[yt-svn] commit/yt: 8 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Apr 14 12:14:55 PDT 2014
8 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/eb255d5bf555/
Changeset: eb255d5bf555
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-10 01:48:44
Summary: Fixing a few RAMSES frontend bugs.
Affected #: 3 files
diff -r 794b2beb2c48272fed16de10daa07975309b950f -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -351,7 +351,7 @@
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
- self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.field_list = [("ramses", f) for f in self.fluid_field_list] \
+ self.particle_field_list
def _setup_auto_fields(self):
@@ -373,8 +373,16 @@
if hydro_fn:
# Read the number of hydro variables
f = open(hydro_fn, "rb")
- fpu.skip(f, 1)
- nvar = fpu.read_vector(f, "i")[0]
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ hvals = fpu.read_attrs(f, hydro_header)
+ self.pf.gamma = hvals['gamma']
+ nvar = hvals['nvar']
# OK, we got NVAR, now set up the arrays depending on what NVAR is
# Allow some wiggle room for users to add too many variables
if nvar < 5:
@@ -440,6 +448,7 @@
class RAMSESDataset(Dataset):
_index_class = RAMSESIndex
_field_info_class = RAMSESFieldInfo
+ gamma = 1.4 # This will get replaced on hydro_fn open
def __init__(self, filename, dataset_type='ramses',
fields = None, storage_filename = None):
@@ -450,6 +459,7 @@
fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
If set to None, will try a default set of fields
'''
+ self.fluid_types += ("ramses",)
self._fields_in_file = fields
Dataset.__init__(self, filename, dataset_type)
self.storage_filename = storage_filename
diff -r 794b2beb2c48272fed16de10daa07975309b950f -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -29,16 +29,6 @@
)
yield header
# TODO: REMOVE
- '''
- hydro_header = ( ('ncpu', 1, 'i'),
- ('nvar', 1, 'i'),
- ('ndim', 1, 'i'),
- ('nlevelmax', 1, 'i'),
- ('nboundary', 1, 'i'),
- ('gamma', 1, 'd')
- )
- yield hydro_header
- '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
diff -r 794b2beb2c48272fed16de10daa07975309b950f -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -105,8 +105,8 @@
def _create_field(name, interp_object):
def _func(field, data):
shape = data["Temperature"].shape
- d = {'lognH': np.log10(_X*data["Density"]/mh).ravel(),
- 'logT' : np.log10(data["Temperature"]).ravel()}
+ d = {'lognH': np.log10(_X*data["density"]/mh).ravel(),
+ 'logT' : np.log10(data["temperature"]).ravel()}
rv = 10**interp_object(d).reshape(shape)
return rv
self.add_field(name = name, function=_func,
https://bitbucket.org/yt_analysis/yt/commits/6287cebead68/
Changeset: 6287cebead68
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 16:00:51
Summary: Merging from tip of experimental
Affected #: 10 files
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -61,6 +61,7 @@
self.field_list = field_list
self.slice_info = slice_info
self.field_aliases = {}
+ self.species_names = []
self.setup_fluid_aliases()
def setup_fluid_fields(self):
@@ -161,6 +162,8 @@
:class:`~yt.data_objects.api.DerivedField`.
"""
+ override = kwargs.pop("force_override", False)
+ if not override and name in self: return
if function is None:
def create_function(function):
self[name] = DerivedField(name, function, **kwargs)
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/fields/fluid_fields.py
--- a/yt/fields/fluid_fields.py
+++ b/yt/fields/fluid_fields.py
@@ -162,12 +162,22 @@
registry.add_field((ftype, "metal_mass"),
function=_metal_mass,
units="g")
+
+ def _number_density(field, data):
+ field_data = np.zeros_like(data["gas", "%s_number_density" % \
+ data.pf.field_info.species_names[0]])
+ for species in data.pf.field_info.species_names:
+ field_data += data["gas", "%s_number_density" % species]
+ return field_data
+ registry.add_field((ftype, "number_density"),
+ function = _number_density,
+ units="cm**-3")
def _mean_molecular_weight(field, data):
return (data[ftype, "density"] / (mh * data[ftype, "number_density"]))
registry.add_field((ftype, "mean_molecular_weight"),
function=_mean_molecular_weight,
- units=r"")
+ units="")
setup_gradient_fields(registry, (ftype, "pressure"), "dyne/cm**2",
slice_info)
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/fields/interpolated_fields.py
--- /dev/null
+++ b/yt/fields/interpolated_fields.py
@@ -0,0 +1,49 @@
+"""
+Fields from interpolating data tables.
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2014, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import numpy as np
+
+from yt.fields.local_fields import add_field
+
+from yt.utilities.linear_interpolators import \
+ UnilinearFieldInterpolator, \
+ BilinearFieldInterpolator, \
+ TrilinearFieldInterpolator
+
+_int_class = {1: UnilinearFieldInterpolator,
+ 2: BilinearFieldInterpolator,
+ 3: TrilinearFieldInterpolator}
+
+def add_interpolated_field(name, units, table_data, axes_data, axes_fields,
+ ftype="gas", particle_type=False, validators=None,
+ truncate=True):
+
+ if len(table_data.shape) not in _int_class:
+ raise RuntimeError("Interpolated field can only be created from 1d, 2d, or 3d data.")
+
+ if len(axes_fields) != len(axes_data) or len(axes_fields) != len(table_data.shape):
+ raise RuntimeError("Data dimension mismatch: data is %d, %d axes data provided, and %d axes fields provided." %
+ (len(table_data.shape), len(axes_data), len(axes_fields)))
+
+ int_class = _int_class[len(table_data.shape)]
+ my_interpolator = int_class(table_data, axes_data, axes_fields, truncate=truncate)
+
+ def _interpolated_field(field, data):
+ return my_interpolator(data)
+ add_field((ftype, name),
+ function=_interpolated_field,
+ units=units,
+ validators=validators, particle_type=particle_type)
+
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/fields/species_fields.py
--- a/yt/fields/species_fields.py
+++ b/yt/fields/species_fields.py
@@ -14,15 +14,22 @@
#-----------------------------------------------------------------------------
import numpy as np
+import re
from yt.utilities.physical_constants import \
mh, \
mass_sun_cgs, \
amu_cgs
+from yt.utilities.physical_ratios import \
+ primordial_H_mass_fraction
from yt.funcs import *
from yt.utilities.chemical_formulas import \
ChemicalFormula
+_primordial_mass_fraction = \
+ {"H": primordial_H_mass_fraction,
+ "He" : (1 - primordial_H_mass_fraction)}
+
# See YTEP-0003 for details, but we want to ensure these fields are all
# populated:
#
@@ -50,7 +57,7 @@
weight *= amu_cgs
def _number_density(field, data):
return data[ftype, "%s_density" % species] \
- / amu_cgs
+ / weight
return _number_density
def _create_density_func(ftype, species):
@@ -102,3 +109,53 @@
function = _create_number_density_func(ftype, species),
particle_type = particle_type,
units = "cm**-3")
+
+def add_nuclei_density_fields(registry, ftype,
+ particle_type = False):
+ elements = _get_all_elements(registry.species_names)
+ for element in elements:
+ registry.add_field((ftype, "%s_nuclei_density" % element),
+ function = _nuclei_density,
+ particle_type = particle_type,
+ units = "cm**-3")
+ if len(elements) == 0:
+ for element in ["H", "He"]:
+ registry.add_field((ftype, "%s_nuclei_density" % element),
+ function = _default_nuclei_density,
+ particle_type = particle_type,
+ units = "cm**-3")
+
+def _default_nuclei_density(field, data):
+ element = field.name[1][:field.name[1].find("_")]
+ return data["gas", "density"] * _primordial_mass_fraction[element] / \
+ ChemicalFormula(element).weight / amu_cgs
+
+def _nuclei_density(field, data):
+ element = field.name[1][:field.name[1].find("_")]
+ field_data = np.zeros_like(data["gas", "%s_number_density" %
+ data.pf.field_info.species_names[0]])
+ for species in data.pf.field_info.species_names:
+ nucleus = species
+ if "_" in species:
+ nucleus = species[:species.find("_")]
+ num = _get_element_multiple(nucleus, element)
+ field_data += num * data["gas", "%s_number_density" % species]
+ return field_data
+
+def _get_all_elements(species_list):
+ elements = []
+ for species in species_list:
+ for item in re.findall('[A-Z][a-z]?|[0-9]+', species):
+ if not item.isdigit() and item not in elements \
+ and item != "El":
+ elements.append(item)
+ return elements
+
+def _get_element_multiple(compound, element):
+ my_split = re.findall('[A-Z][a-z]?|[0-9]+', compound)
+ if element not in my_split:
+ return 0
+ loc = my_split.index(element)
+ if loc == len(my_split) - 1 or not my_split[loc + 1].isdigit():
+ return 1
+ return int(my_split[loc + 1])
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -45,7 +45,9 @@
cm_per_mpc
from .fields import \
- BoxlibFieldInfo
+ BoxlibFieldInfo, \
+ MaestroFieldInfo
+
from .io import IOHandlerBoxlib
# This is what we use to find scientific notation that might include d's
# instead of e's.
@@ -457,21 +459,7 @@
elif param == "castro.use_comoving":
vals = self.cosmological_simulation = int(vals)
else:
- # Now we guess some things about the parameter and its type
- v = vals.split()[0] # Just in case there are multiple; we'll go
- # back afterward to using vals.
- try:
- float(v.upper().replace("D","E"))
- except:
- pcast = str
- else:
- syms = (".", "D+", "D-", "E+", "E-")
- if any(sym in v.upper() for sym in syms for v in vals.split()):
- pcast = float
- else:
- pcast = int
- vals = [pcast(v) for v in vals.split()]
- if len(vals) == 1: vals = vals[0]
+ vals = _guess_pcast(vals)
self.parameters[param] = vals
if getattr(self, "cosmological_simulation", 0) == 1:
@@ -759,6 +747,8 @@
class MaestroDataset(BoxlibDataset):
+ _field_info_class = MaestroFieldInfo
+
@classmethod
def _is_valid(cls, *args, **kwargs):
# fill our args
@@ -775,6 +765,19 @@
if any("maestro" in line.lower() for line in lines): return True
return False
+ def _parse_parameter_file(self):
+ super(MaestroDataset, self)._parse_parameter_file()
+ jobinfo_filename = os.path.join(self.output_dir, "job_info")
+ line = ""
+ with open(jobinfo_filename, "r") as f:
+ while not line.startswith(" [*] indicates overridden default"):
+ line = f.next()
+ for line in f:
+ p, v = (_.strip() for _ in line[4:].split("="))
+ if len(v) == 0:
+ self.parameters[p] = ""
+ else:
+ self.parameters[p] = _guess_pcast(v)
class NyxHierarchy(BoxlibHierarchy):
@@ -871,3 +874,23 @@
self.length_unit = YTQuantity(1.0 / (1 + self.current_redshift),
"mpc")
self.velocity_unit = self.length_unit / self.time_unit
+
+def _guess_pcast(vals):
+ # Now we guess some things about the parameter and its type
+ v = vals.split()[0] # Just in case there are multiple; we'll go
+ # back afterward to using vals.
+ try:
+ float(v.upper().replace("D","E"))
+ except:
+ pcast = str
+ if v in ("F", "T"):
+ pcast = bool
+ else:
+ syms = (".", "D+", "D-", "E+", "E-")
+ if any(sym in v.upper() for sym in syms for v in vals.split()):
+ pcast = float
+ else:
+ pcast = int
+ vals = [pcast(v) for v in vals.split()]
+ if len(vals) == 1: vals = vals[0]
+ return vals
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -14,11 +14,16 @@
#-----------------------------------------------------------------------------
import numpy as np
+import string
from yt.utilities.physical_constants import \
mh, boltzmann_constant_cgs, amu_cgs
from yt.fields.field_info_container import \
FieldInfoContainer
+from yt.fields.species_fields import \
+ add_species_field_by_fraction
+from yt.utilities.chemical_formulas import \
+ ChemicalFormula
rho_units = "code_mass / code_length**3"
mom_units = "code_mass / (code_time * code_length**2)"
@@ -108,3 +113,90 @@
self.add_field(("gas", "velocity_%s" % ax),
function = _get_vel(ax),
units = "cm/s")
+
+class MaestroFieldInfo(FieldInfoContainer):
+
+ known_other_fields = (
+ ("density", ("g/cm**3", ["density"], None)),
+ ("x_vel", ("cm/s", ["velocity_x"], None)),
+ ("y_vel", ("cm/s", ["velocity_y"], None)),
+ ("z_vel", ("cm/s", ["velocity_z"], None)),
+ ("magvel", ("cm/s", ["velocity_magnitude"], None)),
+ ("tfromp", ("K", [], None)),
+ ("tfromh", ("K", [], None)),
+ ("Machnumber", ("", ["mach_number"], None)),
+ ("S", ("1/s", [], None)),
+ ("ad_excess", ("", [], "Adiabatic Excess")),
+ ("deltaT", ("", [], None)),
+ ("deltagamma", ("", [], None)),
+ ("deltap", ("", [], None)),
+ ("divw0", ("1/s", [], None)),
+ # Specific entropy
+ ("entropy", ("erg/(g*K)", ["entropy"], None)),
+ ("entropypert", ("", [], None)),
+ ("enucdot", ("ergs/(g*s)", [], None)),
+ ("gpi_x", ("dyne/cm**3", [], None)), # Perturbational pressure grad
+ ("gpi_y", ("dyne/cm**3", [], None)),
+ ("gpi_z", ("dyne/cm**3", [], None)),
+ ("h", ("erg/g", [], "Specific Enthalpy")),
+ ("h0", ("erg/g", [], "Base State Specific Enthalpy")),
+ # Momentum cannot be computed because we need to include base and
+ # full state.
+ ("momentum", ("g*cm/s", ["momentum_magnitude"], None)),
+ ("p0", ("erg/cm**3", [], "p_0")),
+ ("p0pluspi", ("erg/cm**3", [], "p_0 + \pi")),
+ ("pi", ("erg/cm**3", [], None)),
+ ("pioverp0", ("", [], "\pi/p_0")),
+ # Base state density
+ ("rho0", ("g/cm**3", [], "\\rho_0")),
+ ("rhoh", ("erg/cm**3", ["enthalpy_density"], "(\\rho h)")),
+ # Base state enthalpy density
+ ("rhoh0", ("erg/cm**3", [], "(\\rho h)_0")),
+ ("rhohpert", ("erg/cm**3", [], "(\\rho h)^\prime")),
+ ("rhopert", ("g/cm**3", [], "\\rho^\prime")),
+ ("soundspeed", ("cm/s", ["sound_speed"], None)),
+ ("sponge", ("", [], None)),
+ ("tpert", ("K", [], None)),
+ # Again, base state -- so we can't compute ourselves.
+ ("vort", ("1/s", ["vorticity_magnitude"], None)),
+ # Base state
+ ("w0_x", ("cm/s", [], None)),
+ ("w0_y", ("cm/s", [], None)),
+ ("w0_z", ("cm/s", [], None)),
+ )
+
+ def setup_fluid_fields(self):
+ # Add omegadots, units of 1/s
+ if self.pf.parameters["use_tfromp"]:
+ self.alias(("gas", "temperature"), ("boxlib", "tfromp"),
+ units = "K")
+ else:
+ self.alias(("gas", "temperature"), ("boxlib", "tfromh"),
+ units = "K")
+
+ for _, field in self.pf.field_list:
+ if field.startswith("X("):
+ # We have a fraction
+ nice_name = field[2:-1]
+ self.alias(("gas", "%s_fraction" % nice_name), ("boxlib", field),
+ units = "")
+ def _create_density_func(field_name):
+ def _func(field, data):
+ return data[field_name] * data["gas", "density"]
+ return _func
+ func = _create_density_func(("gas", "%s_fraction" % nice_name))
+ self.add_field(name = ("gas", "%s_density" % nice_name),
+ function = func,
+ units = "g/cm**3")
+ # We know this will either have one letter, or two.
+ if field[3] in string.letters:
+ element, weight = field[2:4], field[4:-1]
+ else:
+ element, weight = field[2:3], field[3:-1]
+ weight = int(weight)
+ # Here we can, later, add number density.
+ if field.startswith("omegadot("):
+ nice_name = field[9:-1]
+ self.add_output_field(("boxlib", field), units = "1/s")
+ self.alias(("gas", "%s_creation_rate" % nice_name),
+ ("boxlib", field), units = "1/s")
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py
+++ b/yt/frontends/enzo/fields.py
@@ -21,6 +21,7 @@
from yt.units.yt_array import \
YTArray
from yt.fields.species_fields import \
+ add_nuclei_density_fields, \
add_species_field_by_density
from yt.utilities.physical_constants import \
mh, me, mp, \
@@ -42,7 +43,7 @@
'HM' : 'H_m1',
'DI' : 'D',
'DII' : 'D_p1',
- 'HD' : 'HD',
+ 'HDI' : 'HD',
'Electron': 'El'
}
@@ -119,8 +120,10 @@
take_log=True,
units="code_mass/code_length**3")
yt_name = known_species_names[species]
- self.alias(("gas", "%s_density" % yt_name),
- ("enzo", "%s_Density" % species))
+ # don't alias electron density since mass is wrong
+ if species != "Electron":
+ self.alias(("gas", "%s_density" % yt_name),
+ ("enzo", "%s_Density" % species))
add_species_field_by_density(self, "gas", yt_name)
def setup_species_fields(self):
@@ -135,7 +138,8 @@
units = "g/cm**3")
for sp in species_names:
self.add_species_field(sp)
-
+ self.species_names.append(known_species_names[sp])
+ add_nuclei_density_fields(self, "gas")
def setup_fluid_fields(self):
# Now we conditionally load a few other things.
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -388,7 +388,7 @@
self.over_refine_factor = over_refine_factor
if field_dtypes is None:
field_dtypes = {}
- success, self.endian = self._validate_header(filename, field_dtypes)
+ success, self.endian = self._validate_header(filename)
if not success:
print "SOMETHING HAS GONE WRONG. NBODIES != SUM PARTICLES."
print "%s != (%s == %s + %s + %s)" % (
@@ -522,7 +522,7 @@
self.time_unit = 1.0 / np.sqrt(G * density_unit)
@staticmethod
- def _validate_header(filename, field_dtypes):
+ def _validate_header(filename):
'''
This method automatically detects whether the tipsy file is big/little endian
and is not corrupt/invalid. It returns a tuple of (Valid, endianswap) where
@@ -534,10 +534,11 @@
except:
return False, 1
try:
- fs = len(f.read())
+ f.seek(0, os.SEEK_END)
+ fs = f.tell()
+ f.seek(0, os.SEEK_SET)
except IOError:
return False, 1
- f.seek(0)
#Read in the header
t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
endianswap = "<"
@@ -546,16 +547,13 @@
endianswap = ">"
f.seek(0)
t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
- # Now we construct the sizes of each of the particles.
- dtypes = IOHandlerTipsyBinary._compute_dtypes(field_dtypes, endianswap)
- #Catch for 4 byte padding
- gas_size = dtypes["Gas"].itemsize
- dm_size = dtypes["DarkMatter"].itemsize
- star_size = dtypes["Stars"].itemsize
- if (fs == 32+gas_size*ng+dm_size*nd+star_size*ns):
- f.read(4)
- #File is borked if this is true
- elif (fs != 28+gas_size*ng+dm_size*nd+star_size*ns):
+ # File is borked if this is true. The header is 28 bytes, and may
+ # Be followed by a 4 byte pad. Next comes gas particles, which use
+ # 48 bytes, followed by 36 bytes per dark matter particle, and 44 bytes
+ # per star particle. If positions are stored as doubles, each of these
+ # sizes is increased by 12 bytes.
+ if (fs != 28+48*ng+36*nd+44*ns and fs != 28+60*ng+48*nd+56*ns and
+ fs != 32+48*ng+36*nd+44*ns and fs != 32+60*ng+48*nd+56*ns):
f.close()
return False, 0
f.close()
@@ -563,8 +561,7 @@
@classmethod
def _is_valid(self, *args, **kwargs):
- field_dtypes = kwargs.get("field_dtypes", {})
- return TipsyDataset._validate_header(args[0], field_dtypes)[0]
+ return TipsyDataset._validate_header(args[0])[0]
class HTTPParticleFile(ParticleFile):
pass
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/utilities/physical_ratios.py
--- a/yt/utilities/physical_ratios.py
+++ b/yt/utilities/physical_ratios.py
@@ -94,6 +94,7 @@
jansky_cgs = 1.0e-23
# Cosmological constants
rho_crit_g_cm3_h2 = 1.8788e-29
+primordial_H_mass_fraction = 0.76
# Misc. Approximations
mass_mean_atomic_cosmology = 1.22
diff -r eb255d5bf555ff2b80ac53c159aa5d7b615ffd33 -r 6287cebead68a0706608db82ea4b4950735e6cd5 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -294,8 +294,9 @@
order += [0, 4, 1, 5, 2, 6, 3, 7]
vertices = np.empty([corners.shape[2]*2*12,3])
+ vertices = self.pf.arr(vertices, "code_length")
for i in xrange(3):
- vertices[:,i] = corners[order,i,:].ravel(order='F')
+ vertices[:,i] = corners[order,i,...].ravel(order='F')
px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
@@ -477,8 +478,9 @@
order += [0, 4, 1, 5, 2, 6, 3, 7]
vertices = np.empty([24,3])
+ vertices = self.pf.arr(vertices, "code_length")
for i in xrange(3):
- vertices[:,i] = corners[order,i,:].ravel(order='F')
+ vertices[:,i] = corners[order,i,...].ravel(order='F')
px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
https://bitbucket.org/yt_analysis/yt/commits/5eb590ee8cac/
Changeset: 5eb590ee8cac
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 16:19:30
Summary: Fix pressure alias for ramses
Affected #: 1 file
diff -r 6287cebead68a0706608db82ea4b4950735e6cd5 -r 5eb590ee8cac9511224c076608968c50b5a490c5 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -70,7 +70,7 @@
("x-velocity", (vel_units, ["velocity_x"], None)),
("y-velocity", (vel_units, ["velocity_y"], None)),
("z-velocity", (vel_units, ["velocity_z"], None)),
- ("Pressure", ("code_mass / (code_length * code_time**2)", [], None)),
+ ("Pressure", ("code_mass / (code_length * code_time**2)", ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
)
known_particle_fields = (
https://bitbucket.org/yt_analysis/yt/commits/1a5546302a74/
Changeset: 1a5546302a74
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 16:44:55
Summary: Answer testing plays a bit of havoc with instantiation.
Affected #: 2 files
diff -r 5eb590ee8cac9511224c076608968c50b5a490c5 -r 1a5546302a74f42ede5b65ef2fe02a6369c4d146 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -112,6 +112,7 @@
_index_class = None
field_units = None
derived_field_list = requires_index("derived_field_list")
+ _instantiated = False
class __metaclass__(type):
def __init__(cls, name, b, d):
@@ -147,8 +148,7 @@
"""
# We return early and do NOT initialize a second time if this file has
# already been initialized.
- if self.known_filters is not None:
- return
+ if self._instantiated: return
self.dataset_type = dataset_type
self.file_style = file_style
self.conversion_factors = {}
diff -r 5eb590ee8cac9511224c076608968c50b5a490c5 -r 1a5546302a74f42ede5b65ef2fe02a6369c4d146 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -95,6 +95,7 @@
header_spec = "default",
field_spec = "default",
ptype_spec = "default"):
+ if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
self._field_spec = self._setup_binary_spec(
https://bitbucket.org/yt_analysis/yt/commits/7a6d31627e8f/
Changeset: 7a6d31627e8f
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 19:24:20
Summary: Fixing MOAB tests.
Affected #: 1 file
diff -r 1a5546302a74f42ede5b65ef2fe02a6369c4d146 -r 7a6d31627e8f87f427cbeb0f579572ebba1f836c yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -24,7 +24,7 @@
FieldValuesTest
from yt.frontends.moab.api import MoabHex8Dataset
-_fields = (("gas", "flux"),
+_fields = (("moab", "flux"),
)
c5 = "c5/c5.h5m"
@@ -39,12 +39,14 @@
yield assert_almost_equal, pf.index.get_smallest_dx(), 0.00411522633744843, 10
yield assert_equal, dd["x"].shape[0], 63*63*63
yield assert_almost_equal, \
- dd["cell_volume"].in_units("code_length**3").sum(dtype="float64"), \
+ dd["cell_volume"].in_units("code_length**3").sum(dtype="float64").d, \
1.0, 10
for offset_1 in [1e-9, 1e-4, 0.1]:
for offset_2 in [1e-9, 1e-4, 0.1]:
- ray = pf.ray(pf.domain_left_edge + offset_1,
- pf.domain_right_edge - offset_2)
+ DLE = pf.domain_left_edge
+ DRE = pf.domain_right_edge
+ ray = pf.ray(DLE + offset_1 * DLE.uq,
+ DRE - offset_2 * DRE.uq)
yield assert_almost_equal, ray["dts"].sum(dtype="float64"), 1.0, 8
for i, p1 in enumerate(np.random.random((5, 3))):
for j, p2 in enumerate(np.random.random((5, 3))):
https://bitbucket.org/yt_analysis/yt/commits/294952584d59/
Changeset: 294952584d59
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 19:28:53
Summary: Updating Chombo and disabling velocity_divergence for Chombo.
Affected #: 3 files
diff -r 7a6d31627e8f87f427cbeb0f579572ebba1f836c -r 294952584d599aae331d55fe18a6fbfc7a5fda83 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -70,7 +70,7 @@
level.
"""
- if self.start_index != None:
+ if self.start_index is not None:
return self.start_index
if self.Parent == []:
iLE = self.LeftEdge - self.pf.domain_left_edge
@@ -84,8 +84,7 @@
def _setup_dx(self):
# has already been read in and stored in index
- self.dds = self.index.dds_list[self.Level]
- self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = self.dds
+ self.dds = self.pf.arr(self.index.dds_list[self.Level], "code_length")
class ChomboHierarchy(GridIndex):
diff -r 7a6d31627e8f87f427cbeb0f579572ebba1f836c -r 294952584d599aae331d55fe18a6fbfc7a5fda83 yt/frontends/chombo/fields.py
--- a/yt/frontends/chombo/fields.py
+++ b/yt/frontends/chombo/fields.py
@@ -25,7 +25,7 @@
_temperature
rho_units = "code_mass / code_length**3"
-mom_units = "code_mass * code_length / code_time"
+mom_units = "code_mass / (code_time * code_length**2)"
eden_units = "code_mass / (code_time**2 * code_length)" # erg / cm^3
# We duplicate everything here from Boxlib, because we want to be able to
@@ -69,7 +69,8 @@
def setup_fluid_fields(self):
def _get_vel(axis):
def velocity(field, data):
- return data["%smom" % ax]/data["density"]
+ return data["momentum_%s" % ax]/data["density"]
+ return velocity
for ax in 'xyz':
self.add_field("velocity_%s" % ax, function = _get_vel(ax),
units = "cm/s")
diff -r 7a6d31627e8f87f427cbeb0f579572ebba1f836c -r 294952584d599aae331d55fe18a6fbfc7a5fda83 yt/frontends/chombo/tests/test_outputs.py
--- a/yt/frontends/chombo/tests/test_outputs.py
+++ b/yt/frontends/chombo/tests/test_outputs.py
@@ -21,7 +21,7 @@
data_dir_load
from yt.frontends.chombo.api import ChomboDataset
-_fields = ("density", "velocity_magnitude", "velocity_divergence",
+_fields = ("density", "velocity_magnitude", #"velocity_divergence",
"magnetic_field_x")
gc = "GaussianCloud/data.0077.3d.hdf5"
https://bitbucket.org/yt_analysis/yt/commits/3b3c8f6d2ce1/
Changeset: 3b3c8f6d2ce1
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-14 20:00:44
Summary: Merging from experimental
Affected #: 2 files
diff -r 294952584d599aae331d55fe18a6fbfc7a5fda83 -r 3b3c8f6d2ce1327c9d763a00b287e9c7e6eb071d yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -779,6 +779,20 @@
else:
self.parameters[p] = _guess_pcast(v)
+ # set the periodicity based on the integer BC runtime parameters
+ periodicity = [True, True, True]
+ if not self.parameters['bcx_lo'] == -1:
+ periodicity[0] = False
+
+ if not self.parameters['bcy_lo'] == -1:
+ periodicity[1] = False
+
+ if not self.parameters['bcz_lo'] == -1:
+ periodicity[2] = False
+
+ self.periodicity = ensure_tuple(periodicity)
+
+
class NyxHierarchy(BoxlibHierarchy):
def __init__(self, pf, dataset_type='nyx_native'):
diff -r 294952584d599aae331d55fe18a6fbfc7a5fda83 -r 3b3c8f6d2ce1327c9d763a00b287e9c7e6eb071d yt/frontends/halo_catalogs/setup.py
--- a/yt/frontends/halo_catalogs/setup.py
+++ b/yt/frontends/halo_catalogs/setup.py
@@ -1,13 +1,10 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
-import glob
+from numpy.distutils.misc_util import Configuration
+
def configuration(parent_package='', top_path=None):
- from numpy.distutils.misc_util import Configuration
config = Configuration('halo_catalogs', parent_package, top_path)
- config.make_config_py() # installs __config__.py
- #config.make_svn_version_py()
+ config.add_subpackage("halo_catalog")
+ config.add_subpackage("rockstar")
+ config.make_config_py()
return config
https://bitbucket.org/yt_analysis/yt/commits/b77623d7526e/
Changeset: b77623d7526e
Branch: yt-3.0
User: xarthisius
Date: 2014-04-14 21:14:47
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #816)
Fixing frontend bugs
Affected #: 9 files
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -112,6 +112,7 @@
_index_class = None
field_units = None
derived_field_list = requires_index("derived_field_list")
+ _instantiated = False
class __metaclass__(type):
def __init__(cls, name, b, d):
@@ -147,8 +148,7 @@
"""
# We return early and do NOT initialize a second time if this file has
# already been initialized.
- if self.known_filters is not None:
- return
+ if self._instantiated: return
self.dataset_type = dataset_type
self.file_style = file_style
self.conversion_factors = {}
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -67,7 +67,7 @@
level.
"""
- if self.start_index != None:
+ if self.start_index is not None:
return self.start_index
if self.Parent == []:
iLE = self.LeftEdge - self.pf.domain_left_edge
@@ -81,8 +81,7 @@
def _setup_dx(self):
# has already been read in and stored in index
- self.dds = self.index.dds_list[self.Level]
- self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = self.dds
+ self.dds = self.pf.arr(self.index.dds_list[self.Level], "code_length")
class ChomboHierarchy(GridIndex):
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/fields.py
--- a/yt/frontends/chombo/fields.py
+++ b/yt/frontends/chombo/fields.py
@@ -25,7 +25,7 @@
_temperature
rho_units = "code_mass / code_length**3"
-mom_units = "code_mass * code_length / code_time"
+mom_units = "code_mass / (code_time * code_length**2)"
eden_units = "code_mass / (code_time**2 * code_length)" # erg / cm^3
# We duplicate everything here from Boxlib, because we want to be able to
@@ -69,7 +69,8 @@
def setup_fluid_fields(self):
def _get_vel(axis):
def velocity(field, data):
- return data["%smom" % ax]/data["density"]
+ return data["momentum_%s" % ax]/data["density"]
+ return velocity
for ax in 'xyz':
self.add_field("velocity_%s" % ax, function = _get_vel(ax),
units = "cm/s")
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/tests/test_outputs.py
--- a/yt/frontends/chombo/tests/test_outputs.py
+++ b/yt/frontends/chombo/tests/test_outputs.py
@@ -21,7 +21,7 @@
data_dir_load
from yt.frontends.chombo.api import ChomboDataset
-_fields = ("density", "velocity_magnitude", "velocity_divergence",
+_fields = ("density", "velocity_magnitude", #"velocity_divergence",
"magnetic_field_x")
gc = "GaussianCloud/data.0077.3d.hdf5"
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -24,7 +24,7 @@
FieldValuesTest
from yt.frontends.moab.api import MoabHex8Dataset
-_fields = (("gas", "flux"),
+_fields = (("moab", "flux"),
)
c5 = "c5/c5.h5m"
@@ -39,12 +39,14 @@
yield assert_almost_equal, pf.index.get_smallest_dx(), 0.00411522633744843, 10
yield assert_equal, dd["x"].shape[0], 63*63*63
yield assert_almost_equal, \
- dd["cell_volume"].in_units("code_length**3").sum(dtype="float64"), \
+ dd["cell_volume"].in_units("code_length**3").sum(dtype="float64").d, \
1.0, 10
for offset_1 in [1e-9, 1e-4, 0.1]:
for offset_2 in [1e-9, 1e-4, 0.1]:
- ray = pf.ray(pf.domain_left_edge + offset_1,
- pf.domain_right_edge - offset_2)
+ DLE = pf.domain_left_edge
+ DRE = pf.domain_right_edge
+ ray = pf.ray(DLE + offset_1 * DLE.uq,
+ DRE - offset_2 * DRE.uq)
yield assert_almost_equal, ray["dts"].sum(dtype="float64"), 1.0, 8
for i, p1 in enumerate(np.random.random((5, 3))):
for j, p2 in enumerate(np.random.random((5, 3))):
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -350,7 +350,7 @@
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
- self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.field_list = [("ramses", f) for f in self.fluid_field_list] \
+ self.particle_field_list
def _setup_auto_fields(self):
@@ -372,8 +372,16 @@
if hydro_fn:
# Read the number of hydro variables
f = open(hydro_fn, "rb")
- fpu.skip(f, 1)
- nvar = fpu.read_vector(f, "i")[0]
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ hvals = fpu.read_attrs(f, hydro_header)
+ self.pf.gamma = hvals['gamma']
+ nvar = hvals['nvar']
# OK, we got NVAR, now set up the arrays depending on what NVAR is
# Allow some wiggle room for users to add too many variables
if nvar < 5:
@@ -439,6 +447,7 @@
class RAMSESDataset(Dataset):
_index_class = RAMSESIndex
_field_info_class = RAMSESFieldInfo
+ gamma = 1.4 # This will get replaced on hydro_fn open
def __init__(self, filename, dataset_type='ramses',
fields = None, storage_filename = None):
@@ -449,6 +458,7 @@
fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
If set to None, will try a default set of fields
'''
+ self.fluid_types += ("ramses",)
self._fields_in_file = fields
Dataset.__init__(self, filename, dataset_type)
self.storage_filename = storage_filename
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -29,16 +29,6 @@
)
yield header
# TODO: REMOVE
- '''
- hydro_header = ( ('ncpu', 1, 'i'),
- ('nvar', 1, 'i'),
- ('ndim', 1, 'i'),
- ('nlevelmax', 1, 'i'),
- ('nboundary', 1, 'i'),
- ('gamma', 1, 'd')
- )
- yield hydro_header
- '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -70,7 +70,7 @@
("x-velocity", (vel_units, ["velocity_x"], None)),
("y-velocity", (vel_units, ["velocity_y"], None)),
("z-velocity", (vel_units, ["velocity_z"], None)),
- ("Pressure", ("code_mass / (code_length * code_time**2)", [], None)),
+ ("Pressure", ("code_mass / (code_length * code_time**2)", ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
)
known_particle_fields = (
@@ -105,8 +105,8 @@
def _create_field(name, interp_object):
def _func(field, data):
shape = data["Temperature"].shape
- d = {'lognH': np.log10(_X*data["Density"]/mh).ravel(),
- 'logT' : np.log10(data["Temperature"]).ravel()}
+ d = {'lognH': np.log10(_X*data["density"]/mh).ravel(),
+ 'logT' : np.log10(data["temperature"]).ravel()}
rv = 10**interp_object(d).reshape(shape)
return rv
self.add_field(name = name, function=_func,
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -95,6 +95,7 @@
header_spec = "default",
field_spec = "default",
ptype_spec = "default"):
+ if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
self._field_spec = self._setup_binary_spec(
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list