[yt-svn] commit/yt: 21 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Apr 3 06:01:23 PDT 2014
21 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/4bd47fec61f7/
Changeset: 4bd47fec61f7
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-24 18:27:41
Summary: First pass at updating answer_tests for new field schema.
Affected #: 3 files
diff -r 8998ed2194500cd405198102eb90239d20e73b75 -r 4bd47fec61f729c029136e095729d442d3782dbb yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -345,7 +345,7 @@
This is a helper function to return the location of the most dense
point.
"""
- return self.pf.h.find_max("Density")[1]
+ return self.pf.h.find_max("density")[1]
@property
def entire_simulation(self):
@@ -378,9 +378,9 @@
def run(self):
obj = create_obj(self.pf, self.obj_type)
- avg = obj.quantities["WeightedAverageQuantity"](self.field,
- weight="Ones")
- (mi, ma), = obj.quantities["Extrema"](self.field)
+ avg = obj.quantities.weighted_average_quantity(
+ self.field, weight="ones")
+ mi, ma = obj.quantities.extrema(self.field)
return np.array([avg, mi, ma])
def compare(self, new_result, old_result):
@@ -710,7 +710,7 @@
yield GridValuesTest(pf_fn, field)
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield ProjectionValuesTest(
pf_fn, axis, field, weight_field,
ds)
@@ -726,7 +726,7 @@
yield GridValuesTest(pf_fn, field)
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf_fn, axis, field, weight_field,
ds)
diff -r 8998ed2194500cd405198102eb90239d20e73b75 -r 4bd47fec61f729c029136e095729d442d3782dbb yt/utilities/answer_testing/hydro_tests.py
--- a/yt/utilities/answer_testing/hydro_tests.py
+++ b/yt/utilities/answer_testing/hydro_tests.py
@@ -141,14 +141,14 @@
# function, which is a relatively simple function that takes the base class,
# a name, and any parameters that the test requires.
for axis in range(3):
- for field in ["Density", "Temperature"]:
+ for field in ["density", "temperature"]:
create_test(TestProjection, "projection_test_%s_%s" % (axis, field),
field = field, axis = axis)
class TestGasDistribution(YTDatasetTest):
field_x = None
field_y = None
- weight = "CellMassMsun"
+ weight = "cell_mass"
n_bins = 32
def run(self):
@@ -172,14 +172,14 @@
# Now we create all our tests, but we're only going to check the binning
# against Density for now.
-for field in ["Temperature", "velocity_x"]:
+for field in ["temperature", "velocity_x"]:
create_test(TestGasDistribution, "profile_density_test_%s" % field,
- field_x = "Density", field_y = field)
+ field_x = "density", field_y = field)
class Test2DGasDistribution(TestGasDistribution):
x_bins = 128
y_bins = 128
- field_z = "CellMassMsun"
+ field_z = "cell_mass"
weight = None
def run(self):
# We're NOT going to use the low-level profiling API here,
diff -r 8998ed2194500cd405198102eb90239d20e73b75 -r 4bd47fec61f729c029136e095729d442d3782dbb yt/utilities/answer_testing/output_tests.py
--- a/yt/utilities/answer_testing/output_tests.py
+++ b/yt/utilities/answer_testing/output_tests.py
@@ -212,7 +212,7 @@
This is a helper function to return the location of the most dense
point.
"""
- return self.pf.h.find_max("Density")[1]
+ return self.pf.h.find_max("density")[1]
@property
def entire_simulation(self):
https://bitbucket.org/yt_analysis/yt/commits/374c5defd862/
Changeset: 374c5defd862
Branch: yt-3.0
User: ngoldbaum
Date: 2014-03-24 21:19:47
Summary: Updating the FLASH answer tests. Updating the GridHierarchyTest.
Affected #: 2 files
diff -r 4bd47fec61f729c029136e095729d442d3782dbb -r 374c5defd8625531c250f8008da6e8b547abba7c yt/frontends/flash/tests/test_outputs.py
--- a/yt/frontends/flash/tests/test_outputs.py
+++ b/yt/frontends/flash/tests/test_outputs.py
@@ -21,7 +21,7 @@
data_dir_load
from yt.frontends.flash.api import FLASHDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+_fields = ("temperature", "density", "velocity_magnitude", "velocity_divergence")
sloshing = "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0300"
@requires_pf(sloshing, big_data=True)
@@ -32,7 +32,7 @@
test_sloshing.__name__ = test.description
yield test
-_fields_2d = ("Temperature", "Density")
+_fields_2d = ("temperature", "density")
wt = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
@requires_pf(wt)
diff -r 4bd47fec61f729c029136e095729d442d3782dbb -r 374c5defd8625531c250f8008da6e8b547abba7c yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -551,11 +551,11 @@
def run(self):
result = {}
- result["grid_dimensions"] = self.pf.grid_dimensions
- result["grid_left_edges"] = self.pf.grid_left_edge
- result["grid_right_edges"] = self.pf.grid_right_edge
- result["grid_levels"] = self.pf.grid_levels
- result["grid_particle_count"] = self.pf.grid_particle_count
+ result["grid_dimensions"] = self.pf.index.grid_dimensions
+ result["grid_left_edges"] = self.pf.index.grid_left_edge
+ result["grid_right_edges"] = self.pf.index.grid_right_edge
+ result["grid_levels"] = self.pf.index.grid_levels
+ result["grid_particle_count"] = self.pf.index.grid_particle_count
return result
def compare(self, new_result, old_result):
https://bitbucket.org/yt_analysis/yt/commits/93f13016be95/
Changeset: 93f13016be95
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-24 23:55:16
Summary: First pass at updating field names for answer tests.
Affected #: 9 files
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/art/tests/test_outputs.py
--- a/yt/frontends/art/tests/test_outputs.py
+++ b/yt/frontends/art/tests/test_outputs.py
@@ -22,7 +22,7 @@
data_dir_load
from yt.frontends.art.api import ARTDataset
-_fields = ("Density", "particle_mass", ("all", "particle_position_x"))
+_fields = ("density", "particle_mass", ("all", "particle_position_x"))
sfg1 = "10MpcBox_csf512_a0.330.d"
@@ -35,7 +35,7 @@
for field in _fields:
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
sfg1, axis, field, weight_field,
ds)
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/artio/tests/test_outputs.py
--- a/yt/frontends/artio/tests/test_outputs.py
+++ b/yt/frontends/artio/tests/test_outputs.py
@@ -23,7 +23,7 @@
create_obj
from yt.frontends.artio.api import ARTIODataset
-_fields = ("Temperature", "Density", "VelocityMagnitude",
+_fields = ("temperature", "density", "velocity_magnitude",
("deposit", "all_density"), ("deposit", "all_count"))
sizmbhloz = "sizmbhloz-clref04SNth-rs9_a0.9011/sizmbhloz-clref04SNth-rs9_a0.9011.art"
@@ -36,12 +36,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
sizmbhloz, axis, field, weight_field,
ds)
yield FieldValuesTest(sizmbhloz, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/boxlib/tests/test_orion.py
--- a/yt/frontends/boxlib/tests/test_orion.py
+++ b/yt/frontends/boxlib/tests/test_orion.py
@@ -21,7 +21,8 @@
data_dir_load
from yt.frontends.boxlib.api import OrionDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+_fields = ("temperature", "density", "velocity_magnitude",
+ "velocity_divergence")
radadvect = "RadAdvect/plt00000"
@requires_pf(radadvect)
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 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,8 @@
data_dir_load
from yt.frontends.chombo.api import ChomboDataset
-_fields = ("Density", "VelocityMagnitude", "DivV", "X-magnfield")
+_fields = ("density", "velocity_magnitude", "velocity_divergence",
+ "magnetic_field_x")
gc = "GaussianCloud/data.0077.3d.hdf5"
@requires_pf(gc)
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/enzo/tests/test_outputs.py
--- a/yt/frontends/enzo/tests/test_outputs.py
+++ b/yt/frontends/enzo/tests/test_outputs.py
@@ -21,7 +21,8 @@
data_dir_load
from yt.frontends.enzo.api import EnzoDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+_fields = ("temperature", "density", "velocity_magnitude",
+ "velocity_divergence")
m7 = "DD0010/moving7_0010"
@requires_pf(m7)
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -38,7 +38,9 @@
dd = pf.h.all_data()
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["CellVolumeCode"].sum(dtype="float64"), 1.0, 10
+ yield assert_almost_equal, \
+ dd["cell_volume"].in_units("code_length**3").sum(dtype="float64"), \
+ 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,
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -23,7 +23,7 @@
create_obj
from yt.frontends.artio.api import ARTIODataset
-_fields = ("Temperature", "Density", "VelocityMagnitude",
+_fields = ("temperature", "density", "velocity_magnitude",
("deposit", "all_density"), ("deposit", "all_count"))
output_00080 = "output_00080/info_00080.txt"
@@ -35,12 +35,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
output_00080, axis, field, weight_field,
ds)
yield FieldValuesTest(output_00080, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/sph/tests/test_owls.py
--- a/yt/frontends/sph/tests/test_owls.py
+++ b/yt/frontends/sph/tests/test_owls.py
@@ -36,20 +36,20 @@
yield assert_equal, str(pf), "snap_033"
dso = [ None, ("sphere", ("c", (0.1, 'unitary')))]
dd = pf.h.all_data()
- yield assert_equal, dd["Coordinates"].shape[0], 2*(128*128*128)
- yield assert_equal, dd["Coordinates"].shape[1], 3
- tot = sum(dd[ptype,"Coordinates"].shape[0]
+ yield assert_equal, dd["particle_position"].shape[0], 2*(128*128*128)
+ yield assert_equal, dd["particle_position"].shape[1], 3
+ tot = sum(dd[ptype,"particle_position"].shape[0]
for ptype in pf.particle_types if ptype != "all")
yield assert_equal, tot, (2*128*128*128)
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
os33, axis, field, weight_field,
ds)
yield FieldValuesTest(os33, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 374c5defd8625531c250f8008da6e8b547abba7c -r 93f13016be95d457e03b31be6748de898faab424 yt/frontends/sph/tests/test_tipsy.py
--- a/yt/frontends/sph/tests/test_tipsy.py
+++ b/yt/frontends/sph/tests/test_tipsy.py
@@ -40,7 +40,7 @@
kwargs = dict(endian="<",
field_dtypes = {"Coordinates": "d"},
cosmology_parameters = cosmology_parameters,
- unit_base = {'mpchcm': 1.0/60.0},
+ unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
pf = data_dir_load(pkdgrav, TipsyDataset, (), kwargs)
yield assert_equal, str(pf), "halo1e11_run1.00400"
@@ -53,13 +53,13 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf, axis, field, weight_field,
ds)
yield FieldValuesTest(pf, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
@@ -71,7 +71,7 @@
omega_matter = 0.272,
hubble_constant = 0.702)
kwargs = dict(cosmology_parameters = cosmology_parameters,
- unit_base = {'mpchcm': 1.0/60.0},
+ unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
pf = data_dir_load(gasoline, TipsyDataset, (), kwargs)
yield assert_equal, str(pf), "agora_1e11.00400"
@@ -84,12 +84,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf, axis, field, weight_field,
ds)
yield FieldValuesTest(pf, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
https://bitbucket.org/yt_analysis/yt/commits/97c6c2e1d8d6/
Changeset: 97c6c2e1d8d6
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 00:20:28
Summary: Fixing some of the ARTIO data_structure and field defs.
Affected #: 2 files
diff -r 93f13016be95d457e03b31be6748de898faab424 -r 97c6c2e1d8d60fa3e00b1863aa12daee989299a1 yt/frontends/artio/data_structures.py
--- a/yt/frontends/artio/data_structures.py
+++ b/yt/frontends/artio/data_structures.py
@@ -59,7 +59,6 @@
self.sfc_end = sfc_end
self.oct_handler = oct_handler
self.pf = pf
- self.index = self.pf.index
self._last_mask = None
self._last_selector_id = None
self._current_particle_type = 'all'
diff -r 93f13016be95d457e03b31be6748de898faab424 -r 97c6c2e1d8d60fa3e00b1863aa12daee989299a1 yt/frontends/artio/fields.py
--- a/yt/frontends/artio/fields.py
+++ b/yt/frontends/artio/fields.py
@@ -24,7 +24,9 @@
from yt.utilities.physical_constants import \
mh, \
- mass_sun_cgs
+ mass_sun_cgs, \
+ boltzmann_constant_cgs, \
+ amu_cgs
b_units = "code_magnetic"
ra_units = "code_length / code_time**2"
@@ -43,7 +45,7 @@
("HVAR_MOMENTUM_X", (mom_units, ["momentum_x"], None)),
("HVAR_MOMENTUM_Y", (mom_units, ["momentum_y"], None)),
("HVAR_MOMENTUM_Z", (mom_units, ["momentum_z"], None)),
- ("HVAR_GAMMA", ("", "gamma", None)),
+ ("HVAR_GAMMA", ("", ["gamma"], None)),
("HVAR_METAL_DENSITY_Ia", (rho_units, ["metal_ia_density"], None)),
("HVAR_METAL_DENSITY_II", (rho_units, ["metal_ii_density"], None)),
("VAR_POTENTIAL", ("", ["potential"], None)),
@@ -69,9 +71,11 @@
def setup_fluid_fields(self):
def _get_vel(axis):
def velocity(field, data):
- return data["momentum_%s" % ax]/data["density"]
+ return data["momentum_%s" % axis]/data["density"]
+ return velocity
for ax in 'xyz':
- self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ self.add_field(("gas", "velocity_%s" % ax),
+ function = _get_vel(ax),
units = "cm/s")
def _temperature(field, data):
@@ -79,26 +83,31 @@
# We want this to match *exactly* what ARTIO would compute
# internally. We therefore use the exact values that are internal
# to ARTIO, rather than yt's own internal constants.
- amu = 1.660538782e-24
- mH = 1.007825*amu
- mHe = 4.002602*amu
+ mH = 1.007825*amu_cgs
+ mHe = 4.002602*amu_cgs
Yp = 0.24
XH = 1.0 - Yp
XHe = 0.25*Yp
mb = XH*mH + XHe*mHe
wmu = 4.0/(8.0-5.0*Yp)
# Note that we have gamma = 5.0/3.0 here
- return tr * wmu * (data["gamma"] - 1)
+ tr *= (data["gamma"] - 1.0)
+ tr *= wmu
+ tr *= mb/boltzmann_constant_cgs
+ return tr
# TODO: The conversion factor here needs to be addressed, as previously
# it was set as:
# unit_T = unit_v**2.0*mb / constants.k
- self.add_field("temperature", function = _temperature, units = "")
+ self.add_field(("gas", "temperature"), function = _temperature,
+ units = "K")
def _metal_density(field, data):
tr = data["metal_ia_density"]
tr += data["metal_ii_density"]
return tr
- self.add_field("metal_density", function=_metal_density, units="g/cm**3",
+ self.add_field(("gas","metal_density"),
+ function=_metal_density,
+ units="g/cm**3",
take_log=True)
def setup_particle_fields(self, ptype):
https://bitbucket.org/yt_analysis/yt/commits/e368576a884d/
Changeset: e368576a884d
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 00:46:44
Summary: Removing some of the indirection in ARTIO.
Affected #: 2 files
diff -r 97c6c2e1d8d60fa3e00b1863aa12daee989299a1 -r e368576a884d558ea17e21b5f65151f0bfb89648 yt/frontends/artio/data_structures.py
--- a/yt/frontends/artio/data_structures.py
+++ b/yt/frontends/artio/data_structures.py
@@ -18,7 +18,7 @@
import weakref
import cStringIO
-from .definitions import yt_to_art, art_to_yt, ARTIOconstants
+from .definitions import ARTIOconstants
from _artio_caller import \
artio_is_valid, artio_fileset, ARTIOOctreeContainer, \
ARTIORootMeshContainer, ARTIOSFCRangeHandler
@@ -93,31 +93,24 @@
def fill_particles(self, fields):
if len(fields) == 0: return {}
- art_fields = []
- for s, f in fields:
- fn = yt_to_art[f]
- for i in self.pf.particle_type_map[s]:
- if fn in self.pf.particle_variables[i]:
- art_fields.append((i, fn))
+ ptype_indices = self.pf.particle_types
+ art_fields = [(ptype_indices.index(ptype), fname) for
+ ptype, fname in fields]
species_data = self.oct_handler.fill_sfc_particles(art_fields)
tr = defaultdict(dict)
# Now we need to sum things up and then fill
for s, f in fields:
count = 0
- fn = yt_to_art[f]
dt = "float64" # default
- for i in self.pf.particle_type_map[s]:
- if (i, fn) not in species_data: continue
- # No vector fields in ARTIO
- count += species_data[i, fn].size
- dt = species_data[i, fn].dtype
+ i = ptype_indices.index(s)
+ # No vector fields in ARTIO
+ count += species_data[i, f].size
+ dt = species_data[i, f].dtype
tr[s][f] = np.zeros(count, dtype=dt)
cp = 0
- for i in self.pf.particle_type_map[s]:
- if (i, fn) not in species_data: continue
- v = species_data.pop((i, fn))
- tr[s][f][cp:cp+v.size] = v
- cp += v.size
+ v = species_data.pop((i, f))
+ tr[s][f][cp:cp+v.size] = v
+ cp += v.size
return tr
# We create something of a fake octree here. This is primarily to enable us to
@@ -224,13 +217,10 @@
def _detect_particle_fields(self):
fields = set()
- for ptype in self.pf.particle_types:
- if ptype == "all": continue
- for f in yt_to_art.values():
- if all(f in self.pf.particle_variables[i]
- for i in range(self.pf.num_species)
- if art_to_yt[self.pf.particle_species[i]] == ptype):
- fields.add((ptype, art_to_yt[f]))
+ for i, ptype in enumerate(self.pf.particle_types):
+ if ptype == "all": break # This will always be after all intrinsic
+ for fname in self.pf.particle_variables[i]:
+ fields.add((ptype, fname))
return list(fields)
def _identify_base_chunk(self, dobj):
@@ -369,14 +359,9 @@
self.num_species = self.artio_parameters["num_particle_species"][0]
self.particle_variables = [["PID", "SPECIES"]
for i in range(self.num_species)]
- self.particle_species = \
+ self.particle_types_raw = \
self.artio_parameters["particle_species_labels"]
- self.particle_type_map = {}
- for i, s in enumerate(self.particle_species):
- f = art_to_yt[s]
- if f not in self.particle_type_map:
- self.particle_type_map[f] = []
- self.particle_type_map[f].append(i)
+ self.particle_types = tuple(self.particle_types_raw)
for species in range(self.num_species):
# Mass would be best as a derived field,
@@ -396,10 +381,6 @@
"species_%02d_secondary_variable_labels"
% (species, )])
- self.particle_types_raw = tuple(
- set(art_to_yt[s] for s in
- self.artio_parameters["particle_species_labels"]))
- self.particle_types = tuple(self.particle_types)
else:
self.num_species = 0
self.particle_variables = []
diff -r 97c6c2e1d8d60fa3e00b1863aa12daee989299a1 -r e368576a884d558ea17e21b5f65151f0bfb89648 yt/frontends/artio/io.py
--- a/yt/frontends/artio/io.py
+++ b/yt/frontends/artio/io.py
@@ -35,27 +35,27 @@
return tr
def _read_particle_coords(self, chunks, ptf):
- pn = "particle_position_%s"
+ pn = "POSITION_%s"
chunks = list(chunks)
- fields = [(ptype, "particle_position_%s" % ax)
+ fields = [(ptype, pn % ax)
for ptype, field_list in ptf.items()
- for ax in 'xyz']
+ for ax in 'XYZ']
for chunk in chunks: # These should be organized by grid filename
for subset in chunk.objs:
rv = dict(**subset.fill_particles(fields))
for ptype, field_list in sorted(ptf.items()):
x, y, z = (np.asarray(rv[ptype][pn % ax], dtype="=f8")
- for ax in 'xyz')
+ for ax in 'XYZ')
yield ptype, (x, y, z)
rv.pop(ptype)
def _read_particle_fields(self, chunks, ptf, selector):
- pn = "particle_position_%s"
+ pn = "POSITION_%s"
chunks = list(chunks)
fields = [(ptype, fname) for ptype, field_list in ptf.items()
for fname in field_list]
for ptype, field_list in sorted(ptf.items()):
- for ax in 'xyz':
+ for ax in 'XYZ':
if pn % ax not in field_list:
fields.append((ptype, pn % ax))
for chunk in chunks: # These should be organized by grid filename
@@ -63,7 +63,7 @@
rv = dict(**subset.fill_particles(fields))
for ptype, field_list in sorted(ptf.items()):
x, y, z = (np.asarray(rv[ptype][pn % ax], dtype="=f8")
- for ax in 'xyz')
+ for ax in 'XYZ')
mask = selector.select_points(x, y, z)
if mask is None: continue
for field in field_list:
https://bitbucket.org/yt_analysis/yt/commits/b5bc8c240512/
Changeset: b5bc8c240512
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 01:15:11
Summary: Starting process of fixing Boxlib answer_tests.
Affected #: 2 files
diff -r e368576a884d558ea17e21b5f65151f0bfb89648 -r b5bc8c2405125efc107ba388bcb965a1074ddb6e yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -386,6 +386,8 @@
self.parameters["HydroMethod"] = 'boxlib'
self.parameters["Time"] = 1. # default unit is 1...
self.parameters["EOSType"] = -1 # default
+ self.parameters["gamma"] = self.parameters.get(
+ "materials.gamma", 1.6667)
def _localize_check(self, fn):
# If the file exists, use it. If not, set it to None.
diff -r e368576a884d558ea17e21b5f65151f0bfb89648 -r b5bc8c2405125efc107ba388bcb965a1074ddb6e yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -36,8 +36,9 @@
return data["thermal_energy_density"] / data["density"]
def _temperature(field,data):
- mu = data.get_field_parameter("mu")
- return ( (data.pf.gamma-1.0) * mu * mh *
+ mu = data.pf.parameters["mu"]
+ gamma = data.pf.parameters["gamma"]
+ return ( gamma * mu * mh *
data["thermal_energy"] / (kboltz * data["density"]) )
@@ -74,17 +75,19 @@
)
def setup_fluid_fields(self):
+ self._show_field_errors.append(("gas", "temperature"))
def _get_vel(axis):
def velocity(field, data):
- return data["%smom" % ax]/data["density"]
+ return data["%smom" % axis]/data["density"]
for ax in 'xyz':
- self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ self.add_field(("gas", "velocity_%s" % ax),
+ function = _get_vel(ax),
units = "cm/s")
- self.add_field("thermal_energy",
+ self.add_field(("gas", "thermal_energy"),
function = _thermal_energy,
units = "erg/g")
- self.add_field("thermal_energy_density",
+ self.add_field(("gas", "thermal_energy_density"),
function = _thermal_energy_density,
units = "erg/cm**3")
- self.add_field("temperature", function=_temperature,
+ self.add_field(("gas", "temperature"), function=_temperature,
units="K")
https://bitbucket.org/yt_analysis/yt/commits/da06fbbc6782/
Changeset: da06fbbc6782
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 01:15:35
Summary: Merging from mainline experimental bookmark
Affected #: 24 files
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 doc/source/analyzing/creating_derived_fields.rst
--- a/doc/source/analyzing/creating_derived_fields.rst
+++ b/doc/source/analyzing/creating_derived_fields.rst
@@ -295,8 +295,6 @@
(*Advanced*) Should this field appear in the dropdown box in Reason?
``not_in_all``
(*Advanced*) If this is *True*, the field may not be in all the grids.
- ``projection_conversion``
- (*Advanced*) Which unit should we multiply by in a projection?
How Do Units Work?
------------------
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 doc/source/analyzing/objects.rst
--- a/doc/source/analyzing/objects.rst
+++ b/doc/source/analyzing/objects.rst
@@ -40,8 +40,7 @@
add_enzo_field("Cooling_Time", units=r"\rm{s}",
function=NullFunc,
- validators=ValidateDataField("Cooling_Time"),
- projection_conversion="1")
+ validators=ValidateDataField("Cooling_Time"))
Note that we used the ``NullFunc`` function here. To add a derived field,
which is not expected to necessarily exist on disk, use the standard
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -39,26 +39,35 @@
pass
vlist = "xyz"
+def setup_sunyaev_zeldovich_fields(registry, ftype = "gas", slice_info = None):
+ def _t_squared(field, data):
+ return data["gas","density"]*data["gas","kT"]*data["gas","kT"]
+ registry.add_field(("gas", "t_squared"),
+ function = _t_squared,
+ units="g*keV**2/cm**3")
+ def _beta_perp_squared(field, data):
+ return data["gas","density"]*data["gas","velocity_magnitude"]**2/clight/clight - data["gas","beta_par_squared"]
+ registry.add_field(("gas","beta_perp_squared"),
+ function = _beta_perp_squared,
+ units="g/cm**3")
- at derived_field(name=("gas","t_squared"), units="g*keV**2/cm**3")
-def _t_squared(field, data):
- return data["gas","density"]*data["gas","kT"]*data["gas","kT"]
+ def _beta_par_squared(field, data):
+ return data["gas","beta_par"]**2/data["gas","density"]
+ registry.add_field(("gas","beta_par_squared"),
+ function = _beta_par_squared,
+ units="g/cm**3")
- at derived_field(name=("gas","beta_perp_squared"), units="g/cm**3")
-def _beta_perp_squared(field, data):
- return data["gas","density"]*data["gas","velocity_magnitude"]**2/clight/clight - data["gas","beta_par_squared"]
+ def _t_beta_par(field, data):
+ return data["gas","kT"]*data["gas","beta_par"]
+ registry.add_field(("gas","t_beta_par"),
+ function = _t_beta_par,
+ units="keV*g/cm**3")
- at derived_field(name=("gas","beta_par_squared"), units="g/cm**3")
-def _beta_par_squared(field, data):
- return data["gas","beta_par"]**2/data["gas","density"]
-
- at derived_field(name=("gas","t_beta_par"), units="keV*g/cm**3")
-def _t_beta_par(field, data):
- return data["gas","kT"]*data["gas","beta_par"]
-
- at derived_field(name=("gas","t_sz"), units="keV*g/cm**3")
-def _t_sz(field, data):
- return data["gas","density"]*data["gas","kT"]
+ def _t_sz(field, data):
+ return data["gas","density"]*data["gas","kT"]
+ registry.add_field(("gas","t_sz"),
+ function = _t_sz,
+ units="keV*g/cm**3")
def generate_beta_par(L):
def _beta_par(field, data):
@@ -90,6 +99,7 @@
def __init__(self, pf, freqs, mue=1.143, high_order=False):
self.pf = pf
+ pf.field_info.load_plugin(setup_sunyaev_zeldovich_fields)
self.num_freqs = len(freqs)
self.high_order = high_order
self.freqs = pf.arr(freqs, "GHz")
@@ -138,8 +148,7 @@
L[axis] = 1.0
beta_par = generate_beta_par(L)
- self.pf.field_info.add_field(name=("gas","beta_par"), function=beta_par, units="g/cm**3")
- proj = self.pf.proj("density", axis, center=ctr, data_source=source)
+ self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
frb = proj.to_frb(width, nx)
dens = frb["density"]
Te = frb["t_sz"]/dens
@@ -202,7 +211,7 @@
raise NotImplementedError
beta_par = generate_beta_par(L)
- self.pf.field_info.add_field(name=("gas","beta_par"), function=beta_par, units="g/cm**3")
+ self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
dens = off_axis_projection(self.pf, ctr, L, w, nx, "density")
Te = off_axis_projection(self.pf, ctr, L, w, nx, "t_sz")/dens
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -517,7 +517,7 @@
# Now all the object related stuff
def all_data(self, find_max=False):
- if find_max: c = self.find_max("Density")[1]
+ if find_max: c = self.find_max("density")[1]
else: c = (self.domain_right_edge + self.domain_left_edge)/2.0
return self.region(c,
self.domain_left_edge, self.domain_right_edge)
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -78,14 +78,11 @@
Used for baryon fields from the data that are not in all the grids
display_name : str
A name used in the plots
- projection_conversion : unit
- which unit should we multiply by in a projection?
"""
def __init__(self, name, function, units=None,
take_log=True, validators=None,
particle_type=False, vector_field=False, display_field=True,
- not_in_all=False, display_name=None,
- projection_conversion="cm"):
+ not_in_all=False, display_name=None):
self.name = name
self.take_log = take_log
self.display_name = display_name
@@ -124,7 +121,6 @@
dd['display_field'] = True
dd['not_in_all'] = self.not_in_all
dd['display_name'] = self.display_name
- dd['projection_conversion'] = self.projection_conversion
return dd
def get_units(self):
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -172,8 +172,11 @@
self.find_dependencies(loaded)
def load_plugin(self, plugin_name, ftype = "gas", skip_check = False):
+ if callable(plugin_name):
+ f = plugin_name
+ else:
+ f = field_plugins[plugin_name]
orig = set(self.items())
- f = field_plugins[plugin_name]
f(self, ftype, slice_info = self.slice_info)
loaded = [n for n, v in set(self.items()).difference(orig)]
return loaded
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -78,7 +78,6 @@
registry.add_field(("index", "zeros"), function=_zeros,
units = "",
- projection_conversion="unitary",
display_field=False)
def _ones(field, data):
@@ -88,7 +87,6 @@
return data.apply_units(arr, field.units)
registry.add_field(("index", "ones"), function=_ones,
- projection_conversion="unitary",
units = "",
display_field=False)
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/fields/particle_fields.py
--- a/yt/fields/particle_fields.py
+++ b/yt/fields/particle_fields.py
@@ -80,8 +80,7 @@
registry.add_field(("deposit", "%s_count" % ptype),
function = particle_count,
validators = [ValidateSpatial()],
- display_name = "\\mathrm{%s Count}" % ptype,
- projection_conversion = '1')
+ display_name = "\\mathrm{%s Count}" % ptype)
def particle_mass(field, data):
pos = data[ptype, coord_name]
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/fields/species_fields.py
--- a/yt/fields/species_fields.py
+++ b/yt/fields/species_fields.py
@@ -53,6 +53,12 @@
/ amu_cgs
return _number_density
+def _create_density_func(ftype, species):
+ def _density(field, data):
+ return data[ftype, "%s_fraction" % species] \
+ * data[ftype,'density']
+ return _density
+
def add_species_field_by_density(registry, ftype, species):
"""
This takes a field registry, a fluid type, and a species name and then
@@ -68,3 +74,19 @@
registry.add_field((ftype, "%s_number_density" % species),
function = _create_number_density_func(ftype, species),
units = "cm**-3")
+
+def add_species_field_by_fraction(registry, ftype, species):
+ """
+ This takes a field registry, a fluid type, and a species name and then
+ adds the other fluids based on that. This assumes that the field
+ "SPECIES_fraction" already exists and refers to mass fraction.
+ """
+ registry.add_field((ftype, "%s_density" % species),
+ function = _create_density_func(ftype, species),
+ units = "g/cm**3")
+ registry.add_field((ftype, "%s_mass" % species),
+ function = _create_mass_func(ftype, species),
+ units = "g")
+ registry.add_field((ftype, "%s_number_density" % species),
+ function = _create_number_density_func(ftype, species),
+ units = "cm**-3")
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -177,10 +177,20 @@
if self.dimensionality < 3:
dx[i].append(DRE[2] - DLE[1])
self.level_dds = np.array(dx, dtype="float64")
+ coordinate_type = int(header_file.next())
+ if self.pf.geometry == "cartesian":
+ default_ybounds = (0.0, 1.0)
+ default_zbounds = (0.0, 1.0)
+ elif self.pf.geometry == "cylindrical":
+ # Now we check for dimensionality issues
+ if self.dimensionality != 2:
+ raise RuntimeError("yt needs cylindrical to be 2D")
+ self.level_dds[:,2] = 2*np.pi
+ default_zbounds = (0.0, 2*np.pi)
+ else:
+ raise RuntimeError("yt only supports cartesian and cylindrical coordinates.")
if int(header_file.next()) != 0:
- raise RunTimeError("yt only supports cartesian coordinates.")
- if int(header_file.next()) != 0:
- raise RunTimeError("INTERNAL ERROR! This should be a zero.")
+ raise RuntimeError("INTERNAL ERROR! This should be a zero.")
# each level is one group with ngrids on it.
# each grid has self.dimensionality number of lines of 2 reals
@@ -196,11 +206,11 @@
if self.dimensionality > 1:
ylo, yhi = [float(v) for v in header_file.next().split()]
else:
- ylo, yhi = 0.0, 1.0
+ ylo, yhi = default_ybounds
if self.dimensionality > 2:
zlo, zhi = [float(v) for v in header_file.next().split()]
else:
- zlo, zhi = 0.0, 1.0
+ zlo, zhi = default_zbounds
self.grid_left_edge[grid_counter + gi, :] = [xlo, ylo, zlo]
self.grid_right_edge[grid_counter + gi, :] = [xhi, yhi, zhi]
# Now we get to the level header filename, which we open and parse.
@@ -571,6 +581,14 @@
# Skip timesteps per level
header_file.readline()
self._header_mesh_start = header_file.tell()
+ header_file.next()
+ coordinate_type = int(header_file.next())
+ if coordinate_type == 0:
+ self.geometry = "cartesian"
+ elif coordinate_type == 1:
+ self.geometry = "cylindrical"
+ else:
+ raise RuntimeError("yt does not yet support spherical geometry")
# overrides for 1/2-dimensional data
if self.dimensionality == 1:
@@ -599,12 +617,12 @@
self.periodicity = ensure_tuple(tmp)
def _setup2d(self):
-# self._index_class = BoxlibHierarchy2D
-# self._fieldinfo_fallback = Orion2DFieldInfo
self.domain_left_edge = \
np.concatenate([self.domain_left_edge, [0.0]])
self.domain_right_edge = \
np.concatenate([self.domain_right_edge, [1.0]])
+ if self.geometry == "cylindrical":
+ self.domain_right_edge[2] = 2.0 * np.pi
tmp = self.domain_dimensions.tolist()
tmp.append(1)
self.domain_dimensions = np.array(tmp)
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -24,8 +24,6 @@
mom_units = "code_mass * code_length / code_time"
eden_units = "code_mass / (code_time**2 * code_length)" # erg / cm^3
-
-
def _thermal_energy_density(field, data):
ke = 0.5 * ( data["momentum_x"]**2
+ data["momentum_y"]**2
@@ -50,6 +48,8 @@
("ymom", (mom_units, ["momentum_y"], None)),
("zmom", (mom_units, ["momentum_z"], None)),
("temperature", ("K", ["temperature"], None)),
+ ("x_velocity", ("cm/s", ["velocity_x"], None)),
+ ("y_velocity", ("cm/s", ["velocity_y"], None)),
)
known_particle_fields = (
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/chombo/api.py
--- a/yt/frontends/chombo/api.py
+++ b/yt/frontends/chombo/api.py
@@ -19,8 +19,8 @@
ChomboDataset
from .fields import \
- ChomboFieldInfo, \
- add_chombo_field
+ ChomboFieldInfo
+add_chombo_field = ChomboFieldInfo.add_field
from .io import \
IOHandlerChomboHDF5
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -43,12 +43,15 @@
mpc_conversion, sec_conversion
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_root_only
+from yt.units.yt_array import \
+ YTArray, \
+ YTQuantity
+from yt.utilities.lib.misc_utilities import \
+ get_box_grids_level
from yt.utilities.io_handler import \
io_registry
-from yt.fields.field_info_container import \
- FieldInfoContainer, NullFunc
-from .fields import ChomboFieldInfo, KnownChomboFields
+from .fields import ChomboFieldInfo
class ChomboGrid(AMRGridPatch):
_id_offset = 0
@@ -104,7 +107,6 @@
self._levels = self._handle.keys()[1:]
GridIndex.__init__(self,pf,dataset_type)
self._read_particles()
- self._fhandle.close()
def _read_particles(self):
self.particle_filename = self.index_filename[:-4] + 'sink'
@@ -136,7 +138,7 @@
def _detect_output_fields(self):
ncomp = int(self._handle['/'].attrs['num_components'])
- self.field_list = [c[1] for c in self._handle['/'].attrs.items()[-ncomp:]]
+ self.field_list = [("chombo", c[1]) for c in self._handle['/'].attrs.items()[-ncomp:]]
def _count_grids(self):
self.num_grids = 0
@@ -174,32 +176,38 @@
# self.grids = np.array(self.grids, dtype='object')
def _populate_grid_objects(self):
+ self._reconstruct_parent_child()
for g in self.grids:
g._prepare_grid()
g._setup_dx()
-
- for g in self.grids:
- g.Children = self._get_grid_children(g)
- for g1 in g.Children:
- g1.Parent.append(g)
self.max_level = self.grid_levels.max()
def _setup_derived_fields(self):
self.derived_field_list = []
- def _get_grid_children(self, grid):
- mask = np.zeros(self.num_grids, dtype='bool')
- grids, grid_ind = self.get_box_grids(grid.LeftEdge, grid.RightEdge)
- mask[grid_ind] = True
- return [g for g in self.grids[mask] if g.Level == grid.Level + 1]
+ def _reconstruct_parent_child(self):
+ mask = np.empty(len(self.grids), dtype='int32')
+ mylog.debug("First pass; identifying child grids")
+ for i, grid in enumerate(self.grids):
+ get_box_grids_level(self.grid_left_edge[i,:],
+ self.grid_right_edge[i,:],
+ self.grid_levels[i] + 1,
+ self.grid_left_edge, self.grid_right_edge,
+ self.grid_levels, mask)
+ ids = np.where(mask.astype("bool")) # where is a tuple
+ grid._children_ids = ids[0] + grid._id_offset
+ mylog.debug("Second pass; identifying parents")
+ for i, grid in enumerate(self.grids): # Second pass
+ for child in grid.Children:
+ child._parent_id.append(i + grid._id_offset)
class ChomboDataset(Dataset):
_index_class = ChomboHierarchy
- _fieldinfo_fallback = ChomboFieldInfo
- _fieldinfo_known = KnownChomboFields
+ _field_info_class = ChomboFieldInfo
def __init__(self, filename, dataset_type='chombo_hdf5',
storage_filename = None, ini_filename = None):
+ self.fluid_types += ("chombo",)
self._handle = h5py.File(filename,'r')
self.current_time = self._handle.attrs['time']
self.ini_filename = ini_filename
@@ -216,34 +224,11 @@
def __del__(self):
self._handle.close()
- def _set_units(self):
- """
- Generates the conversion to various physical _units based on the parameter file
- """
- self.units = {}
- self.time_units = {}
- if len(self.parameters) == 0:
- self._parse_parameter_file()
- self._setup_nounits_units()
- self.conversion_factors = defaultdict(lambda: 1.0)
- self.time_units['1'] = 1
- self.units['1'] = 1.0
- self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
- seconds = 1 #self["Time"]
- for unit in sec_conversion.keys():
- self.time_units[unit] = seconds / sec_conversion[unit]
- for key in yt2chomboFieldsDict:
- self.conversion_factors[key] = 1.0
-
- def _setup_nounits_units(self):
- z = 0
- mylog.warning("Setting 1.0 in code units to be 1.0 cm")
- if not self.has_key("TimeUnits"):
- mylog.warning("No time units. Setting 1.0 = 1 second.")
- self.conversion_factors["Time"] = 1.0
- for unit in mpc_conversion.keys():
- self.units[unit] = mpc_conversion[unit] / mpc_conversion["cm"]
-
+ def _set_code_unit_attributes(self):
+ self.length_unit = YTQuantity(1.0, "cm")
+ self.mass_unit = YTQuantity(1.0, "g")
+ self.time_unit = YTQuantity(1.0, "s")
+ self.velocity_unit = YTQuantity(1.0, "cm/s")
def _localize(self, f, default):
if f is None:
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/chombo/fields.py
--- a/yt/frontends/chombo/fields.py
+++ b/yt/frontends/chombo/fields.py
@@ -13,159 +13,71 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import numpy as np
from yt.fields.field_info_container import \
- FieldInfoContainer, \
- FieldInfo, \
- NullFunc, \
- ValidateParameter, \
- ValidateDataField, \
- ValidateProperty, \
- ValidateSpatial, \
- ValidateGridType
-import numpy as np
+ FieldInfoContainer
+from yt.frontends.boxlib.fields import \
+ rho_units, \
+ mom_units, \
+ eden_units, \
+ _thermal_energy_density, \
+ _thermal_energy, \
+ _temperature
-KnownChomboFields = FieldInfoContainer()
-add_chombo_field = KnownChomboFields.add_field
+rho_units = "code_mass / code_length**3"
+mom_units = "code_mass * code_length / code_time"
+eden_units = "code_mass / (code_time**2 * code_length)" # erg / cm^3
-ChomboFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
-add_field = ChomboFieldInfo.add_field
+# We duplicate everything here from Boxlib, because we want to be able to
+# subclass it and that can be somewhat tricky.
+class ChomboFieldInfo(FieldInfoContainer):
+ known_other_fields = (
+ ("density", (rho_units, ["density"], None)),
+ ("energy-density", (eden_units, ["energy_density"], None)),
+ ("radiation-energy-density", (eden_units, ["radiation_energy_density"], None)),
+ ("X-momentum", (mom_units, ["momentum_x"], None)),
+ ("Y-momentum", (mom_units, ["momentum_y"], None)),
+ ("Z-momentum", (mom_units, ["momentum_z"], None)),
+ ("temperature", ("K", ["temperature"], None)),
+ ("X-magnfield", ("gauss", ["magnetic_field_x"], None)),
+ ("Y-magnfield", ("gauss", ["magnetic_field_y"], None)),
+ ("Z-magnfield", ("gauss", ["magnetic_field_z"], None)),
+ )
-add_chombo_field("density", function=NullFunc, take_log=True,
- validators = [ValidateDataField("density")],
- units="g/cm**3")
+ known_particle_fields = (
+ ("particle_mass", ("code_mass", [], None)),
+ ("particle_position_x", ("code_length", [], None)),
+ ("particle_position_y", ("code_length", [], None)),
+ ("particle_position_z", ("code_length", [], None)),
+ ("particle_momentum_x", (mom_units, [], None)),
+ ("particle_momentum_y", (mom_units, [], None)),
+ ("particle_momentum_z", (mom_units, [], None)),
+ # Note that these are *internal* agmomen
+ ("particle_angmomen_x", ("code_length**2/code_time", [], None)),
+ ("particle_angmomen_y", ("code_length**2/code_time", [], None)),
+ ("particle_angmomen_z", ("code_length**2/code_time", [], None)),
+ ("particle_mlast", ("code_mass", [], None)),
+ ("particle_r", ("code_length", [], None)),
+ ("particle_mdeut", ("code_mass", [], None)),
+ ("particle_n", ("", [], None)),
+ ("particle_mdot", ("code_mass/code_time", [], None)),
+ ("particle_burnstate", ("", [], None)),
+ ("particle_luminosity", ("", [], None)),
+ ("particle_id", ("", ["particle_index"], None)),
+ )
-add_chombo_field("X-momentum", function=NullFunc, take_log=False,
- validators = [ValidateDataField("X-Momentum")],
- units="g/cm**2/s",display_name=r"M_x")
-
-add_chombo_field("Y-momentum", function=NullFunc, take_log=False,
- validators = [ValidateDataField("Y-Momentum")],
- units="g/cm**2/s",display_name=r"M_y")
-
-add_chombo_field("Z-momentum", function=NullFunc, take_log=False,
- validators = [ValidateDataField("Z-Momentum")],
- units="g/cm**2/s",display_name=r"M_z")
-
-add_chombo_field("X-magnfield", function=NullFunc, take_log=False,
- validators = [ValidateDataField("X-Magnfield")],
- units="gauss",display_name=r"B_x")
-
-add_chombo_field("Y-magnfield", function=NullFunc, take_log=False,
- validators = [ValidateDataField("Y-Magnfield")],
- units="gauss",display_name=r"B_y")
-
-add_chombo_field("Z-magnfield", function=NullFunc, take_log=False,
- validators = [ValidateDataField("Z-Magnfield")],
- units="gauss",display_name=r"B_z")
-
-add_chombo_field("energy-density", function=NullFunc, take_log=True,
- validators = [ValidateDataField("energy-density")],
- units="erg/cm**3")
-
-add_chombo_field("radiation-energy-density", function=NullFunc, take_log=True,
- validators = [ValidateDataField("radiation-energy-density")],
- units="erg/cm**3")
-
-def _Density(field,data):
- """A duplicate of the density field. This is needed because when you try
- to instantiate a PlotCollection without passing in a center, the code
- will try to generate one for you using the "Density" field, which gives an error
- if it isn't defined.
-
- """
- return data["density"]
-add_field("Density",function=_Density, take_log=True,
- units='g/cm**3')
-
-def _Bx(field,data):
- return data["X-magnfield"]
-add_field("Bx", function=_Bx, take_log=False,
- units="gauss", display_name=r"B_x")
-
-def _By(field,data):
- return data["Y-magnfield"]
-add_field("By", function=_By, take_log=False,
- units="gauss", display_name=r"B_y")
-
-def _Bz(field,data):
- return data["Z-magnfield"]
-add_field("Bz", function=_Bz, take_log=False,
- units="gauss", display_name=r"B_z")
-
-def _MagneticEnergy(field,data):
- return (data["X-magnfield"]**2 +
- data["Y-magnfield"]**2 +
- data["Z-magnfield"]**2)/2.
-add_field("MagneticEnergy", function=_MagneticEnergy, take_log=True,
- units=r"erg/cm**3", display_name=r"B^2 / 8 \pi")
-
-def _xVelocity(field, data):
- """ Generate x-velocity from x-momentum and density. """
- return data["X-momentum"]/data["density"]
-add_field("x-velocity",function=_xVelocity, take_log=False,
- units='cm/s')
-
-def _yVelocity(field,data):
- """ Generate y-velocity from y-momentum and density. """
- #try:
- # return data["xvel"]
- #except KeyError:
- return data["Y-momentum"]/data["density"]
-add_field("y-velocity",function=_yVelocity, take_log=False,
- units='cm/s')
-
-def _zVelocity(field,data):
- """ Generate z-velocity from z-momentum and density. """
- return data["Z-momentum"]/data["density"]
-add_field("z-velocity",function=_zVelocity, take_log=False,
- units='cm/s')
-
-def particle_func(p_field, dtype='float64'):
- def _Particles(field, data):
- io = data.index.io
- if not data.NumberOfParticles > 0:
- return np.array([], dtype=dtype)
- else:
- return io._read_particles(data, p_field).astype(dtype)
-
- return _Particles
-
-_particle_field_list = ["mass",
- "position_x",
- "position_y",
- "position_z",
- "momentum_x",
- "momentum_y",
- "momentum_z",
- "angmomen_x",
- "angmomen_y",
- "angmomen_z",
- "mlast",
- "r",
- "mdeut",
- "n",
- "mdot",
- "burnstate",
- "luminosity",
- "id"]
-
-for pf in _particle_field_list:
- pfunc = particle_func("particle_%s" % (pf))
- add_field("particle_%s" % pf, function=pfunc,
- validators = [ValidateSpatial(0)],
- particle_type=True)
-
-def _ParticleMass(field, data):
- particles = data["particle_mass"].astype('float64')
- return particles
-
-def _ParticleMassMsun(field, data):
- particles = data["particle_mass"].astype('float64')
- return particles/1.989e33
-
-add_field("ParticleMass",
- function=_ParticleMass, validators=[ValidateSpatial(0)],
- particle_type=True)
-add_field("ParticleMassMsun",
- function=_ParticleMassMsun, validators=[ValidateSpatial(0)],
- particle_type=True)
+ def setup_fluid_fields(self):
+ def _get_vel(axis):
+ def velocity(field, data):
+ return data["%smom" % ax]/data["density"]
+ for ax in 'xyz':
+ self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ units = "cm/s")
+ self.add_field("thermal_energy",
+ function = _thermal_energy,
+ units = "erg/g")
+ self.add_field("thermal_energy_density",
+ function = _thermal_energy_density,
+ units = "erg/cm**3")
+ self.add_field("temperature", function=_temperature,
+ units="K")
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/chombo/io.py
--- a/yt/frontends/chombo/io.py
+++ b/yt/frontends/chombo/io.py
@@ -16,6 +16,7 @@
import os
import re
import numpy as np
+from yt.utilities.logger import ytLogger as mylog
from yt.utilities.io_handler import \
BaseIOHandler
@@ -26,8 +27,7 @@
_data_string = 'data:datatype=0'
def __init__(self, pf, *args, **kwargs):
- BaseIOHandler.__init__(self, *args, **kwargs)
- self.pf = pf
+ BaseIOHandler.__init__(self, pf)
self._handle = pf._handle
_field_dict = None
@@ -61,6 +61,52 @@
return data.reshape(dims, order='F')
+ def _read_fluid_selection(self, chunks, selector, fields, size):
+ rv = {}
+ chunks = list(chunks)
+ fields.sort(key=lambda a: self.field_dict[a[1]])
+ if selector.__class__.__name__ == "GridSelector":
+ if not (len(chunks) == len(chunks[0].objs) == 1):
+ raise RuntimeError
+ grid = chunks[0].objs[0]
+ lstring = 'level_%i' % grid.Level
+ lev = self._handle[lstring]
+ grid_offset = lev[self._offset_string][grid._level_id]
+ boxsize = grid.ActiveDimensions.prod()
+ for ftype, fname in fields:
+ start = grid_offset+self.field_dict[fname]*boxsize
+ stop = start + boxsize
+ data = lev[self._data_string][start:stop]
+ rv[ftype, fname] = data.reshape(grid.ActiveDimensions,
+ order='F')
+ return rv
+ if size is None:
+ size = sum((g.count(selector) for chunk in chunks
+ for g in chunk.objs))
+ for field in fields:
+ ftype, fname = field
+ fsize = size
+ rv[field] = np.empty(fsize, dtype="float64")
+ ng = sum(len(c.objs) for c in chunks)
+ mylog.debug("Reading %s cells of %s fields in %s grids",
+ size, [f2 for f1, f2 in fields], ng)
+ ind = 0
+ for chunk in chunks:
+ for g in chunk.objs:
+ lstring = 'level_%i' % g.Level
+ lev = self._handle[lstring]
+ grid_offset = lev[self._offset_string][g._level_id]
+ boxsize = g.ActiveDimensions.prod()
+ nd = 0
+ for field in fields:
+ start = grid_offset+self.field_dict[fname]*boxsize
+ stop = start + boxsize
+ data = lev[self._data_string][start:stop]
+ data = data.reshape(g.ActiveDimensions, order='F')
+ nd = g.select(selector, data, rv[field], ind) # caches
+ ind += nd
+ return rv
+
def _read_particles(self, grid, field):
"""
parses the Orion Star Particle text files
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -38,7 +38,7 @@
mass_sun_cgs
from yt.utilities.cosmology import Cosmology
from .fields import \
- SPHFieldInfo
+ SPHFieldInfo, OWLSFieldInfo
from .definitions import \
gadget_header_specs, \
gadget_field_specs, \
@@ -284,6 +284,7 @@
class OWLSDataset(GadgetHDF5Dataset):
_particle_mass_name = "Mass"
+ _field_info_class = OWLSFieldInfo
def _parse_parameter_file(self):
handle = h5py.File(self.parameter_filename, mode="r")
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -23,6 +23,10 @@
gadget_ptypes, \
ghdf5_ptypes
+from yt.fields.species_fields import add_species_field_by_fraction
+
+
+
# Here are helper functions for things like vector fields and so on.
def _get_conv(cf):
@@ -50,3 +54,40 @@
("Phi", ("code_length", [], None)),
("FormationTime", ("code_time", ["creation_time"], None)),
)
+
+
+
+
+class OWLSFieldInfo(SPHFieldInfo):
+
+ _species_fractions = ['H_fraction', 'He_fraction', 'C_fraction',
+ 'N_fraction', 'O_fraction', 'Ne_fraction',
+ 'Mg_fraction', 'Si_fraction', 'Fe_fraction']
+
+ # override
+ #--------------------------------------------------------------
+ def __init__(self, *args, **kwargs):
+
+ new_particle_fields = (
+ ('Hydrogen', ('', ['H_fraction'], None)),
+ ('Helium', ('', ['He_fraction'], None)),
+ ('Carbon', ('', ['C_fraction'], None)),
+ ('Nitrogen', ('', ['N_fraction'], None)),
+ ('Oxygen', ('', ['O_fraction'], None)),
+ ('Neon', ('', ['Ne_fraction'], None)),
+ ('Magnesium', ('', ['Mg_fraction'], None)),
+ ('Silicon', ('', ['Si_fraction'], None)),
+ ('Iron', ('', ['Fe_fraction'], None))
+ )
+
+ self.known_particle_fields += new_particle_fields
+
+ super(OWLSFieldInfo,self).__init__( *args, **kwargs )
+
+
+
+ def setup_fluid_fields(self):
+ # here species_name is "H", "He", etc
+ for s in self._species_fractions:
+ species_name = s.split('_')[0]
+ add_species_field_by_fraction(self, "gas", species_name)
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -53,6 +53,9 @@
_vector_fields = ("Coordinates", "Velocity", "Velocities")
_known_ptypes = ghdf5_ptypes
_var_mass = None
+ _element_fields = ('Hydrogen', 'Helium', 'Carbon', 'Nitrogen', 'Oxygen',
+ 'Neon', 'Magnesium', 'Silicon', 'Iron' )
+
@property
def var_mass(self):
@@ -100,13 +103,20 @@
del coords
if mask is None: continue
for field in field_list:
+
if field in ("Mass", "Masses") and \
ptype not in self.var_mass:
data = np.empty(mask.sum(), dtype="float64")
ind = self._known_ptypes.index(ptype)
data[:] = self.pf["Massarr"][ind]
+
+ elif field in self._element_fields:
+ rfield = 'ElementAbundance/' + field
+ data = g[rfield][:][mask,...]
+
else:
data = g[field][:][mask,...]
+
yield (ptype, field), data
f.close()
@@ -144,24 +154,46 @@
npart = dict(("PartType%s" % (i), v) for i, v in enumerate(pcount))
return npart
+
def _identify_fields(self, data_file):
f = _get_h5_handle(data_file.filename)
fields = []
- cname = self.pf._particle_coordinates_name
- mname = self.pf._particle_mass_name
- for key in f.keys():
+ cname = self.pf._particle_coordinates_name # Coordinates
+ mname = self.pf._particle_mass_name # Mass
+
+ # loop over all keys in OWLS hdf5 file
+ #--------------------------------------------------
+ for key in f.keys():
+
+ # only want particle data
+ #--------------------------------------
if not key.startswith("PartType"): continue
+
+ # particle data group
+ #--------------------------------------
g = f[key]
if cname not in g: continue
+
+ # note str => not unicode!
+
#ptype = int(key[8:])
ptype = str(key)
+
+ # loop over all keys in PartTypeX group
+ #----------------------------------------
for k in g.keys():
- if not hasattr(g[k], "shape"): continue
- # str => not unicode!
- fields.append((ptype, str(k)))
- if mname not in g.keys():
- # We'll append it anyway.
- fields.append((ptype, mname))
+
+ if k == 'ElementAbundance':
+ gp = g[k]
+ for j in gp.keys():
+ kk = j
+ fields.append((ptype, str(kk)))
+ else:
+ kk = k
+ if not hasattr(g[kk], "shape"): continue
+ fields.append((ptype, str(kk)))
+
+
f.close()
return fields, {}
@@ -420,12 +452,12 @@
raise RuntimeError
# Use the mask to slice out the appropriate particle type data
- if mask.size == data_file.total_particles['DarkMatter']:
- return auxdata[:data_file.total_particles['DarkMatter']]
- elif mask.size == data_file.total_particles['Gas']:
- return auxdata[data_file.total_particles['DarkMatter']:data_file.total_particles['Stars']]
+ if mask.size == data_file.total_particles['Gas']:
+ return auxdata[:data_file.total_particles['Gas']]
+ elif mask.size == data_file.total_particles['DarkMatter']:
+ return auxdata[data_file.total_particles['Gas']:-data_file.total_particles['DarkMatter']]
else:
- return auxdata[data_file.total_particles['Stars']:]
+ return auxdata[-data_file.total_particles['Stars']:]
def _fill_fields(self, fields, vals, mask, data_file):
if mask is None:
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/geometry/cartesian_coordinates.py
--- a/yt/geometry/cartesian_coordinates.py
+++ b/yt/geometry/cartesian_coordinates.py
@@ -17,7 +17,8 @@
import numpy as np
from .coordinate_handler import \
CoordinateHandler, \
- _unknown_coord
+ _unknown_coord, \
+ _get_coord_fields
class CartesianCoordinateHandler(CoordinateHandler):
@@ -25,16 +26,8 @@
super(CartesianCoordinateHandler, self).__init__(pf)
def setup_fields(self, registry):
- def _get_coord_fields(axi, ax):
- def _dds(field, data):
- rv = data.pf.arr(data.fwidth[...,axi], 'code_length')
- return data._reshape_vals(rv)
- def _coords(field, data):
- rv = data.pf.arr(data.fcoords[...,axi], 'code_length')
- return data._reshape_vals(rv)
- return _dds, _coords
for axi, ax in enumerate('xyz'):
- f1, f2 = _get_coord_fields(axi, ax)
+ f1, f2 = _get_coord_fields(axi)
registry.add_field(("index", "d%s" % ax), function = f1,
display_field = False,
units = "code_length")
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/geometry/coordinate_handler.py
--- a/yt/geometry/coordinate_handler.py
+++ b/yt/geometry/coordinate_handler.py
@@ -32,6 +32,15 @@
def _unknown_coord(field, data):
raise YTCoordinateNotImplemented
+def _get_coord_fields(axi, units = "code_length"):
+ def _dds(field, data):
+ rv = data.pf.arr(data.fwidth[...,axi], units)
+ return data._reshape_vals(rv)
+ def _coords(field, data):
+ rv = data.pf.arr(data.fcoords[...,axi], units)
+ return data._reshape_vals(rv)
+ return _dds, _coords
+
class CoordinateHandler(object):
def __init__(self, pf):
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/geometry/cylindrical_coordinates.py
--- a/yt/geometry/cylindrical_coordinates.py
+++ b/yt/geometry/cylindrical_coordinates.py
@@ -18,8 +18,8 @@
from yt.units.yt_array import YTArray
from .coordinate_handler import \
CoordinateHandler, \
- _unknown_coord
-
+ _unknown_coord, \
+ _get_coord_fields
#
# Cylindrical fields
#
@@ -36,54 +36,29 @@
registry.add_field(("index", "dy"), function=_unknown_coord)
registry.add_field(("index", "x"), function=_unknown_coord)
registry.add_field(("index", "y"), function=_unknown_coord)
+ f1, f2 = _get_coord_fields(0)
+ registry.add_field(("index", "dr"), function = f1,
+ display_field = False,
+ units = "code_length")
+ registry.add_field(("index", "r"), function = f2,
+ display_field = False,
+ units = "code_length")
- def _dr(field, data):
- return np.ones(data.ActiveDimensions, dtype='float64') * data.dds[0]
- registry.add_field(("index", "dr"),
- function=_dr,
- display_field=False,
- validators=[ValidateSpatial(0)])
+ f1, f2 = _get_coord_fields(1)
+ registry.add_field(("index", "dz"), function = f1,
+ display_field = False,
+ units = "code_length")
+ registry.add_field(("index", "z"), function = f2,
+ display_field = False,
+ units = "code_length")
- def _dz(field, data):
- return np.ones(data.ActiveDimensions, dtype='float64') * data.dds[1]
- registry.add_field(("index", "dz"),
- function=_dz,
- display_field=False,
- validators=[ValidateSpatial(0)])
-
- def _dtheta(field, data):
- return np.ones(data.ActiveDimensions, dtype='float64') * data.dds[2]
- registry.add_field(("index", "dtheta"),
- function=_dtheta,
- display_field=False,
- validators=[ValidateSpatial(0)])
-
- def _coordR(field, data):
- dim = data.ActiveDimensions[0]
- return (np.ones(data.ActiveDimensions, dtype='float64')
- * np.arange(data.ActiveDimensions[0])[:,None,None]
- +0.5) * data["index", "dr"] + data.LeftEdge[0]
- registry.add_field(("index", "r"),
- function=_coordR, display_field=False,
- validators=[ValidateSpatial(0)])
-
- def _coordZ(field, data):
- dim = data.ActiveDimensions[1]
- return (np.ones(data.ActiveDimensions, dtype='float64')
- * np.arange(data.ActiveDimensions[1])[None,:,None]
- +0.5) * data["index", "dz"] + data.LeftEdge[1]
- registry.add_field(("index", "z"),
- function=_coordZ, display_field=False,
- validators=[ValidateSpatial(0)])
-
- def _coordTheta(field, data):
- dim = data.ActiveDimensions[2]
- return (np.ones(data.ActiveDimensions, dtype='float64')
- * np.arange(data.ActiveDimensions[2])[None,None,:]
- +0.5) * data["index", "dtheta"] + data.LeftEdge[2]
- registry.add_field(("index", "theta"),
- function=_coordTheta, display_field=False,
- validators=[ValidateSpatial(0)])
+ f1, f2 = _get_coord_fields(2, "")
+ registry.add_field(("index", "dtheta"), function = f1,
+ display_field = False,
+ units = "")
+ registry.add_field(("index", "theta"), function = f2,
+ display_field = False,
+ units = "")
def _CylindricalVolume(field, data):
return data["index", "dtheta"] \
@@ -91,7 +66,8 @@
* data["index", "dr"] \
* data["index", "dz"]
registry.add_field(("index", "cell_volume"),
- function=_CylindricalVolume)
+ function=_CylindricalVolume,
+ units = "code_length**3")
def pixelize(self, dimension, data_source, field, bounds, size, antialias = True):
diff -r b5bc8c2405125efc107ba388bcb965a1074ddb6e -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -102,8 +102,8 @@
HaloCatalogDataset, HaloCatalogFieldInfo, \
RockstarDataset, RockstarFieldInfo
-#from yt.frontends.chombo.api import \
-# ChomboDataset, ChomboFieldInfo, add_chombo_field
+from yt.frontends.chombo.api import \
+ ChomboDataset, ChomboFieldInfo, add_chombo_field
from yt.frontends.gdf.api import \
GDFDataset, GDFFieldInfo, add_gdf_field
https://bitbucket.org/yt_analysis/yt/commits/a9b93a7642a5/
Changeset: a9b93a7642a5
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 02:08:26
Summary: Fixing some boxlib/orion mismatches for geometry.
Affected #: 2 files
diff -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 -r a9b93a7642a58f0f548a9fe3be6aa812881f0149 yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -177,7 +177,7 @@
if self.dimensionality < 3:
dx[i].append(DRE[2] - DLE[1])
self.level_dds = np.array(dx, dtype="float64")
- coordinate_type = int(header_file.next())
+ header_file.next()
if self.pf.geometry == "cartesian":
default_ybounds = (0.0, 1.0)
default_zbounds = (0.0, 1.0)
@@ -582,7 +582,11 @@
header_file.readline()
self._header_mesh_start = header_file.tell()
header_file.next()
- coordinate_type = int(header_file.next())
+ next_line = header_file.next()
+ if len(next_line.split()) == 1:
+ coordinate_type = int(next_line)
+ else:
+ coordinate_type = 0
if coordinate_type == 0:
self.geometry = "cartesian"
elif coordinate_type == 1:
diff -r da06fbbc6782c4341e8db6d69cab0c1fc45a0144 -r a9b93a7642a58f0f548a9fe3be6aa812881f0149 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -48,6 +48,7 @@
("ymom", (mom_units, ["momentum_y"], None)),
("zmom", (mom_units, ["momentum_z"], None)),
("temperature", ("K", ["temperature"], None)),
+ ("Temp", ("K", ["temperature"], None)),
("x_velocity", ("cm/s", ["velocity_x"], None)),
("y_velocity", ("cm/s", ["velocity_y"], None)),
)
@@ -89,5 +90,7 @@
self.add_field(("gas", "thermal_energy_density"),
function = _thermal_energy_density,
units = "erg/cm**3")
- self.add_field(("gas", "temperature"), function=_temperature,
- units="K")
+ if ("gas", "temperature") not in self.field_aliases:
+ self.add_field(("gas", "temperature"),
+ function=_temperature,
+ units="K")
https://bitbucket.org/yt_analysis/yt/commits/de5b75b74ca6/
Changeset: de5b75b74ca6
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 02:31:14
Summary: Adjustments to Boxlib temperature.
The issue I am now seeing is that the thermal_energy_density and thermal_energy
fields are not defined consistently between the various frontends in yt, which
is a problem here, as I feel I should be able to use the same definition for
temperature in here and in ARTIO, but it does not work. I am missing
something.
Affected #: 1 file
diff -r a9b93a7642a58f0f548a9fe3be6aa812881f0149 -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -16,29 +16,35 @@
import numpy as np
from yt.utilities.physical_constants import \
- mh, kboltz
+ mh, boltzmann_constant_cgs, amu_cgs
from yt.fields.field_info_container import \
FieldInfoContainer
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
def _thermal_energy_density(field, data):
+ # What we've got here is UEINT:
+ # u here is velocity
+ # E is energy density from the file
+ # rho e = rho E - rho * u * u / 2
ke = 0.5 * ( data["momentum_x"]**2
+ data["momentum_y"]**2
+ data["momentum_z"]**2) / data["density"]
return data["eden"] - ke
def _thermal_energy(field, data):
+ # This is little e, so we take thermal_energy_density and divide by density
return data["thermal_energy_density"] / data["density"]
def _temperature(field,data):
mu = data.pf.parameters["mu"]
gamma = data.pf.parameters["gamma"]
- return ( gamma * mu * mh *
- data["thermal_energy"] / (kboltz * data["density"]) )
-
+ tr = data["thermal_energy_density"] / data["density"]
+ tr *= mu * amu_cgs / boltzmann_constant_cgs
+ tr *= (gamma - 1.0)
+ return tr
class BoxlibFieldInfo(FieldInfoContainer):
known_other_fields = (
https://bitbucket.org/yt_analysis/yt/commits/14708c1d5e51/
Changeset: 14708c1d5e51
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-25 05:25:40
Summary: Merging from experimental bookmark
Affected #: 8 files
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -372,25 +372,6 @@
particle type specifications. *These are all excellent projects for new
contributors!*
-Tipsy data cannot be automatically detected. You can load it with a command
-similar to the following:
-
-.. code-block:: python
-
- ds = TipsyDataset('test.00169',
- parameter_file='test.param',
- endian = '<',
- domain_left_edge = domain_left_edge,
- domain_right_edge = domain_right_edge,
- )
-
-Not all of these arguments are necessary; additionally, yt accepts the
-arguments ``n_ref``, ``over_refine_factor``, ``cosmology_parameters``, and
-``unit_base``. By default, yt will not utilize a parameter file, and by
-default it will assume the data is "big" endian (`>`). Optionally, you may
-specify ``field_dtypes``, which describe the size of various fields. For
-example, if you have stored positions as 64-bit floats, you can specify this
-with:
.. code-block:: python
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -149,6 +149,8 @@
beta_par = generate_beta_par(L)
self.pf.field_info.add_field(("gas","beta_par"), function=beta_par, units="g/cm**3")
+ proj = self.pf.h.proj("density", axis, center=ctr, data_source=source)
+ proj.set_field_parameter("axis", axis)
frb = proj.to_frb(width, nx)
dens = frb["density"]
Te = frb["t_sz"]/dens
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -14,7 +14,6 @@
#-----------------------------------------------------------------------------
import numpy as np
import os.path
-import glob
import stat
import weakref
import cStringIO
@@ -203,14 +202,17 @@
particle header, star files, etc.
"""
base_prefix, base_suffix = filename_pattern['amr']
+ aexpstr = 'a'+file_amr.rsplit('a',1)[1].replace(base_suffix,'')
possibles = glob.glob(os.path.dirname(file_amr)+"/*")
for filetype, (prefix, suffix) in filename_pattern.iteritems():
# if this attribute is already set skip it
if getattr(self, "_file_"+filetype, None) is not None:
continue
- stripped = file_amr.replace(base_prefix, prefix)
- stripped = stripped.replace(base_suffix, suffix)
- match, = difflib.get_close_matches(stripped, possibles, 1, 0.6)
+ match = None
+ for possible in possibles:
+ if possible.endswith(aexpstr+suffix):
+ if os.path.basename(possible).startswith(prefix):
+ match = possible
if match is not None:
mylog.info('discovered %s:%s', filetype, match)
setattr(self, "_file_"+filetype, match)
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d yt/frontends/art/tests/test_outputs.py
--- a/yt/frontends/art/tests/test_outputs.py
+++ b/yt/frontends/art/tests/test_outputs.py
@@ -1,5 +1,5 @@
"""
-ART frontend tests using SFG1 a=0.330
+ART frontend tests using D9p a=0.500
@@ -22,20 +22,22 @@
data_dir_load
from yt.frontends.art.api import ARTDataset
-_fields = ("density", "particle_mass", ("all", "particle_position_x"))
+_fields = ("density", "temperature", "particle_mass", ("all", "particle_position_x"))
-sfg1 = "10MpcBox_csf512_a0.330.d"
+d9p = "D9p_500/10MpcBox_HartGal_csf_a0.500.d"
-
- at requires_pf(sfg1, big_data=True)
-def test_sfg1():
- pf = data_dir_load(sfg1)
- yield assert_equal, str(pf), "10MpcBox_csf512_a0.330.d"
+ at requires_pf(d9p, big_data=True)
+def test_d9p():
+ pf = data_dir_load(d9p)
+ yield assert_equal, str(pf), "10MpcBox_HartGal_csf_a0.500.d"
+ for test in big_patch_amr(d9p, _fields):
+ test_d9p.__name__ = test.description
+ yield test
dso = [None, ("sphere", ("max", (0.1, 'unitary')))]
for field in _fields:
for axis in [0, 1, 2]:
for ds in dso:
for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
- sfg1, axis, field, weight_field,
+ d9p, axis, field, weight_field,
ds)
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -38,7 +38,7 @@
mass_sun_cgs
from yt.utilities.cosmology import Cosmology
from .fields import \
- SPHFieldInfo, OWLSFieldInfo
+ SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo
from .definitions import \
gadget_header_specs, \
gadget_field_specs, \
@@ -356,7 +356,7 @@
class TipsyDataset(ParticleDataset):
_index_class = ParticleIndex
_file_class = TipsyFile
- _field_info_class = SPHFieldInfo
+ _field_info_class = TipsyFieldInfo
_particle_mass_name = "Mass"
_particle_coordinates_name = "Coordinates"
_header_spec = (('time', 'd'),
@@ -368,7 +368,6 @@
('dummy', 'i'))
def __init__(self, filename, dataset_type="tipsy",
- endian=">",
field_dtypes=None,
domain_left_edge=None,
domain_right_edge=None,
@@ -378,7 +377,7 @@
n_ref=64, over_refine_factor=1):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
- self.endian = endian
+ self.endian = self._validate_header(filename)[1]
self.storage_filename = None
if domain_left_edge is None:
domain_left_edge = np.zeros(3, "float64") - 0.5
@@ -515,10 +514,35 @@
density_unit = self.mass_unit / self.length_unit**3
self.time_unit = 1.0 / np.sqrt(G * density_unit)
+ @staticmethod
+ def _validate_header(filename):
+ try:
+ f = open(filename,'rb')
+ except:
+ return False, 1
+ fs = len(f.read())
+ f.seek(0)
+ #Read in the header
+ t, n, ndim, ng, nd, ns = struct.unpack("<diiiii", f.read(28))
+ endianswap = "<"
+ #Check Endianness
+ if (ndim < 1 or ndim > 3):
+ endianswap = ">"
+ f.seek(0)
+ t, n, ndim, ng, nd, ns = struct.unpack(">diiiii", f.read(28))
+ #Catch for 4 byte padding
+ if (fs == 32+48*ng+36*nd+44*ns):
+ f.read(4)
+ #File is borked if this is true
+ elif (fs != 28+48*ng+36*nd+44*ns):
+ f.close()
+ return False, 0
+ f.close()
+ return True, endianswap
+
@classmethod
def _is_valid(self, *args, **kwargs):
- # We do not allow load() of these files.
- return False
+ return TipsyDataset._validate_header(args[0])[0]
class HTTPParticleFile(ParticleFile):
pass
diff -r de5b75b74ca6afe7423c4ddfff5220e3de0b357e -r 14708c1d5e51e39c8418e13f4229ab81b406913d yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -57,6 +57,36 @@
+class TipsyFieldInfo(SPHFieldInfo):
+
+ def __init__(self, pf, field_list, slice_info = None):
+ aux_particle_fields = {
+ 'uDotFB':("uDotFB", ("code_mass * code_velocity**2", ["uDotFB"], None)),
+ 'uDotAV':("uDotAV", ("code_mass * code_velocity**2", ["uDotAV"], None)),
+ 'uDotPdV':("uDotPdV", ("code_mass * code_velocity**2", ["uDotPdV"], None)),
+ 'uDotHydro':("uDotHydro", ("code_mass * code_velocity**2", ["uDotHydro"], None)),
+ 'uDotDiff':("uDotDiff", ("code_mass * code_velocity**2", ["uDotDiff"], None)),
+ 'uDot':("uDot", ("code_mass * code_velocity**2", ["uDot"], None)),
+ 'coolontime':("coolontime", ("code_time", ["coolontime"], None)),
+ 'timeform':("timeform", ("code_time", ["timeform"], None)),
+ 'massform':("massform", ("code_mass", ["massform"], None)),
+ 'HI':("HI", ("dimensionless", ["HI"], None)),
+ 'HII':("HII", ("dimensionless", ["HII"], None)),
+ 'HeI':("HeI", ("dimensionless", ["HeI"], None)),
+ 'HeII':("HeII", ("dimensionless", ["HeII"], None)),
+ 'OxMassFrac':("OxMassFrac", ("dimensionless", ["OxMassFrac"], None)),
+ 'FeMassFrac':("FeMassFrac", ("dimensionless", ["FeMassFrac"], None)),
+ 'c':("c", ("code_velocity", ["c"], None)),
+ 'acc':("acc", ("code_velocity / code_time", ["acc"], None)),
+ 'accg':("accg", ("code_velocity / code_time", ["accg"], None))}
+ for field in field_list:
+ if field[1] in aux_particle_fields.keys() and \
+ aux_particle_fields[field[1]] not in self.known_particle_fields:
+ self.known_particle_fields += (aux_particle_fields[field[1]],)
+ super(TipsyFieldInfo,self).__init__(pf, field_list, slice_info)
+
+
+
class OWLSFieldInfo(SPHFieldInfo):
https://bitbucket.org/yt_analysis/yt/commits/65857bada120/
Changeset: 65857bada120
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 20:16:33
Summary: Merging from experimental again
Affected #: 71 files
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/extensions/notebook_sphinxext.py
--- a/doc/extensions/notebook_sphinxext.py
+++ b/doc/extensions/notebook_sphinxext.py
@@ -1,9 +1,10 @@
-import os, shutil, string, glob
+import os, shutil, string, glob, re
from sphinx.util.compat import Directive
from docutils import nodes
from docutils.parsers.rst import directives
from IPython.nbconvert import html, python
-from runipy.notebook_runner import NotebookRunner
+from IPython.nbformat.current import read, write
+from runipy.notebook_runner import NotebookRunner, NotebookError
class NotebookDirective(Directive):
"""Insert an evaluated notebook into a document
@@ -57,12 +58,8 @@
skip_exceptions = 'skip_exceptions' in self.options
- try:
- evaluated_text = evaluate_notebook(nb_abs_path, dest_path_eval,
- skip_exceptions=skip_exceptions)
- except:
- # bail
- return []
+ evaluated_text = evaluate_notebook(nb_abs_path, dest_path_eval,
+ skip_exceptions=skip_exceptions)
# Create link to notebook and script files
link_rst = "(" + \
@@ -138,11 +135,20 @@
# Create evaluated version and save it to the dest path.
# Always use --pylab so figures appear inline
# perhaps this is questionable?
- nb_runner = NotebookRunner(nb_path, pylab=False)
- nb_runner.run_notebook(skip_exceptions=skip_exceptions)
+ notebook = read(open(nb_path), 'json')
+ nb_runner = NotebookRunner(notebook, pylab=False)
+ try:
+ nb_runner.run_notebook(skip_exceptions=skip_exceptions)
+ except NotebookError as e:
+ print ''
+ print e
+ # Return the traceback, filtering out ANSI color codes.
+ # http://stackoverflow.com/questions/13506033/filtering-out-ansi-escape-sequences
+ return 'Notebook conversion failed with the following traceback: \n%s' % \
+ re.sub(r'\\033[\[\]]([0-9]{1,2}([;@][0-9]{0,2})*)*[mKP]?', '', str(e))
if dest_path is None:
dest_path = 'temp_evaluated.ipynb'
- nb_runner.save_notebook(dest_path)
+ write(nb_runner.nb, open(dest_path, 'w'), 'json')
ret = nb_to_html(dest_path)
if dest_path is 'temp_evaluated.ipynb':
os.remove(dest_path)
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/extensions/notebookcell_sphinxext.py
--- a/doc/extensions/notebookcell_sphinxext.py
+++ b/doc/extensions/notebookcell_sphinxext.py
@@ -35,12 +35,7 @@
skip_exceptions = 'skip_exceptions' in self.options
- try:
- evaluated_text = \
- evaluate_notebook('temp.ipynb', skip_exceptions=skip_exceptions)
- except:
- # bail
- return []
+ evaluated_text = evaluate_notebook('temp.ipynb', skip_exceptions=skip_exceptions)
# create notebook node
attributes = {'format': 'html', 'source': 'nb_path'}
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/analyzing/objects.rst
--- a/doc/source/analyzing/objects.rst
+++ b/doc/source/analyzing/objects.rst
@@ -242,15 +242,15 @@
.. notebook-cell::
from yt.mods import *
- pf = load("enzo_tiny_cosmology/DD0046/DD0046")
- ad = pf.h.all_data()
- total_mass = ad.quantities["TotalQuantity"]("cell_mass")
+ ds = load("enzo_tiny_cosmology/DD0046/DD0046")
+ ad = ds.all_data()
+ total_mass = ad.quantities.total_mass()
# now select only gas with 1e5 K < T < 1e7 K.
new_region = ad.cut_region(['obj["temperature"] > 1e5',
'obj["temperature"] < 1e7'])
- cut_mass = new_region.quantities["TotalQuantity"]("cell_mass")
+ cut_mass = new_region.quantities.total_mass()
print "The fraction of mass in this temperature range is %f." % \
- (cut_mass[0] / total_mass[0])
+ (cut_mass / total_mass)
The ``cut_region`` function generates a new object containing only the cells
that meet all of the specified criteria. The sole argument to ``cut_region``
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/bootcamp/3)_Simple_Visualization.ipynb
--- a/doc/source/bootcamp/3)_Simple_Visualization.ipynb
+++ b/doc/source/bootcamp/3)_Simple_Visualization.ipynb
@@ -243,7 +243,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "s = SlicePlot(pf, \"x\", [\"density\"], center=\"max\")\n",
+ "s = SlicePlot(ds, \"x\", [\"density\"], center=\"max\")\n",
"s.annotate_contour(\"temperature\")\n",
"s.zoom(2.5)"
],
@@ -272,4 +272,4 @@
"metadata": {}
}
]
-}
\ No newline at end of file
+}
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
--- a/doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
+++ b/doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
@@ -68,7 +68,7 @@
"for ds in ts:\n",
" dd = ds.all_data()\n",
" rho_ex.append(dd.quantities.extrema(\"density\"))\n",
- " times.append(pf.current_time.in_units(\"Gyr\"))\n",
+ " times.append(ds.current_time.in_units(\"Gyr\"))\n",
"rho_ex = np.array(rho_ex)"
],
"language": "python",
@@ -211,7 +211,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "pf = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
+ "ds = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
"v, c = ds.find_max(\"density\")\n",
"sl = ds.slice(0, c[0])\n",
"print sl[\"index\", \"x\"], sl[\"index\", \"z\"], sl[\"pdx\"]\n",
@@ -361,4 +361,4 @@
"metadata": {}
}
]
-}
\ No newline at end of file
+}
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/cookbook/embedded_javascript_animation.ipynb
--- a/doc/source/cookbook/embedded_javascript_animation.ipynb
+++ b/doc/source/cookbook/embedded_javascript_animation.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:578ca4fbc3831e9093489f06939abce9cde845b6cf75d901a3c429abc270f550"
+ "signature": "sha256:4f7d409d15ecc538096d15212923312e2cb4a911ebf5a9cf7edc9bd63a8335e9"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -47,7 +47,8 @@
"import matplotlib.pyplot as plt\n",
"from matplotlib.backends.backend_agg import FigureCanvasAgg\n",
"\n",
- "prj = ProjectionPlot(load('Enzo_64/DD0000/data0000'), 0, 'density', weight_field='density',width=(180,'mpccm'))\n",
+ "prj = ProjectionPlot(load('Enzo_64/DD0000/data0000'), 0, 'density', weight_field='density',width=(180,'Mpccm'))\n",
+ "prj.set_figure_size(5)\n",
"prj.set_zlim('density',1e-32,1e-26)\n",
"fig = prj.plots['density'].figure\n",
"fig.canvas = FigureCanvasAgg(fig)\n",
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/cookbook/embedded_webm_animation.ipynb
--- a/doc/source/cookbook/embedded_webm_animation.ipynb
+++ b/doc/source/cookbook/embedded_webm_animation.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:67844f8c2c184fc51aa62440cc05623ee85f252edde6faaa0d7b6617c3f33dfe"
+ "signature": "sha256:0090176ae6299b2310bf613404cbfbb42a54e19a03d1469d1429a01170a63aa0"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -96,7 +96,7 @@
"import matplotlib.pyplot as plt\n",
"from matplotlib.backends.backend_agg import FigureCanvasAgg\n",
"\n",
- "prj = ProjectionPlot(load('Enzo_64/DD0000/data0000'), 0, 'density', weight_field='density',width=(180,'mpccm'))\n",
+ "prj = ProjectionPlot(load('Enzo_64/DD0000/data0000'), 0, 'density', weight_field='density',width=(180,'Mpccm'))\n",
"prj.set_zlim('density',1e-32,1e-26)\n",
"fig = prj.plots['density'].figure\n",
"fig.canvas = FigureCanvasAgg(fig)\n",
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -367,16 +367,11 @@
yt also supports loading Tipsy data. Many of its characteristics are similar
to how Gadget data is loaded; specifically, it shares its definition of
indexing and mesh-identification with that described in
-:ref:`particle-indexing-criteria`. However, unlike Gadget, the Tipsy frontend
-has not yet implemented header specifications, field specifications, or
-particle type specifications. *These are all excellent projects for new
-contributors!*
-
+:ref:`particle-indexing-criteria`.
.. code-block:: python
- ds = TipsyDataset("./halo1e11_run1.00400", endian="<",
- field_dtypes = {"Coordinates": "d"})
+ ds = load("./halo1e11_run1.00400")
.. _specifying-cosmology-tipsy:
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/reference/api/api.rst
--- a/doc/source/reference/api/api.rst
+++ b/doc/source/reference/api/api.rst
@@ -604,13 +604,12 @@
~yt.data_objects.derived_quantities.DerivedQuantity
~yt.data_objects.derived_quantities.DerivedQuantityCollection
- ~yt.data_objects.derived_quantities.WeightedAverage
- ~yt.data_objects.derived_quantities.TotalValue
+ ~yt.data_objects.derived_quantities.WeightedAverageQuantity
+ ~yt.data_objects.derived_quantities.TotalQuantity
~yt.data_objects.derived_quantities.TotalMass
~yt.data_objects.derived_quantities.CenterOfMass
~yt.data_objects.derived_quantities.BulkVelocity
~yt.data_objects.derived_quantities.AngularMomentumVector
- ~yt.data_objects.derived_quantities.ParticleAngularMomentumVector
~yt.data_objects.derived_quantities.Extrema
~yt.data_objects.derived_quantities.MaxLocation
~yt.data_objects.derived_quantities.MinLocation
@@ -719,12 +718,11 @@
~yt.config.YTConfigParser
~yt.utilities.parameter_file_storage.ParameterFileStore
- ~yt.data_objects.data_containers.FakeGridForParticles
~yt.utilities.parallel_tools.parallel_analysis_interface.ObjectIterator
~yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface
~yt.utilities.parallel_tools.parallel_analysis_interface.ParallelObjectIterator
- ~yt.analysis_modules.index_subset.index_subset.ConstructedRootGrid
- ~yt.analysis_modules.index_subset.index_subset.ExtractedHierarchy
+ ~yt.analysis_modules.hierarchy_subset.hierarchy_subset.ConstructedRootGrid
+ ~yt.analysis_modules.hierarchy_subset.hierarchy_subset.ExtractedHierarchy
Testing Infrastructure
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/visualizing/_cb_docstrings.inc
--- a/doc/source/visualizing/_cb_docstrings.inc
+++ b/doc/source/visualizing/_cb_docstrings.inc
@@ -9,9 +9,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'), center='max')
- slc.annotate_arrow((0.53, 0.53, 0.53), 1/pf['kpc'])
+ slc.annotate_arrow((0.5, 0.5, 0.5), (1, 'kpc'))
slc.save()
-------------
@@ -30,7 +30,7 @@
pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
data_source = pf.disk([0.5, 0.5, 0.5], [0., 0., 1.],
- 8./pf.units['kpc'], 1./pf.units['kpc'])
+ (8., 'kpc'), (1., 'kpc'))
c_min = 10**na.floor(na.log10(data_source['density']).min() )
c_max = 10**na.floor(na.log10(data_source['density']).max()+1)
@@ -79,7 +79,7 @@
from yt.mods import *
pf = load("Enzo_64/DD0043/data0043")
s = OffAxisSlicePlot(pf, [1,1,0], ["density"], center="c")
- s.annotate_cquiver('CuttingPlaneVelocityX', 'CuttingPlaneVelocityY', 10)
+ s.annotate_cquiver('cutting_plane_velocity_x', 'cutting_plane_velocity_y', 10)
s.zoom(1.5)
s.save()
@@ -97,7 +97,7 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'), center='max')
slc.annotate_grids()
slc.save()
@@ -153,7 +153,7 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = ProjectionPlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
p.annotate_image_line((0.3, 0.4), (0.8, 0.9), plot_args={'linewidth':5})
p.save()
@@ -169,7 +169,7 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = ProjectionPlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
p.annotate_line([-6, -4, -2, 0, 2, 4, 6], [3.6, 1.6, 0.4, 0, 0.4, 1.6, 3.6], plot_args={'linewidth':5})
p.save()
@@ -212,9 +212,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
s = SlicePlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
- s.annotate_marker([0.53, 0.53, 0.53], plot_args={'s':10000})
+ s.annotate_marker([0.5, 0.5, 0.5], plot_args={'s':10000})
s.save()
-------------
@@ -237,7 +237,7 @@
from yt.mods import *
pf = load("Enzo_64/DD0043/data0043")
p = ProjectionPlot(pf, "x", "density", center='m', width=(10, 'Mpc'))
- p.annotate_particles(10/pf['Mpc'])
+ p.annotate_particles((10, 'Mpc'))
p.save()
-------------
@@ -253,9 +253,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = ProjectionPlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
- p.annotate_point([0.53, 0.526, 0.53], "What's going on here?", text_args={'size':'xx-large', 'color':'w'})
+ p.annotate_point([0.5, 0.496, 0.5], "What's going on here?", text_args={'size':'xx-large', 'color':'w'})
p.save()
-------------
@@ -273,8 +273,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- p = ProjectionPlot(pf, 'z', 'density', center=[0.53, 0.53, 0.53],
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ p = ProjectionPlot(pf, 'z', 'density', center=[0.5, 0.5, 0.5],
weight_field='density', width=(20, 'kpc'))
p.annotate_quiver('velocity_x', 'velocity_y', 16)
p.save()
@@ -292,9 +292,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- p = ProjectionPlot(pf, 'z', 'density', center=[0.53, 0.53, 0.53], width=(20, 'kpc'))
- p.annotate_sphere([0.53, 0.53, 0.53], 2/pf['kpc'], {'fill':True})
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ p = ProjectionPlot(pf, 'z', 'density', center='c', width=(20, 'kpc'))
+ p.annotate_sphere([0.5, 0.5, 0.5], (2, 'kpc'), {'fill':True})
p.save()
-------------
@@ -314,8 +314,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- s = SlicePlot(pf, 'z', 'density', center=[0.53, 0.53, 0.53], width=(20, 'kpc'))
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ s = SlicePlot(pf, 'z', 'density', center='c', width=(20, 'kpc'))
s.annotate_streamlines('velocity_x', 'velocity_y')
s.save()
@@ -333,9 +333,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
s = SlicePlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
- s.annotate_text((0.53, 0.53), 'Sample text', text_args={'size':'xx-large', 'color':'w'})
+ s.annotate_text((0.5, 0.5), 'Sample text', text_args={'size':'xx-large', 'color':'w'})
s.save()
-------------
@@ -349,8 +349,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- p = ProjectionPlot(pf, 'z', 'density', center=[0.53, 0.53, 0.53], width=(20, 'kpc'))
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ p = ProjectionPlot(pf, 'z', 'density', center='c', width=(20, 'kpc'))
p.annotate_title('Density plot')
p.save()
@@ -373,7 +373,7 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = SlicePlot(pf, 'z', 'density', center='m', width=(10, 'kpc'))
p.annotate_velocity()
p.save()
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/visualizing/manual_plotting.rst
--- a/doc/source/visualizing/manual_plotting.rst
+++ b/doc/source/visualizing/manual_plotting.rst
@@ -39,13 +39,13 @@
pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
c = pf.h.find_max('density')[1]
- proj = pf.proj(0, 'density')
+ proj = pf.proj('density', 0)
- width = 10/pf['kpc'] # we want a 1.5 mpc view
+ width = (10, 'kpc') # we want a 1.5 mpc view
res = [1000, 1000] # create an image with 1000x1000 pixels
frb = proj.to_frb(width, res, center=c)
- P.imshow(frb['density'])
+ P.imshow(np.array(frb['density']))
P.savefig('my_perfect_figure.png')
The FRB is a very small object that can be deleted and recreated quickly (in
@@ -76,10 +76,10 @@
ray = pf.ortho_ray(ax, (c[1], c[2])) # cutting through the y0,z0 such that we hit the max density
P.subplot(211)
- P.semilogy(ray['x'], ray['density'])
+ P.semilogy(np.array(ray['x']), np.array(ray['density']))
P.ylabel('density')
P.subplot(212)
- P.semilogy(ray['x'], ray['temperature'])
+ P.semilogy(np.array(ray['x']), np.array(ray['temperature']))
P.xlabel('x')
P.ylabel('temperature')
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -108,13 +108,13 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'density', center=[0.53, 0.53, 0.53], width=(20,'kpc'))
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', center=[0.5, 0.5, 0.5], width=(20,'kpc'))
slc.save()
The above example will display an annotated plot of a slice of the
Density field in a 20 kpc square window centered on the coordinate
-(0.53,0.53) in the x-y plane. The axis to slice along is keyed to the
+(0.5, 0.5, 0.5) in the x-y plane. The axis to slice along is keyed to the
letter 'z', corresponding to the z-axis. Finally, the image is saved to
a png file.
@@ -124,18 +124,19 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z','Pressure', center=[0.53, 0.53, 0.53])
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'pressure', center='c')
slc.save()
slc.zoom(30)
slc.save('zoom')
-will save a slice of the pressure field in a slice along the z
+will save a plot of the pressure field in a slice along the z
axis across the entire simulation domain followed by another plot that
is zoomed in by a factor of 30 with respect to the original
-image. With these sorts of manipulations, one can easily pan and zoom
-onto an interesting region in the simulation and adjust the
-boundaries of the region to visualize on the fly.
+image. Both plots will be centered on the center of the simulation box.
+With these sorts of manipulations, one can easily pan and zoom onto an
+interesting region in the simulation and adjust the boundaries of the
+region to visualize on the fly.
A slice object can also add annotations like a title, an overlying
quiver plot, the location of grid boundaries, halo-finder annotations,
@@ -145,12 +146,12 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.annotate_grids()
slc.save()
-will plot the VorticitySquared in a 10 kiloparsec slice through the
+will plot the density field in a 10 kiloparsec slice through the
z-axis centered on the highest density point in the simulation domain.
Before saving the plot, the script annotates it with the grid
boundaries, which are drawn as thick black lines by default.
@@ -174,9 +175,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- prj = ProjectionPlot(pf, 2, 'density', center=[0.53, 0.53, 0.53],
- width=(25, 'kpc'), weight_field=None)
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ prj = ProjectionPlot(pf, 2, 'density', width=(25, 'kpc'),
+ weight_field=None)
prj.save()
will create a projection of Density field along the x axis, plot it,
@@ -205,11 +206,11 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
L = [1,1,0] # vector normal to cutting plane
north_vector = [-1,1,0]
- cut = OffAxisSlicePlot(pf, L, 'density', width=(25, 'kpc'),
- center=[0.53, 0.53, 0.53], north_vector=north_vector)
+ cut = OffAxisSlicePlot(pf, L, 'density', width=(25, 'kpc'),
+ north_vector=north_vector)
cut.save()
creates an off-axis slice in the plane perpendicular to ``L``,
@@ -246,11 +247,11 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
L = [1,1,0] # vector normal to cutting plane
north_vector = [-1,1,0]
W = [0.02, 0.02, 0.02]
- c = [0.53, 0.53, 0.53]
+ c = [0.5, 0.5, 0.5]
N = 512
image = off_axis_projection(pf, c, L, W, N, "density")
write_image(na.log10(image), "%s_offaxis_projection.png" % pf)
@@ -268,11 +269,10 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
L = [1,1,0] # vector normal to cutting plane
north_vector = [-1,1,0]
prj = OffAxisProjectionPlot(pf,L,'density',width=(25, 'kpc'),
- center=[0.53, 0.53, 0.53],
north_vector=north_vector)
prj.save()
@@ -292,8 +292,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.save()
Panning and zooming
@@ -307,9 +307,10 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
- slc.pan((2/pf['kpc'],2/pf['kpc']))
+ from yt.units import kpc
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
+ slc.pan((2*kpc, 2*kpc))
slc.save()
:class:`~yt.visualization.plot_window.SlicePlot.pan_rel` accepts deltas in units relative
@@ -318,8 +319,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.pan_rel((0.1, -0.1))
slc.save()
@@ -328,8 +329,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.zoom(2)
slc.save()
@@ -342,8 +343,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.set_axes_unit('Mpc')
slc.save()
@@ -356,9 +357,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
- slc.set_center((0.53, 0.53))
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
+ slc.set_center((0.5, 0.5))
slc.save()
Fonts
@@ -369,8 +370,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.set_font({'family': 'sans-serif', 'style': 'italic','weight': 'bold', 'size': 24})
slc.save()
@@ -388,9 +389,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
- slc.set_cmap('VorticitySquared', 'RdBu_r')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
+ slc.set_cmap('density', 'RdBu_r')
slc.save()
The :class:`~yt.visualization.plot_window.SlicePlot.set_log` function accepts a field name
@@ -400,9 +401,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
- slc.set_log('VorticitySquared', False)
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
+ slc.set_log('density', False)
slc.save()
Lastly, the :class:`~yt.visualization.plot_window.SlicePlot.set_zlim` function makes it
@@ -411,9 +412,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
- slc.set_zlim('VorticitySquared', 1e-30, 1e-25)
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
+ slc.set_zlim('density', 1e-30, 1e-25)
slc.save()
Set the size of the plot
@@ -427,8 +428,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.set_window_size(10)
slc.save()
@@ -438,8 +439,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- slc = SlicePlot(pf, 'z', 'VorticitySquared', width=(10,'kpc'), center='max')
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ slc = SlicePlot(pf, 'z', 'density', width=(10,'kpc'))
slc.set_buff_size(1600)
slc.save()
@@ -464,8 +465,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- my_galaxy = pf.disk([0.53, 0.53, 0.53], [0.0, 0.0, 1.0], 0.01, 0.003)
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ my_galaxy = pf.disk([0.5, 0.5, 0.5], [0.0, 0.0, 1.0], 0.01, 0.003)
plot = ProfilePlot(my_galaxy, "density", ["temperature"])
plot.save()
@@ -483,8 +484,8 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
- my_sphere = pf.sphere([0.53, 0.53, 0.53], (100, "pc"))
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ my_sphere = pf.sphere([0.5, 0.5, 0.5], (100, "kpc"))
plot = ProfilePlot(my_sphere, "temperature", ["cell_mass"],
weight_field=None)
plot.save()
@@ -589,7 +590,7 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
my_sphere = pf.sphere("c", (50, "kpc"))
plot = PhasePlot(my_sphere, "density", "temperature", ["cell_mass"],
weight_field=None)
@@ -602,9 +603,9 @@
.. python-script::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
my_sphere = pf.sphere("c", (50, "kpc"))
- plot = PhasePlot(my_sphere, "density", "temperature", ["HI_Fraction"],
+ plot = PhasePlot(my_sphere, "density", "temperature", ["H_fraction"],
weight_field="cell_mass")
plot.save()
@@ -646,7 +647,7 @@
.. notebook-cell::
from yt.mods import *
- pf = load("HiresIsolatedGalaxy/DD0044/DD0044")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = ProjectionPlot(pf, "x", "density", center='m', width=(10,'kpc'),
weight_field='density')
p.show()
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -142,8 +142,7 @@
:class:`~yt.visualization.volume_rendering.camera.Camera`, which represents a
viewpoint into a volume. The camera optionally accepts a volume, which can be
either an instance of
-:class:`~yt.visualization.volume_rendering.grid_partitioner.HomogenizedVolume`
-or an instance of :class:`~yt.utilities.amr_kdtree.amr_kdtree.AMRKDTree` that
+:class:`~yt.utilities.amr_kdtree.amr_kdtree.AMRKDTree` that
has already been initialized. If one is not supplied, the camera will generate
one itself. This can also be specified if you wish to save bricks between
repeated calls, thus saving considerable amounts of time.
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -74,25 +74,87 @@
__version__ = "3.0-dev"
-def run_nose(verbose=False, run_answer_tests=False, answer_big_data=False):
- import nose, os, sys
- from yt.config import ytcfg
- nose_argv = sys.argv
- nose_argv += ['--exclude=answer_testing','--detailed-errors']
- if verbose:
- nose_argv.append('-v')
- if run_answer_tests:
- nose_argv.append('--with-answer-testing')
- if answer_big_data:
- nose_argv.append('--answer-big-data')
- log_suppress = ytcfg.getboolean("yt","suppressStreamLogging")
- ytcfg.set("yt","suppressStreamLogging", 'True')
- initial_dir = os.getcwd()
- yt_file = os.path.abspath(__file__)
- yt_dir = os.path.dirname(yt_file)
- os.chdir(yt_dir)
- try:
- nose.run(argv=nose_argv)
- finally:
- os.chdir(initial_dir)
- ytcfg.set("yt","suppressStreamLogging", str(log_suppress))
+# First module imports
+import numpy as np # For modern purposes
+import numpy # In case anyone wishes to use it by name
+
+from yt.funcs import \
+ iterable, \
+ get_memory_usage, \
+ print_tb, \
+ rootonly, \
+ insert_ipython, \
+ get_pbar, \
+ only_on_root, \
+ is_root, \
+ get_version_stack, \
+ get_yt_supp, \
+ get_yt_version, \
+ parallel_profile, \
+ enable_plugins, \
+ memory_checker, \
+ deprecated_class
+from yt.utilities.logger import ytLogger as mylog
+
+import yt.utilities.physical_constants as physical_constants
+import yt.units as units
+from yt.units.yt_array import YTArray, YTQuantity
+
+from yt.fields.api import \
+ field_plugins, \
+ DerivedField, \
+ FieldDetector, \
+ FieldInfoContainer, \
+ ValidateParameter, \
+ ValidateDataField, \
+ ValidateProperty, \
+ ValidateSpatial, \
+ ValidateGridType, \
+ add_field, \
+ derived_field
+
+from yt.data_objects.api import \
+ BinnedProfile1D, BinnedProfile2D, BinnedProfile3D, \
+ DatasetSeries, \
+ ImageArray, particle_filter, create_profile, \
+ Profile1D, Profile2D, Profile3D
+
+# For backwards compatibility
+TimeSeriesData = deprecated_class(DatasetSeries)
+
+from yt.frontends.api import _frontend_container
+frontends = _frontend_container()
+
+from yt.frontends.stream.api import \
+ load_uniform_grid, load_amr_grids, \
+ load_particles, load_hexahedral_mesh, load_octree
+
+# For backwards compatibility
+GadgetDataset = frontends.sph.GadgetDataset
+GadgetStaticOutput = deprecated_class(GadgetDataset)
+TipsyDataset = frontends.sph.TipsyDataset
+TipsyStaticOutput = deprecated_class(TipsyDataset)
+
+# Now individual component imports from the visualization API
+from yt.visualization.api import \
+ PlotCollection, PlotCollectionInteractive, \
+ get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
+ write_bitmap, write_image, \
+ apply_colormap, scale_image, write_projection, \
+ SlicePlot, AxisAlignedSlicePlot, OffAxisSlicePlot, \
+ ProjectionPlot, OffAxisProjectionPlot, \
+ show_colormaps, ProfilePlot, PhasePlot
+
+from yt.visualization.volume_rendering.api import \
+ off_axis_projection
+
+from yt.utilities.parallel_tools.parallel_analysis_interface import \
+ parallel_objects, enable_parallelism
+
+from yt.convenience import \
+ load, simulation
+
+# Import some helpful math utilities
+from yt.utilities.math_utils import \
+ ortho_find, quartiles, periodic_position
+
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/api.py
--- a/yt/analysis_modules/api.py
+++ b/yt/analysis_modules/api.py
@@ -63,14 +63,13 @@
HaloProfiler, \
FakeProfile
-from .index_subset.api import \
+from .hierarchy_subset.api import \
ConstructedRootGrid, \
AMRExtractedGridProxy, \
ExtractedHierarchy, \
ExtractedParameterFile
from .level_sets.api import \
- coalesce_join_tree, \
identify_contours, \
Clump, \
find_clumps, \
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
@@ -26,7 +26,6 @@
from yt.utilities.cosmology import \
Cosmology
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- only_on_root, \
parallel_objects, \
parallel_root_only
from yt.visualization.image_writer import \
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
--- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
+++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py
@@ -25,7 +25,6 @@
HaloProfiler
from yt.convenience import load
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- only_on_root, \
parallel_objects, \
parallel_root_only
from yt.utilities.physical_constants import \
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/halo_mass_function/halo_mass_function.py
--- a/yt/analysis_modules/halo_mass_function/halo_mass_function.py
+++ b/yt/analysis_modules/halo_mass_function/halo_mass_function.py
@@ -23,9 +23,9 @@
parallel_blocking_call
from yt.utilities.physical_constants import \
cm_per_mpc, \
- mass_sun_cgs, \
- rho_crit_now
-
+ mass_sun_cgs
+from yt.utilities.physical_ratios import \
+ rho_crit_g_cm3_h2
class HaloMassFcn(ParallelAnalysisInterface):
"""
@@ -256,7 +256,7 @@
# rho0 in units of h^2 Msolar/Mpc^3
rho0 = self.omega_matter0 * \
- rho_crit_now * cm_per_mpc**3 / mass_sun_cgs
+ rho_crit_g_cm3_h2 * cm_per_mpc**3 / mass_sun_cgs
# spacing in mass of our sigma calculation
dm = (float(self.log_mass_max) - self.log_mass_min)/self.num_sigma_bins;
@@ -293,7 +293,7 @@
# constants - set these before calling any functions!
# rho0 in units of h^2 Msolar/Mpc^3
rho0 = self.omega_matter0 * \
- rho_crit_now * cm_per_mpc**3 / mass_sun_cgs
+ rho_crit_g_cm3_h2 * cm_per_mpc**3 / mass_sun_cgs
self.delta_c0 = 1.69; # critical density for turnaround (Press-Schechter)
nofmz_cum = 0.0; # keep track of cumulative number density
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/halo_profiler/multi_halo_profiler.py
--- a/yt/analysis_modules/halo_profiler/multi_halo_profiler.py
+++ b/yt/analysis_modules/halo_profiler/multi_halo_profiler.py
@@ -44,8 +44,9 @@
parallel_root_only, \
parallel_objects
from yt.utilities.physical_constants import \
- mass_sun_cgs, \
- rho_crit_now
+ mass_sun_cgs
+from yt.utilities.physical_ratios import \
+ rho_crit_g_cm3_h2
from yt.visualization.fixed_resolution import \
FixedResolutionBuffer
from yt.visualization.image_writer import write_image
@@ -932,7 +933,7 @@
if 'ActualOverdensity' in profile.keys():
return
- rhocritnow = rho_crit_now * self.pf.hubble_constant**2 # g cm^-3
+ rhocritnow = rho_crit_g_cm3_h2 * self.pf.hubble_constant**2 # g cm^-3
rho_crit = rhocritnow * ((1.0 + self.pf.current_redshift)**3.0)
if not self.use_critical_density: rho_crit *= self.pf.omega_matter
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/hierarchy_subset/api.py
--- a/yt/analysis_modules/hierarchy_subset/api.py
+++ b/yt/analysis_modules/hierarchy_subset/api.py
@@ -1,5 +1,5 @@
"""
-API for index_subset
+API for hierarchy_subset
@@ -13,7 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from .index_subset import \
+from .hierarchy_subset import \
ConstructedRootGrid, \
AMRExtractedGridProxy, \
ExtractedHierarchy, \
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/hierarchy_subset/setup.py
--- a/yt/analysis_modules/hierarchy_subset/setup.py
+++ b/yt/analysis_modules/hierarchy_subset/setup.py
@@ -7,7 +7,7 @@
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
- config = Configuration('index_subset', parent_package, top_path)
+ config = Configuration('hierarchy_subset', parent_package, top_path)
config.make_config_py() # installs __config__.py
#config.make_svn_version_py()
return config
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -33,11 +33,9 @@
from yt import units
from yt.units.yt_array import YTQuantity
import h5py
-try:
- import astropy.io.fits as pyfits
- import astropy.wcs as pywcs
-except ImportError:
- pass
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+pywcs = ap.pywcs
comm = communication_system.communicators[-1]
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -17,13 +17,14 @@
from yt import units
import h5py
try:
- import astropy.io.fits as pyfits
import xspec
from scipy.integrate import cumtrapz
from scipy import stats
except ImportError:
pass
-
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+
from yt.utilities.physical_constants import hcgs, clight, erg_per_keV, amu_cgs
hc = (hcgs*clight).in_units("keV*angstrom")
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -216,7 +216,7 @@
"""
_key_fields = YTSelectionContainer2D._key_fields + ['weight_field']
_type_name = "proj"
- _con_args = ('axis', 'weight_field')
+ _con_args = ('axis', 'field', 'weight_field')
_container_fields = ('px', 'py', 'pdx', 'pdy', 'weight_field')
def __init__(self, field, axis, weight_field = None,
center = None, pf = None, data_source=None,
@@ -241,6 +241,10 @@
return self.data_source.blocks
@property
+ def field(self):
+ return [k for k in self.field_data.keys() if k not in self._container_fields]
+
+ @property
def _mrep(self):
return MinimalProjectionData(self)
@@ -269,12 +273,12 @@
chunk_fields.append(self.weight_field)
tree = self._get_tree(len(fields))
# We do this once
- for chunk in self.data_source.chunks([], "io"):
+ for chunk in self.data_source.chunks([], "io", local_only = False):
self._initialize_chunk(chunk, tree)
# This needs to be parallel_objects-ified
with self.data_source._field_parameter_state(self.field_parameters):
for chunk in parallel_objects(self.data_source.chunks(
- chunk_fields, "io")):
+ chunk_fields, "io", local_only = True)):
mylog.debug("Adding chunk (%s) to tree (%0.3e GB RAM)", chunk.ires.size,
get_memory_usage()/1024.)
self._handle_chunk(chunk, fields, tree)
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -802,6 +802,8 @@
if center is None:
center = (self.pf.domain_right_edge
+ self.pf.domain_left_edge)/2.0
+ elif iterable(center) and not isinstance(center, YTArray):
+ center = self.pf.arr(center, 'code_length')
if iterable(width):
w, u = width
width = self.pf.arr(w, input_units = u)
@@ -1262,8 +1264,7 @@
def _get_cut_mask(self, grid, field=None):
if self._is_fully_enclosed(grid):
return True # We do not want child masking here
- if not isinstance(grid, (FakeGridForParticles,)) \
- and grid.id in self._cut_masks:
+ if grid.id in self._cut_masks:
return self._cut_masks[grid.id]
# If we get this far, we have to generate the cut_mask.
return self._get_level_mask(self.regions, grid)
@@ -1320,6 +1321,5 @@
this_cut_mask)
if item == "OR":
np.bitwise_or(this_cut_mask, level_masks[i+1], this_cut_mask)
- if not isinstance(grid, FakeGridForParticles):
- self._cut_masks[grid.id] = this_cut_mask
+ self._cut_masks[grid.id] = this_cut_mask
return this_cut_mask
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/data_objects/derived_quantities.py
--- a/yt/data_objects/derived_quantities.py
+++ b/yt/data_objects/derived_quantities.py
@@ -185,6 +185,7 @@
"""
def __call__(self):
+ self.data_source.pf.index
fi = self.data_source.pf.field_info
fields = []
if ("gas", "cell_mass") in fi:
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/data_objects/profiles.py
--- a/yt/data_objects/profiles.py
+++ b/yt/data_objects/profiles.py
@@ -759,6 +759,7 @@
self.field_data = YTFieldData()
self.weight_field = weight_field
self.field_units = {}
+ ParallelAnalysisInterface.__init__(self, comm=data_source.comm)
def add_fields(self, fields):
fields = ensure_list(fields)
@@ -792,7 +793,9 @@
def _finalize_storage(self, fields, temp_storage):
# We use our main comm here
# This also will fill _field_data
- # FIXME: Add parallelism and combining std stuff
+ temp_storage.values = self.comm.mpi_allreduce(temp_storage.values, op="sum", dtype="float64")
+ temp_storage.weight_values = self.comm.mpi_allreduce(temp_storage.weight_values, op="sum", dtype="float64")
+ temp_storage.used = self.comm.mpi_allreduce(temp_storage.used, op="sum", dtype="bool")
blank = ~temp_storage.used
self.used = temp_storage.used
if self.weight_field is not None:
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -186,8 +186,12 @@
self._setup_classes()
def _set_derived_attrs(self):
- self.domain_center = 0.5 * (self.domain_right_edge + self.domain_left_edge)
- self.domain_width = self.domain_right_edge - self.domain_left_edge
+ if self.domain_left_edge is None or self.domain_right_edge is None:
+ self.domain_center = np.zeros(3)
+ self.domain_width = np.zeros(3)
+ else:
+ self.domain_center = 0.5 * (self.domain_right_edge + self.domain_left_edge)
+ self.domain_width = self.domain_right_edge - self.domain_left_edge
if not isinstance(self.current_time, YTQuantity):
self.current_time = self.quan(self.current_time, "code_time")
# need to do this if current_time was set before units were set
@@ -279,7 +283,10 @@
self, dataset_type=self.dataset_type)
# Now we do things that we need an instantiated index for
# ...first off, we create our field_info now.
+ oldsettings = np.geterr()
+ np.seterr(all='ignore')
self.create_field_info()
+ np.seterr(**oldsettings)
return self._instantiated_index
_index_proxy = None
@@ -361,11 +368,16 @@
# No string lookups here, we need an actual union.
f = self.particle_fields_by_type
fields = set_intersection([f[s] for s in union
- if s in self.particle_types_raw])
+ if s in self.particle_types_raw
+ and len(f[s]) > 0])
for field in fields:
units = set([])
for s in union:
- units.add(self.field_units.get((s, field), ""))
+ # First we check our existing fields for units
+ funits = self._get_field_info(s, field).units
+ # Then we override with field_units settings.
+ funits = self.field_units.get((s, field), funits)
+ units.add(funits)
if len(units) == 1:
self.field_units[union.name, field] = list(units)[0]
self.particle_types += (union.name,)
@@ -608,7 +620,10 @@
self.length_unit / self.time_unit)
self.unit_registry.modify("code_velocity", vel_unit)
# domain_width does not yet exist
- DW = self.arr(self.domain_right_edge - self.domain_left_edge, "code_length")
+ if self.domain_left_edge is None or self.domain_right_edge is None:
+ DW = np.zeros(3)
+ else:
+ DW = self.arr(self.domain_right_edge - self.domain_left_edge, "code_length")
self.unit_registry.modify("unitary", DW.max())
_arr = None
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/fields/field_detector.py
--- a/yt/fields/field_detector.py
+++ b/yt/fields/field_detector.py
@@ -188,6 +188,8 @@
return rv
elif param == "fof_groups":
return None
+ elif param == "mu":
+ return 1.0
else:
return 0.0
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -66,8 +66,9 @@
def setup_fluid_fields(self):
pass
- def setup_particle_fields(self, ptype):
+ def setup_particle_fields(self, ptype, ftype='gas', num_neighbors=64 ):
for f, (units, aliases, dn) in sorted(self.known_particle_fields):
+ units = self.pf.field_units.get((ptype, f), units)
self.add_output_field((ptype, f),
units = units, particle_type = True, display_name = dn)
if (ptype, f) not in self.field_list:
@@ -99,7 +100,9 @@
self.add_output_field(field,
units = self.pf.field_units.get(field, ""),
particle_type = True)
- self.setup_smoothed_fields(ptype)
+ self.setup_smoothed_fields(ptype,
+ num_neighbors=num_neighbors,
+ ftype=ftype)
def setup_smoothed_fields(self, ptype, num_neighbors = 64, ftype = "gas"):
# We can in principle compute this, but it is not yet implemented.
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/fields/fluid_vector_fields.py
--- a/yt/fields/fluid_vector_fields.py
+++ b/yt/fields/fluid_vector_fields.py
@@ -28,8 +28,9 @@
just_one
from .vector_operations import \
- create_magnitude_field
-
+ create_magnitude_field, \
+ create_squared_field
+
@register_field_plugin
def setup_fluid_vector_fields(registry, ftype = "gas", slice_info = None):
# slice_info would be the left, the right, and the factor.
@@ -126,6 +127,9 @@
create_magnitude_field(registry, "vorticity", "1/s",
ftype=ftype, slice_info=slice_info,
validators=vort_validators)
+ create_squared_field(registry, "vorticity", "1/s**2",
+ ftype=ftype, slice_info=slice_info,
+ validators=vort_validators)
def _vorticity_stretching_x(field, data):
return data[ftype, "velocity_divergence"] * data[ftype, "vorticity_x"]
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/fields/species_fields.py
--- a/yt/fields/species_fields.py
+++ b/yt/fields/species_fields.py
@@ -59,34 +59,46 @@
* data[ftype,'density']
return _density
-def add_species_field_by_density(registry, ftype, species):
+def add_species_field_by_density(registry, ftype, species,
+ particle_type = False):
"""
This takes a field registry, a fluid type, and a species name and then
adds the other fluids based on that. This assumes that the field
"SPECIES_density" already exists and refers to mass density.
"""
registry.add_field((ftype, "%s_fraction" % species),
- function = _create_fraction_func(ftype, species),
- units = "")
+ function = _create_fraction_func(ftype, species),
+ particle_type = particle_type,
+ units = "")
+
registry.add_field((ftype, "%s_mass" % species),
- function = _create_mass_func(ftype, species),
- units = "g")
+ function = _create_mass_func(ftype, species),
+ particle_type = particle_type,
+ units = "g")
+
registry.add_field((ftype, "%s_number_density" % species),
- function = _create_number_density_func(ftype, species),
- units = "cm**-3")
+ function = _create_number_density_func(ftype, species),
+ particle_type = particle_type,
+ units = "cm**-3")
-def add_species_field_by_fraction(registry, ftype, species):
+def add_species_field_by_fraction(registry, ftype, species,
+ particle_type = False):
"""
This takes a field registry, a fluid type, and a species name and then
adds the other fluids based on that. This assumes that the field
"SPECIES_fraction" already exists and refers to mass fraction.
"""
registry.add_field((ftype, "%s_density" % species),
- function = _create_density_func(ftype, species),
- units = "g/cm**3")
+ function = _create_density_func(ftype, species),
+ particle_type = particle_type,
+ units = "g/cm**3")
+
registry.add_field((ftype, "%s_mass" % species),
- function = _create_mass_func(ftype, species),
- units = "g")
+ function = _create_mass_func(ftype, species),
+ particle_type = particle_type,
+ units = "g")
+
registry.add_field((ftype, "%s_number_density" % species),
- function = _create_number_density_func(ftype, species),
- units = "cm**-3")
+ function = _create_number_density_func(ftype, species),
+ particle_type = particle_type,
+ units = "cm**-3")
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/fields/vector_operations.py
--- a/yt/fields/vector_operations.py
+++ b/yt/fields/vector_operations.py
@@ -61,6 +61,28 @@
function = _magnitude, units = field_units,
validators = validators, particle_type = particle_type)
+def create_squared_field(registry, basename, field_units,
+ ftype = "gas", slice_info = None,
+ validators = None, particle_type=False):
+
+ xn, yn, zn = [(ftype, "%s_%s" % (basename, ax)) for ax in 'xyz']
+
+ # Is this safe?
+ if registry.pf.dimensionality < 3:
+ zn = ("index", "zeros")
+ if registry.pf.dimensionality < 2:
+ yn = ("index", "zeros")
+
+ def _squared(field, data):
+ squared = data[xn] * data[xn]
+ squared += data[yn] * data[yn]
+ squared += data[zn] * data[zn]
+ return squared
+
+ registry.add_field((ftype, "%s_squared" % basename),
+ function = _squared, units = field_units,
+ validators = validators, particle_type = particle_type)
+
def create_vector_fields(registry, basename, field_units,
ftype = "gas", slice_info = None):
# slice_info would be the left, the right, and the factor.
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/api.py
--- a/yt/frontends/api.py
+++ b/yt/frontends/api.py
@@ -12,3 +12,29 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+
+import sys, types, os, glob, cPickle, time, importlib
+
+_frontends = [
+ 'art',
+ 'artio',
+ 'athena',
+ 'boxlib',
+ 'chombo',
+ 'enzo',
+ 'fits',
+ 'flash',
+ 'gdf',
+ 'halo_catalogs',
+ 'moab',
+ #'pluto',
+ 'ramses',
+ 'sph',
+ 'stream',
+]
+
+class _frontend_container:
+ def __init__(self):
+ for frontend in _frontends:
+ _mod = "yt.frontends.%s.api" % frontend
+ setattr(self, frontend, importlib.import_module(_mod))
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -152,7 +152,7 @@
g = og
yield YTDataChunk(dobj, "spatial", [g], None)
- def _chunk_io(self, dobj, cache = True):
+ def _chunk_io(self, dobj, cache = True, local_only = False):
"""
Since subsets are calculated per domain,
i.e. per file, yield each domain at a time to
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/artio/data_structures.py
--- a/yt/frontends/artio/data_structures.py
+++ b/yt/frontends/artio/data_structures.py
@@ -286,7 +286,7 @@
g = og
yield YTDataChunk(dobj, "spatial", [g], None, cache = True)
- def _chunk_io(self, dobj, cache = True):
+ def _chunk_io(self, dobj, cache = True, local_only = False):
# _current_chunk is made from identify_base_chunk
oobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
for chunk in oobjs:
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -90,8 +90,7 @@
def _setup_dx(self):
# has already been read in and stored in index
- my_ind = self.id - self._id_offset
- self.dds = self.index.level_dds[self.Level,:]
+ self.dds = self.index.pf.arr(self.index.level_dds[self.Level, :], 'code_length')
self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = self.dds
def __repr__(self):
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -32,6 +32,8 @@
AMRGridPatch
from yt.geometry.grid_geometry_handler import \
GridIndex
+from yt.geometry.geometry_handler import \
+ YTDataChunk
from yt.data_objects.static_output import \
Dataset
from yt.fields.field_info_container import \
@@ -532,7 +534,7 @@
self.dataset_type = dataset_type
self.float_type = 'float64'
self.parameter_file = weakref.proxy(pf) # for _obtain_enzo
- self.float_type = self.enzo.index_information["GridLeftEdge"].dtype
+ self.float_type = self.enzo.hierarchy_information["GridLeftEdge"].dtype
self.directory = os.getcwd()
GridIndex.__init__(self, pf, dataset_type)
@@ -540,12 +542,12 @@
pass
def _count_grids(self):
- self.num_grids = self.enzo.index_information["GridDimensions"].shape[0]
+ self.num_grids = self.enzo.hierarchy_information["GridDimensions"].shape[0]
def _parse_index(self):
self._copy_index_structure()
mylog.debug("Copying reverse tree")
- reverse_tree = self.enzo.index_information["GridParentIDs"].ravel().tolist()
+ reverse_tree = self.enzo.hierarchy_information["GridParentIDs"].ravel().tolist()
# Initial setup:
mylog.debug("Reconstructing parent-child relationships")
grids = []
@@ -562,7 +564,7 @@
self.grids = np.empty(len(grids), dtype='object')
for i, grid in enumerate(grids):
if (i%1e4) == 0: mylog.debug("Prepared % 7i / % 7i grids", i, self.num_grids)
- grid.filename = None
+ grid.filename = "Inline_processor_%07i" % (self.grid_procs[i,0])
grid._prepare_grid()
grid.proc_num = self.grid_procs[i,0]
self.grids[i] = grid
@@ -574,14 +576,14 @@
def _copy_index_structure(self):
# Dimensions are important!
- self.grid_dimensions[:] = self.enzo.index_information["GridEndIndices"][:]
- self.grid_dimensions -= self.enzo.index_information["GridStartIndices"][:]
+ self.grid_dimensions[:] = self.enzo.hierarchy_information["GridEndIndices"][:]
+ self.grid_dimensions -= self.enzo.hierarchy_information["GridStartIndices"][:]
self.grid_dimensions += 1
- self.grid_left_edge[:] = self.enzo.index_information["GridLeftEdge"][:]
- self.grid_right_edge[:] = self.enzo.index_information["GridRightEdge"][:]
- self.grid_levels[:] = self.enzo.index_information["GridLevels"][:]
- self.grid_procs = self.enzo.index_information["GridProcs"].copy()
- self.grid_particle_count[:] = self.enzo.index_information["GridNumberOfParticles"][:]
+ self.grid_left_edge[:] = self.enzo.hierarchy_information["GridLeftEdge"][:]
+ self.grid_right_edge[:] = self.enzo.hierarchy_information["GridRightEdge"][:]
+ self.grid_levels[:] = self.enzo.hierarchy_information["GridLevels"][:]
+ self.grid_procs = self.enzo.hierarchy_information["GridProcs"].copy()
+ self.grid_particle_count[:] = self.enzo.hierarchy_information["GridNumberOfParticles"][:]
def save_data(self, *args, **kwargs):
pass
@@ -600,6 +602,20 @@
random_sample = np.mgrid[0:max(len(my_grids)-1,1)].astype("int32")
return my_grids[(random_sample,)]
+ def _chunk_io(self, dobj, cache = True, local_only = False):
+ gfiles = defaultdict(list)
+ gobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
+ for g in gobjs:
+ gfiles[g.filename].append(g)
+ for fn in sorted(gfiles):
+ if local_only:
+ gobjs = [g for g in gfiles[fn] if g.proc_num == self.comm.rank]
+ gfiles[fn] = gobjs
+ gs = gfiles[fn]
+ count = self._count_selection(dobj, gs)
+ yield YTDataChunk(dobj, "io", gs, count, cache = cache)
+
+
class EnzoHierarchy1D(EnzoHierarchy):
def _fill_arrays(self, ei, si, LE, RE, npart, nap):
@@ -829,12 +845,11 @@
else:
if "LengthUnits" in self.parameters:
length_unit = self.parameters["LengthUnits"]
- mass_unit = self.parameters["MassUnits"]
+ mass_unit = self.parameters["DensityUnits"] * length_unit**3
time_unit = self.parameters["TimeUnits"]
else:
mylog.warning("Setting 1.0 in code units to be 1.0 cm")
mylog.warning("Setting 1.0 in code units to be 1.0 s")
- mylog.warning("Setting 1.0 in code units to be 1.0 g")
length_unit = mass_unit = time_unit = 1.0
self.length_unit = self.quan(length_unit, "cm")
@@ -899,6 +914,7 @@
return obj
def __init__(self, parameter_override=None, conversion_override=None):
+ self.fluid_types += ("enzo",)
if parameter_override is None: parameter_override = {}
self._parameter_override = parameter_override
if conversion_override is None: conversion_override = {}
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/enzo/io.py
--- a/yt/frontends/enzo/io.py
+++ b/yt/frontends/enzo/io.py
@@ -233,37 +233,8 @@
slice(ghost_zones,-ghost_zones))
BaseIOHandler.__init__(self, pf)
- def _read_data_set(self, grid, field):
- if grid.id not in self.grids_in_memory:
- mylog.error("Was asked for %s but I have %s", grid.id, self.grids_in_memory.keys())
- raise KeyError
- tr = self.grids_in_memory[grid.id][field]
- # If it's particles, we copy.
- if len(tr.shape) == 1: return tr.copy()
- # New in-place unit conversion breaks if we don't copy first
- return tr.swapaxes(0,2)[self.my_slice].copy()
- # We don't do this, because we currently do not interpolate
- coef1 = max((grid.Time - t1)/(grid.Time - t2), 0.0)
- coef2 = 1.0 - coef1
- t1 = enzo.yt_parameter_file["InitialTime"]
- t2 = enzo.index_information["GridOldTimes"][grid.id]
- return (coef1*self.grids_in_memory[grid.id][field] + \
- coef2*self.old_grids_in_memory[grid.id][field])\
- [self.my_slice]
-
- def modify(self, field):
- return field.swapaxes(0,2)
-
def _read_field_names(self, grid):
- return self.grids_in_memory[grid.id].keys()
-
- def _read_data_slice(self, grid, field, axis, coord):
- sl = [slice(3,-3), slice(3,-3), slice(3,-3)]
- sl[axis] = slice(coord + 3, coord + 4)
- sl = tuple(reversed(sl))
- tr = self.grids_in_memory[grid.id][field][sl].swapaxes(0,2)
- # In-place unit conversion requires we return a copy
- return tr.copy()
+ return [("enzo", field) for field in self.grids_in_memory[grid.id].keys()]
def _read_fluid_selection(self, chunks, selector, fields, size):
rv = {}
@@ -279,7 +250,6 @@
if size is None:
size = sum((g.count(selector) for chunk in chunks
for g in chunk.objs))
-
for field in fields:
ftype, fname = field
fsize = size
@@ -291,14 +261,14 @@
ind = 0
for chunk in chunks:
for g in chunk.objs:
- if g.id not in self.grids_in_memory: continue
-
- data = np.empty(g.ActiveDimensions[::-1], dtype="float64")
- data_view = data.swapaxes(0,2)
+ # We want a *hard error* here.
+ #if g.id not in self.grids_in_memory: continue
for field in fields:
ftype, fname = field
- data_view = self.grids_in_memory[g.id][fname]
+ data_view = self.grids_in_memory[g.id][fname][self.my_slice].swapaxes(0,2)
nd = g.select(selector, data_view, rv[field], ind)
+ ind += nd
+ assert(ind == fsize)
return rv
def _read_particle_coords(self, chunks, ptf):
@@ -333,10 +303,6 @@
data = data * g.dds.prod(dtype="f8")
yield (ptype, field), data[mask]
- @property
- def _read_exception(self):
- return KeyError
-
class IOHandlerPacked2D(IOHandlerPackedHDF5):
_dataset_type = "enzo_packed_2d"
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -10,15 +10,11 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-try:
- import astropy.io.fits as pyfits
- import astropy.wcs as pywcs
-except ImportError:
- pass
-
import stat
+import types
import numpy as np
import weakref
+import warnings
from yt.config import ytcfg
from yt.funcs import *
@@ -38,6 +34,46 @@
from yt.utilities.decompose import \
decompose_array, get_psize
+class astropy_imports:
+ _pyfits = None
+ @property
+ def pyfits(self):
+ if self._pyfits is None:
+ try:
+ import astropy.io.fits as pyfits
+ self.log
+ except ImportError:
+ pyfits = None
+ self._pyfits = pyfits
+ return self._pyfits
+
+ _pywcs = None
+ @property
+ def pywcs(self):
+ if self._pywcs is None:
+ try:
+ import astropy.wcs as pywcs
+ self.log
+ except ImportError:
+ pywcs = None
+ self._pywcs = pywcs
+ return self._pywcs
+
+ _log = None
+ @property
+ def log(self):
+ if self._log is None:
+ try:
+ from astropy import log
+ if log.exception_logging_enabled():
+ log.disable_exception_logging()
+ except ImportError:
+ log = None
+ self._log = log
+ return self._log
+
+ap = astropy_imports()
+
angle_units = ["deg","arcsec","arcmin","mas"]
all_units = angle_units + mpc_conversion.keys()
@@ -52,11 +88,11 @@
def __repr__(self):
return "FITSGrid_%04i (%s)" % (self.id, self.ActiveDimensions)
-
+
class FITSHierarchy(GridIndex):
grid = FITSGrid
-
+
def __init__(self,pf,dataset_type='fits'):
self.dataset_type = dataset_type
self.field_indexes = {}
@@ -76,10 +112,10 @@
for h in self._handle[self.parameter_file.first_image:]:
if h.is_image:
self.field_list.append(("fits", h.name.lower()))
-
+
def _count_grids(self):
self.num_grids = self.pf.nprocs
-
+
def _parse_index(self):
f = self._handle # shortcut
pf = self.parameter_file # shortcut
@@ -98,12 +134,12 @@
self.grid_left_edge[0,:] = pf.domain_left_edge
self.grid_right_edge[0,:] = pf.domain_right_edge
self.grid_dimensions[0] = pf.domain_dimensions
-
+
self.grid_levels.flat[:] = 0
self.grids = np.empty(self.num_grids, dtype='object')
for i in xrange(self.num_grids):
self.grids[i] = self.grid(i, self, self.grid_levels[i,0])
-
+
def _populate_grid_objects(self):
for i in xrange(self.num_grids):
self.grids[i]._prepare_grid()
@@ -112,7 +148,7 @@
def _setup_derived_fields(self):
super(FITSHierarchy, self)._setup_derived_fields()
- [self.parameter_file.conversion_factors[field]
+ [self.parameter_file.conversion_factors[field]
for field in self.field_list]
for field in self.field_list:
if field not in self.derived_field_list:
@@ -122,8 +158,8 @@
f = self.parameter_file.field_info[field]
if f._function.func_name == "_TranslationFunc":
# Translating an already-converted field
- self.parameter_file.conversion_factors[field] = 1.0
-
+ self.parameter_file.conversion_factors[field] = 1.0
+
def _setup_data_io(self):
self.io = io_registry[self.dataset_type](self.parameter_file)
@@ -132,7 +168,7 @@
_field_info_class = FITSFieldInfo
_dataset_type = "fits"
_handle = None
-
+
def __init__(self, filename, dataset_type='fits',
primary_header = None,
sky_conversion = None,
@@ -142,24 +178,24 @@
self.fluid_types += ("fits",)
self.mask_nans = mask_nans
self.nprocs = nprocs
- if isinstance(filename, pyfits.HDUList):
+ if isinstance(filename, ap.pyfits.HDUList):
self._handle = filename
fname = filename.filename()
else:
- self._handle = pyfits.open(filename)
+ self._handle = ap.pyfits.open(filename)
fname = filename
for i, h in enumerate(self._handle):
if h.is_image and h.data is not None:
self.first_image = i
break
-
+
if primary_header is None:
self.primary_header = self._handle[self.first_image].header
else:
self.primary_header = primary_header
self.shape = self._handle[self.first_image].shape
- self.wcs = pywcs.WCS(header=self.primary_header)
+ self.wcs = ap.pywcs.WCS(header=self.primary_header)
self.file_unit = None
for i, unit in enumerate(self.wcs.wcs.cunit):
@@ -177,10 +213,11 @@
self.new_unit = self.file_unit
self.pixel_scale = self.wcs.wcs.cdelt[idx]
+ self.refine_by = 2
+
Dataset.__init__(self, fname, dataset_type)
self.storage_filename = storage_filename
-
- self.refine_by = 2
+
# For plotting to APLpy
self.hdu_list = self._handle
@@ -198,7 +235,7 @@
self.length_unit = self.quan(length_factor,length_unit)
self.mass_unit = self.quan(1.0, "g")
self.time_unit = self.quan(1.0, "s")
- self.velocity_unit = self.quan(1.0, "cm/s")
+ self.velocity_unit = self.quan(1.0, "cm/s")
def _parse_parameter_file(self):
self.unique_identifier = \
@@ -216,14 +253,14 @@
if self.dimensionality == 2:
self.domain_dimensions = np.append(self.domain_dimensions,
[int(1)])
-
+
self.domain_left_edge = np.array([0.5]*3)
self.domain_right_edge = np.array([float(dim)+0.5 for dim in self.domain_dimensions])
if self.dimensionality == 2:
self.domain_left_edge[-1] = 0.5
self.domain_right_edge[-1] = 1.5
-
+
# Get the simulation time
try:
self.current_time = self.parameters["time"]
@@ -231,7 +268,7 @@
mylog.warning("Cannot find time")
self.current_time = 0.0
pass
-
+
# For now we'll ignore these
self.periodicity = (False,)*3
self.current_redshift = self.omega_lambda = self.omega_matter = \
@@ -242,15 +279,24 @@
@classmethod
def _is_valid(self, *args, **kwargs):
+ if isinstance(args[0], types.StringTypes):
+ ext = args[0].rsplit(".", 1)[-1]
+ if ext.upper() == "GZ":
+ # We don't know for sure that there will be > 1
+ ext = args[0].rsplit(".", 1)[0].rsplit(".", 1)[-1]
+ if ext.upper() not in ("FITS", "FTS"):
+ return False
try:
- if isinstance(args[0], pyfits.HDUList):
+ if args[0].__class__.__name__ == "HDUList":
for h in args[0]:
if h.is_image and h.data is not None:
return True
except:
pass
try:
- fileh = pyfits.open(args[0])
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', category=UserWarning, append=True)
+ fileh = ap.pyfits.open(args[0])
for h in fileh:
if h.is_image and h.data is not None:
fileh.close()
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/fits/io.py
--- a/yt/frontends/fits/io.py
+++ b/yt/frontends/fits/io.py
@@ -11,10 +11,6 @@
#-----------------------------------------------------------------------------
import numpy as np
-try:
- import astropy.io.fits as pyfits
-except ImportError:
- pass
from yt.utilities.math_utils import prec_accum
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/halo_catalogs/api.py
--- a/yt/frontends/halo_catalogs/api.py
+++ b/yt/frontends/halo_catalogs/api.py
@@ -14,12 +14,12 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from halo_catalog.api import \
+from .halo_catalog.api import \
HaloCatalogDataset, \
IOHandlerHaloCatalogHDF5, \
HaloCatalogFieldInfo
-from rockstar.api import \
+from .rockstar.api import \
RockstarDataset, \
IOHandlerRockstarBinary, \
RockstarFieldInfo
diff -r 14708c1d5e51e39c8418e13f4229ab81b406913d -r 65857bada1205454cb658e7f37ce2c897c6b885f yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -432,7 +432,7 @@
g = og
yield YTDataChunk(dobj, "spatial", [g], None)
- def _chunk_io(self, dobj, cache = True):
+ def _chunk_io(self, dobj, cache = True, local_only = False):
oobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
for subset in oobjs:
yield YTDataChunk(dobj, "io", [subset], None, cache = cache)
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/yt_analysis/yt/commits/a3a0ab694997/
Changeset: a3a0ab694997
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 22:10:41
Summary: Adding helpful error output.
Affected #: 1 file
diff -r 65857bada1205454cb658e7f37ce2c897c6b885f -r a3a0ab694997c5d1f6861d16061ac01a35759dfd yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -172,7 +172,8 @@
original_fields = data.keys() # Copy
if self._function is NullFunc:
raise RuntimeError(
- "Something has gone terribly wrong, _function is NullFunc")
+ "Something has gone terribly wrong, _function is NullFunc " +
+ "for %s" % (self.name,))
with self.unit_registry(data):
dd = self._function(self, data)
for field_name in data.keys():
https://bitbucket.org/yt_analysis/yt/commits/f55e917e80c9/
Changeset: f55e917e80c9
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 22:18:15
Summary: Be a bit smarter about aliasing momentum.
Affected #: 1 file
diff -r a3a0ab694997c5d1f6861d16061ac01a35759dfd -r f55e917e80c9320961f5645b5d4bf0c830c587f5 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -57,6 +57,10 @@
("Temp", ("K", ["temperature"], None)),
("x_velocity", ("cm/s", ["velocity_x"], None)),
("y_velocity", ("cm/s", ["velocity_y"], None)),
+ ("z_velocity", ("cm/s", ["velocity_z"], None)),
+ ("xvel", ("cm/s", ["velocity_x"], None)),
+ ("yvel", ("cm/s", ["velocity_y"], None)),
+ ("zvel", ("cm/s", ["velocity_z"], None)),
)
known_particle_fields = (
@@ -82,14 +86,9 @@
)
def setup_fluid_fields(self):
- self._show_field_errors.append(("gas", "temperature"))
- def _get_vel(axis):
- def velocity(field, data):
- return data["%smom" % axis]/data["density"]
- for ax in 'xyz':
- self.add_field(("gas", "velocity_%s" % ax),
- function = _get_vel(ax),
- units = "cm/s")
+ # Now, let's figure out what fields are included.
+ if any(f[1] == "xmom" for f in self.field_list):
+ self.setup_momentum_to_velocity()
self.add_field(("gas", "thermal_energy"),
function = _thermal_energy,
units = "erg/g")
@@ -100,3 +99,12 @@
self.add_field(("gas", "temperature"),
function=_temperature,
units="K")
+
+ def setup_momentum_to_velocity(self):
+ def _get_vel(axis):
+ def velocity(field, data):
+ return data["%smom" % axis]/data["density"]
+ for ax in 'xyz':
+ self.add_field(("gas", "velocity_%s" % ax),
+ function = _get_vel(ax),
+ units = "cm/s")
https://bitbucket.org/yt_analysis/yt/commits/b6bb07e51495/
Changeset: b6bb07e51495
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 22:34:20
Summary: Remove ghost zone requiring fields.
Affected #: 1 file
diff -r f55e917e80c9320961f5645b5d4bf0c830c587f5 -r b6bb07e51495d2f14e034b01046dc459a14b930c yt/frontends/boxlib/tests/test_orion.py
--- a/yt/frontends/boxlib/tests/test_orion.py
+++ b/yt/frontends/boxlib/tests/test_orion.py
@@ -21,8 +21,9 @@
data_dir_load
from yt.frontends.boxlib.api import OrionDataset
-_fields = ("temperature", "density", "velocity_magnitude",
- "velocity_divergence")
+# We don't do anything needing ghost zone generation right now, because these
+# are non-periodic datasets.
+_fields = ("temperature", "density", "velocity_magnitude")
radadvect = "RadAdvect/plt00000"
@requires_pf(radadvect)
https://bitbucket.org/yt_analysis/yt/commits/33bb22b43c08/
Changeset: 33bb22b43c08
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 22:52:50
Summary: Fixing issue with coordinates not being in code_length.
Affected #: 1 file
diff -r b6bb07e51495d2f14e034b01046dc459a14b930c -r 33bb22b43c080f417f4f6427d23f4798fad85105 yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -163,7 +163,7 @@
op.initialize()
mylog.debug("Depositing %s (%s^3) particles into %s Octs",
positions.shape[0], positions.shape[0]**0.3333333, nvals[-1])
- pos = np.array(positions, dtype="float64")
+ pos = np.array(positions.in_units("code_length"), dtype="float64")
# We should not need the following if we know in advance all our fields
# need no casting.
fields = [np.asarray(f, dtype="float64") for f in fields]
@@ -176,6 +176,7 @@
def smooth(self, positions, fields = None, index_fields = None,
method = None, create_octree = False, nneighbors = 64):
# Here we perform our particle deposition.
+ positions.convert_to("code_length")
if create_octree:
morton = compute_morton(
positions[:,0], positions[:,1], positions[:,2],
https://bitbucket.org/yt_analysis/yt/commits/b0d36db9e7b8/
Changeset: b0d36db9e7b8
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 22:55:43
Summary: Merging to get a fix
Affected #: 2 files
diff -r 33bb22b43c080f417f4f6427d23f4798fad85105 -r b0d36db9e7b8e5eba29459469f992d02debaa5f0 yt/geometry/particle_geometry_handler.py
--- a/yt/geometry/particle_geometry_handler.py
+++ b/yt/geometry/particle_geometry_handler.py
@@ -163,7 +163,7 @@
g = og
yield YTDataChunk(dobj, "spatial", [g])
- def _chunk_io(self, dobj, cache = True):
+ def _chunk_io(self, dobj, cache = True, local_only = False):
oobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
for subset in oobjs:
yield YTDataChunk(dobj, "io", [subset], None, cache = cache)
diff -r 33bb22b43c080f417f4f6427d23f4798fad85105 -r b0d36db9e7b8e5eba29459469f992d02debaa5f0 yt/geometry/unstructured_mesh_handler.py
--- a/yt/geometry/unstructured_mesh_handler.py
+++ b/yt/geometry/unstructured_mesh_handler.py
@@ -86,7 +86,7 @@
if size == 0: continue
yield YTDataChunk(dobj, "spatial", [g], size)
- def _chunk_io(self, dobj, cache = True):
+ def _chunk_io(self, dobj, cache = True, local_only = False):
oobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info)
for subset in oobjs:
s = self._count_selection(dobj, oobjs)
https://bitbucket.org/yt_analysis/yt/commits/10d1dc3bd8c8/
Changeset: 10d1dc3bd8c8
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 23:17:58
Summary: Fixing testing errors for SPH.
Affected #: 2 files
diff -r b0d36db9e7b8e5eba29459469f992d02debaa5f0 -r 10d1dc3bd8c852b949b5fa1e088b42e1be40e13f yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -176,7 +176,7 @@
def smooth(self, positions, fields = None, index_fields = None,
method = None, create_octree = False, nneighbors = 64):
# Here we perform our particle deposition.
- positions.convert_to("code_length")
+ positions.convert_to_units("code_length")
if create_octree:
morton = compute_morton(
positions[:,0], positions[:,1], positions[:,2],
diff -r b0d36db9e7b8e5eba29459469f992d02debaa5f0 -r 10d1dc3bd8c852b949b5fa1e088b42e1be40e13f yt/frontends/sph/tests/test_tipsy.py
--- a/yt/frontends/sph/tests/test_tipsy.py
+++ b/yt/frontends/sph/tests/test_tipsy.py
@@ -37,8 +37,7 @@
omega_lambda = 0.728,
omega_matter = 0.272,
hubble_constant = 0.702)
- kwargs = dict(endian="<",
- field_dtypes = {"Coordinates": "d"},
+ kwargs = dict(field_dtypes = {"Coordinates": "d"},
cosmology_parameters = cosmology_parameters,
unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
https://bitbucket.org/yt_analysis/yt/commits/02f0e173282e/
Changeset: 02f0e173282e
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 23:50:57
Summary: Manually add mass for invariable particle mass.
Affected #: 1 file
diff -r 10d1dc3bd8c852b949b5fa1e088b42e1be40e13f -r 02f0e173282eb340e1b38960d7df405acde842e4 yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -178,6 +178,8 @@
#ptype = int(key[8:])
ptype = str(key)
+ if ptype not in self.var_mass:
+ fields.append((ptype, mname))
# loop over all keys in PartTypeX group
#----------------------------------------
https://bitbucket.org/yt_analysis/yt/commits/458091263f02/
Changeset: 458091263f02
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-02 23:53:27
Summary: Don't add smoothing aliases for known vector fields.
Affected #: 1 file
diff -r 02f0e173282eb340e1b38960d7df405acde842e4 -r 458091263f020cd26d28535b84fb5aab72625a13 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -114,6 +114,8 @@
sml_name = None
new_aliases = []
for _, alias_name in self.field_aliases:
+ if alias_name in ("particle_position", "particle_velocity"):
+ continue
fn = add_volume_weighted_smoothed_field(ptype,
"particle_position", "particle_mass",
sml_name, "density", alias_name, self,
https://bitbucket.org/yt_analysis/yt/commits/1fc5b6b6be04/
Changeset: 1fc5b6b6be04
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-03 00:02:57
Summary: Switch to asarray and convert_to_units.
Affected #: 1 file
diff -r 458091263f020cd26d28535b84fb5aab72625a13 -r 1fc5b6b6be04f9869c5f12ddaa4d3fb6f2f63313 yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -163,7 +163,8 @@
op.initialize()
mylog.debug("Depositing %s (%s^3) particles into %s Octs",
positions.shape[0], positions.shape[0]**0.3333333, nvals[-1])
- pos = np.array(positions.in_units("code_length"), dtype="float64")
+ pos = np.asarray(positions.convert_to_units("code_length"),
+ dtype="float64")
# We should not need the following if we know in advance all our fields
# need no casting.
fields = [np.asarray(f, dtype="float64") for f in fields]
https://bitbucket.org/yt_analysis/yt/commits/2177f9babc9e/
Changeset: 2177f9babc9e
Branch: yt-3.0
User: jzuhone
Date: 2014-04-03 15:01:01
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #751)
First pass at updating answer_tests for new field schema.
Affected #: 22 files
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -163,7 +163,8 @@
op.initialize()
mylog.debug("Depositing %s (%s^3) particles into %s Octs",
positions.shape[0], positions.shape[0]**0.3333333, nvals[-1])
- pos = np.array(positions, dtype="float64")
+ pos = np.asarray(positions.convert_to_units("code_length"),
+ dtype="float64")
# We should not need the following if we know in advance all our fields
# need no casting.
fields = [np.asarray(f, dtype="float64") for f in fields]
@@ -176,6 +177,7 @@
def smooth(self, positions, fields = None, index_fields = None,
method = None, create_octree = False, nneighbors = 64):
# Here we perform our particle deposition.
+ positions.convert_to_units("code_length")
if create_octree:
morton = compute_morton(
positions[:,0], positions[:,1], positions[:,2],
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -172,7 +172,8 @@
original_fields = data.keys() # Copy
if self._function is NullFunc:
raise RuntimeError(
- "Something has gone terribly wrong, _function is NullFunc")
+ "Something has gone terribly wrong, _function is NullFunc " +
+ "for %s" % (self.name,))
with self.unit_registry(data):
dd = self._function(self, data)
for field_name in data.keys():
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -114,6 +114,8 @@
sml_name = None
new_aliases = []
for _, alias_name in self.field_aliases:
+ if alias_name in ("particle_position", "particle_velocity"):
+ continue
fn = add_volume_weighted_smoothed_field(ptype,
"particle_position", "particle_mass",
sml_name, "density", alias_name, self,
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/art/tests/test_outputs.py
--- a/yt/frontends/art/tests/test_outputs.py
+++ b/yt/frontends/art/tests/test_outputs.py
@@ -22,7 +22,7 @@
data_dir_load
from yt.frontends.art.api import ARTDataset
-_fields = ("Temperature", "Density", "particle_mass", ("all", "particle_position_x"))
+_fields = ("density", "temperature", "particle_mass", ("all", "particle_position_x"))
d9p = "D9p_500/10MpcBox_HartGal_csf_a0.500.d"
@@ -37,7 +37,7 @@
for field in _fields:
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
d9p, axis, field, weight_field,
ds)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/artio/data_structures.py
--- a/yt/frontends/artio/data_structures.py
+++ b/yt/frontends/artio/data_structures.py
@@ -18,7 +18,7 @@
import weakref
import cStringIO
-from .definitions import yt_to_art, art_to_yt, ARTIOconstants
+from .definitions import ARTIOconstants
from _artio_caller import \
artio_is_valid, artio_fileset, ARTIOOctreeContainer, \
ARTIORootMeshContainer, ARTIOSFCRangeHandler
@@ -59,7 +59,6 @@
self.sfc_end = sfc_end
self.oct_handler = oct_handler
self.pf = pf
- self.index = self.pf.index
self._last_mask = None
self._last_selector_id = None
self._current_particle_type = 'all'
@@ -94,31 +93,24 @@
def fill_particles(self, fields):
if len(fields) == 0: return {}
- art_fields = []
- for s, f in fields:
- fn = yt_to_art[f]
- for i in self.pf.particle_type_map[s]:
- if fn in self.pf.particle_variables[i]:
- art_fields.append((i, fn))
+ ptype_indices = self.pf.particle_types
+ art_fields = [(ptype_indices.index(ptype), fname) for
+ ptype, fname in fields]
species_data = self.oct_handler.fill_sfc_particles(art_fields)
tr = defaultdict(dict)
# Now we need to sum things up and then fill
for s, f in fields:
count = 0
- fn = yt_to_art[f]
dt = "float64" # default
- for i in self.pf.particle_type_map[s]:
- if (i, fn) not in species_data: continue
- # No vector fields in ARTIO
- count += species_data[i, fn].size
- dt = species_data[i, fn].dtype
+ i = ptype_indices.index(s)
+ # No vector fields in ARTIO
+ count += species_data[i, f].size
+ dt = species_data[i, f].dtype
tr[s][f] = np.zeros(count, dtype=dt)
cp = 0
- for i in self.pf.particle_type_map[s]:
- if (i, fn) not in species_data: continue
- v = species_data.pop((i, fn))
- tr[s][f][cp:cp+v.size] = v
- cp += v.size
+ v = species_data.pop((i, f))
+ tr[s][f][cp:cp+v.size] = v
+ cp += v.size
return tr
# We create something of a fake octree here. This is primarily to enable us to
@@ -225,13 +217,10 @@
def _detect_particle_fields(self):
fields = set()
- for ptype in self.pf.particle_types:
- if ptype == "all": continue
- for f in yt_to_art.values():
- if all(f in self.pf.particle_variables[i]
- for i in range(self.pf.num_species)
- if art_to_yt[self.pf.particle_species[i]] == ptype):
- fields.add((ptype, art_to_yt[f]))
+ for i, ptype in enumerate(self.pf.particle_types):
+ if ptype == "all": break # This will always be after all intrinsic
+ for fname in self.pf.particle_variables[i]:
+ fields.add((ptype, fname))
return list(fields)
def _identify_base_chunk(self, dobj):
@@ -370,14 +359,9 @@
self.num_species = self.artio_parameters["num_particle_species"][0]
self.particle_variables = [["PID", "SPECIES"]
for i in range(self.num_species)]
- self.particle_species = \
+ self.particle_types_raw = \
self.artio_parameters["particle_species_labels"]
- self.particle_type_map = {}
- for i, s in enumerate(self.particle_species):
- f = art_to_yt[s]
- if f not in self.particle_type_map:
- self.particle_type_map[f] = []
- self.particle_type_map[f].append(i)
+ self.particle_types = tuple(self.particle_types_raw)
for species in range(self.num_species):
# Mass would be best as a derived field,
@@ -397,10 +381,6 @@
"species_%02d_secondary_variable_labels"
% (species, )])
- self.particle_types_raw = tuple(
- set(art_to_yt[s] for s in
- self.artio_parameters["particle_species_labels"]))
- self.particle_types = tuple(self.particle_types)
else:
self.num_species = 0
self.particle_variables = []
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/artio/fields.py
--- a/yt/frontends/artio/fields.py
+++ b/yt/frontends/artio/fields.py
@@ -24,7 +24,9 @@
from yt.utilities.physical_constants import \
mh, \
- mass_sun_cgs
+ mass_sun_cgs, \
+ boltzmann_constant_cgs, \
+ amu_cgs
b_units = "code_magnetic"
ra_units = "code_length / code_time**2"
@@ -43,7 +45,7 @@
("HVAR_MOMENTUM_X", (mom_units, ["momentum_x"], None)),
("HVAR_MOMENTUM_Y", (mom_units, ["momentum_y"], None)),
("HVAR_MOMENTUM_Z", (mom_units, ["momentum_z"], None)),
- ("HVAR_GAMMA", ("", "gamma", None)),
+ ("HVAR_GAMMA", ("", ["gamma"], None)),
("HVAR_METAL_DENSITY_Ia", (rho_units, ["metal_ia_density"], None)),
("HVAR_METAL_DENSITY_II", (rho_units, ["metal_ii_density"], None)),
("VAR_POTENTIAL", ("", ["potential"], None)),
@@ -69,9 +71,11 @@
def setup_fluid_fields(self):
def _get_vel(axis):
def velocity(field, data):
- return data["momentum_%s" % ax]/data["density"]
+ return data["momentum_%s" % axis]/data["density"]
+ return velocity
for ax in 'xyz':
- self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ self.add_field(("gas", "velocity_%s" % ax),
+ function = _get_vel(ax),
units = "cm/s")
def _temperature(field, data):
@@ -79,26 +83,31 @@
# We want this to match *exactly* what ARTIO would compute
# internally. We therefore use the exact values that are internal
# to ARTIO, rather than yt's own internal constants.
- amu = 1.660538782e-24
- mH = 1.007825*amu
- mHe = 4.002602*amu
+ mH = 1.007825*amu_cgs
+ mHe = 4.002602*amu_cgs
Yp = 0.24
XH = 1.0 - Yp
XHe = 0.25*Yp
mb = XH*mH + XHe*mHe
wmu = 4.0/(8.0-5.0*Yp)
# Note that we have gamma = 5.0/3.0 here
- return tr * wmu * (data["gamma"] - 1)
+ tr *= (data["gamma"] - 1.0)
+ tr *= wmu
+ tr *= mb/boltzmann_constant_cgs
+ return tr
# TODO: The conversion factor here needs to be addressed, as previously
# it was set as:
# unit_T = unit_v**2.0*mb / constants.k
- self.add_field("temperature", function = _temperature, units = "")
+ self.add_field(("gas", "temperature"), function = _temperature,
+ units = "K")
def _metal_density(field, data):
tr = data["metal_ia_density"]
tr += data["metal_ii_density"]
return tr
- self.add_field("metal_density", function=_metal_density, units="g/cm**3",
+ self.add_field(("gas","metal_density"),
+ function=_metal_density,
+ units="g/cm**3",
take_log=True)
def setup_particle_fields(self, ptype):
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/artio/io.py
--- a/yt/frontends/artio/io.py
+++ b/yt/frontends/artio/io.py
@@ -35,27 +35,27 @@
return tr
def _read_particle_coords(self, chunks, ptf):
- pn = "particle_position_%s"
+ pn = "POSITION_%s"
chunks = list(chunks)
- fields = [(ptype, "particle_position_%s" % ax)
+ fields = [(ptype, pn % ax)
for ptype, field_list in ptf.items()
- for ax in 'xyz']
+ for ax in 'XYZ']
for chunk in chunks: # These should be organized by grid filename
for subset in chunk.objs:
rv = dict(**subset.fill_particles(fields))
for ptype, field_list in sorted(ptf.items()):
x, y, z = (np.asarray(rv[ptype][pn % ax], dtype="=f8")
- for ax in 'xyz')
+ for ax in 'XYZ')
yield ptype, (x, y, z)
rv.pop(ptype)
def _read_particle_fields(self, chunks, ptf, selector):
- pn = "particle_position_%s"
+ pn = "POSITION_%s"
chunks = list(chunks)
fields = [(ptype, fname) for ptype, field_list in ptf.items()
for fname in field_list]
for ptype, field_list in sorted(ptf.items()):
- for ax in 'xyz':
+ for ax in 'XYZ':
if pn % ax not in field_list:
fields.append((ptype, pn % ax))
for chunk in chunks: # These should be organized by grid filename
@@ -63,7 +63,7 @@
rv = dict(**subset.fill_particles(fields))
for ptype, field_list in sorted(ptf.items()):
x, y, z = (np.asarray(rv[ptype][pn % ax], dtype="=f8")
- for ax in 'xyz')
+ for ax in 'XYZ')
mask = selector.select_points(x, y, z)
if mask is None: continue
for field in field_list:
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/artio/tests/test_outputs.py
--- a/yt/frontends/artio/tests/test_outputs.py
+++ b/yt/frontends/artio/tests/test_outputs.py
@@ -23,7 +23,7 @@
create_obj
from yt.frontends.artio.api import ARTIODataset
-_fields = ("Temperature", "Density", "VelocityMagnitude",
+_fields = ("temperature", "density", "velocity_magnitude",
("deposit", "all_density"), ("deposit", "all_count"))
sizmbhloz = "sizmbhloz-clref04SNth-rs9_a0.9011/sizmbhloz-clref04SNth-rs9_a0.9011.art"
@@ -36,12 +36,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
sizmbhloz, axis, field, weight_field,
ds)
yield FieldValuesTest(sizmbhloz, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -395,6 +395,8 @@
self.parameters["HydroMethod"] = 'boxlib'
self.parameters["Time"] = 1. # default unit is 1...
self.parameters["EOSType"] = -1 # default
+ self.parameters["gamma"] = self.parameters.get(
+ "materials.gamma", 1.6667)
def _localize_check(self, fn):
# If the file exists, use it. If not, set it to None.
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -16,28 +16,35 @@
import numpy as np
from yt.utilities.physical_constants import \
- mh, kboltz
+ mh, boltzmann_constant_cgs, amu_cgs
from yt.fields.field_info_container import \
FieldInfoContainer
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
def _thermal_energy_density(field, data):
+ # What we've got here is UEINT:
+ # u here is velocity
+ # E is energy density from the file
+ # rho e = rho E - rho * u * u / 2
ke = 0.5 * ( data["momentum_x"]**2
+ data["momentum_y"]**2
+ data["momentum_z"]**2) / data["density"]
return data["eden"] - ke
def _thermal_energy(field, data):
+ # This is little e, so we take thermal_energy_density and divide by density
return data["thermal_energy_density"] / data["density"]
def _temperature(field,data):
- mu = data.get_field_parameter("mu")
- return ( (data.pf.gamma-1.0) * mu * mh *
- data["thermal_energy"] / (kboltz * data["density"]) )
-
+ mu = data.pf.parameters["mu"]
+ gamma = data.pf.parameters["gamma"]
+ tr = data["thermal_energy_density"] / data["density"]
+ tr *= mu * amu_cgs / boltzmann_constant_cgs
+ tr *= (gamma - 1.0)
+ return tr
class BoxlibFieldInfo(FieldInfoContainer):
known_other_fields = (
@@ -47,8 +54,13 @@
("ymom", (mom_units, ["momentum_y"], None)),
("zmom", (mom_units, ["momentum_z"], None)),
("temperature", ("K", ["temperature"], None)),
+ ("Temp", ("K", ["temperature"], None)),
("x_velocity", ("cm/s", ["velocity_x"], None)),
("y_velocity", ("cm/s", ["velocity_y"], None)),
+ ("z_velocity", ("cm/s", ["velocity_z"], None)),
+ ("xvel", ("cm/s", ["velocity_x"], None)),
+ ("yvel", ("cm/s", ["velocity_y"], None)),
+ ("zvel", ("cm/s", ["velocity_z"], None)),
)
known_particle_fields = (
@@ -74,17 +86,25 @@
)
def setup_fluid_fields(self):
+ # Now, let's figure out what fields are included.
+ if any(f[1] == "xmom" for f in self.field_list):
+ self.setup_momentum_to_velocity()
+ self.add_field(("gas", "thermal_energy"),
+ function = _thermal_energy,
+ units = "erg/g")
+ self.add_field(("gas", "thermal_energy_density"),
+ function = _thermal_energy_density,
+ units = "erg/cm**3")
+ if ("gas", "temperature") not in self.field_aliases:
+ self.add_field(("gas", "temperature"),
+ function=_temperature,
+ units="K")
+
+ def setup_momentum_to_velocity(self):
def _get_vel(axis):
def velocity(field, data):
- return data["%smom" % ax]/data["density"]
+ return data["%smom" % axis]/data["density"]
for ax in 'xyz':
- self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ self.add_field(("gas", "velocity_%s" % ax),
+ function = _get_vel(ax),
units = "cm/s")
- self.add_field("thermal_energy",
- function = _thermal_energy,
- units = "erg/g")
- self.add_field("thermal_energy_density",
- function = _thermal_energy_density,
- units = "erg/cm**3")
- self.add_field("temperature", function=_temperature,
- units="K")
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/boxlib/tests/test_orion.py
--- a/yt/frontends/boxlib/tests/test_orion.py
+++ b/yt/frontends/boxlib/tests/test_orion.py
@@ -21,7 +21,9 @@
data_dir_load
from yt.frontends.boxlib.api import OrionDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+# We don't do anything needing ghost zone generation right now, because these
+# are non-periodic datasets.
+_fields = ("temperature", "density", "velocity_magnitude")
radadvect = "RadAdvect/plt00000"
@requires_pf(radadvect)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db 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,8 @@
data_dir_load
from yt.frontends.chombo.api import ChomboDataset
-_fields = ("Density", "VelocityMagnitude", "DivV", "X-magnfield")
+_fields = ("density", "velocity_magnitude", "velocity_divergence",
+ "magnetic_field_x")
gc = "GaussianCloud/data.0077.3d.hdf5"
@requires_pf(gc)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/enzo/tests/test_outputs.py
--- a/yt/frontends/enzo/tests/test_outputs.py
+++ b/yt/frontends/enzo/tests/test_outputs.py
@@ -21,7 +21,8 @@
data_dir_load
from yt.frontends.enzo.api import EnzoDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+_fields = ("temperature", "density", "velocity_magnitude",
+ "velocity_divergence")
m7 = "DD0010/moving7_0010"
@requires_pf(m7)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/flash/tests/test_outputs.py
--- a/yt/frontends/flash/tests/test_outputs.py
+++ b/yt/frontends/flash/tests/test_outputs.py
@@ -21,7 +21,7 @@
data_dir_load
from yt.frontends.flash.api import FLASHDataset
-_fields = ("Temperature", "Density", "VelocityMagnitude", "DivV")
+_fields = ("temperature", "density", "velocity_magnitude", "velocity_divergence")
sloshing = "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0300"
@requires_pf(sloshing, big_data=True)
@@ -32,7 +32,7 @@
test_sloshing.__name__ = test.description
yield test
-_fields_2d = ("Temperature", "Density")
+_fields_2d = ("temperature", "density")
wt = "WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030"
@requires_pf(wt)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -38,7 +38,9 @@
dd = pf.h.all_data()
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["CellVolumeCode"].sum(dtype="float64"), 1.0, 10
+ yield assert_almost_equal, \
+ dd["cell_volume"].in_units("code_length**3").sum(dtype="float64"), \
+ 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,
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -23,7 +23,7 @@
create_obj
from yt.frontends.artio.api import ARTIODataset
-_fields = ("Temperature", "Density", "VelocityMagnitude",
+_fields = ("temperature", "density", "velocity_magnitude",
("deposit", "all_density"), ("deposit", "all_count"))
output_00080 = "output_00080/info_00080.txt"
@@ -35,12 +35,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
output_00080, axis, field, weight_field,
ds)
yield FieldValuesTest(output_00080, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -178,6 +178,8 @@
#ptype = int(key[8:])
ptype = str(key)
+ if ptype not in self.var_mass:
+ fields.append((ptype, mname))
# loop over all keys in PartTypeX group
#----------------------------------------
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/sph/tests/test_owls.py
--- a/yt/frontends/sph/tests/test_owls.py
+++ b/yt/frontends/sph/tests/test_owls.py
@@ -36,20 +36,20 @@
yield assert_equal, str(pf), "snap_033"
dso = [ None, ("sphere", ("c", (0.1, 'unitary')))]
dd = pf.h.all_data()
- yield assert_equal, dd["Coordinates"].shape[0], 2*(128*128*128)
- yield assert_equal, dd["Coordinates"].shape[1], 3
- tot = sum(dd[ptype,"Coordinates"].shape[0]
+ yield assert_equal, dd["particle_position"].shape[0], 2*(128*128*128)
+ yield assert_equal, dd["particle_position"].shape[1], 3
+ tot = sum(dd[ptype,"particle_position"].shape[0]
for ptype in pf.particle_types if ptype != "all")
yield assert_equal, tot, (2*128*128*128)
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
os33, axis, field, weight_field,
ds)
yield FieldValuesTest(os33, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/frontends/sph/tests/test_tipsy.py
--- a/yt/frontends/sph/tests/test_tipsy.py
+++ b/yt/frontends/sph/tests/test_tipsy.py
@@ -37,10 +37,9 @@
omega_lambda = 0.728,
omega_matter = 0.272,
hubble_constant = 0.702)
- kwargs = dict(endian="<",
- field_dtypes = {"Coordinates": "d"},
+ kwargs = dict(field_dtypes = {"Coordinates": "d"},
cosmology_parameters = cosmology_parameters,
- unit_base = {'mpchcm': 1.0/60.0},
+ unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
pf = data_dir_load(pkdgrav, TipsyDataset, (), kwargs)
yield assert_equal, str(pf), "halo1e11_run1.00400"
@@ -53,13 +52,13 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf, axis, field, weight_field,
ds)
yield FieldValuesTest(pf, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
@@ -71,7 +70,7 @@
omega_matter = 0.272,
hubble_constant = 0.702)
kwargs = dict(cosmology_parameters = cosmology_parameters,
- unit_base = {'mpchcm': 1.0/60.0},
+ unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
pf = data_dir_load(gasoline, TipsyDataset, (), kwargs)
yield assert_equal, str(pf), "agora_1e11.00400"
@@ -84,12 +83,12 @@
for ds in dso:
for field in _fields:
for axis in [0, 1, 2]:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf, axis, field, weight_field,
ds)
yield FieldValuesTest(pf, field, ds)
dobj = create_obj(pf, ds)
- s1 = dobj["Ones"].sum()
+ s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -345,7 +345,7 @@
This is a helper function to return the location of the most dense
point.
"""
- return self.pf.h.find_max("Density")[1]
+ return self.pf.h.find_max("density")[1]
@property
def entire_simulation(self):
@@ -378,9 +378,9 @@
def run(self):
obj = create_obj(self.pf, self.obj_type)
- avg = obj.quantities["WeightedAverageQuantity"](self.field,
- weight="Ones")
- (mi, ma), = obj.quantities["Extrema"](self.field)
+ avg = obj.quantities.weighted_average_quantity(
+ self.field, weight="ones")
+ mi, ma = obj.quantities.extrema(self.field)
return np.array([avg, mi, ma])
def compare(self, new_result, old_result):
@@ -551,11 +551,11 @@
def run(self):
result = {}
- result["grid_dimensions"] = self.pf.grid_dimensions
- result["grid_left_edges"] = self.pf.grid_left_edge
- result["grid_right_edges"] = self.pf.grid_right_edge
- result["grid_levels"] = self.pf.grid_levels
- result["grid_particle_count"] = self.pf.grid_particle_count
+ result["grid_dimensions"] = self.pf.index.grid_dimensions
+ result["grid_left_edges"] = self.pf.index.grid_left_edge
+ result["grid_right_edges"] = self.pf.index.grid_right_edge
+ result["grid_levels"] = self.pf.index.grid_levels
+ result["grid_particle_count"] = self.pf.index.grid_particle_count
return result
def compare(self, new_result, old_result):
@@ -710,7 +710,7 @@
yield GridValuesTest(pf_fn, field)
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield ProjectionValuesTest(
pf_fn, axis, field, weight_field,
ds)
@@ -726,7 +726,7 @@
yield GridValuesTest(pf_fn, field)
for axis in [0, 1, 2]:
for ds in dso:
- for weight_field in [None, "Density"]:
+ for weight_field in [None, "density"]:
yield PixelizedProjectionValuesTest(
pf_fn, axis, field, weight_field,
ds)
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/utilities/answer_testing/hydro_tests.py
--- a/yt/utilities/answer_testing/hydro_tests.py
+++ b/yt/utilities/answer_testing/hydro_tests.py
@@ -141,14 +141,14 @@
# function, which is a relatively simple function that takes the base class,
# a name, and any parameters that the test requires.
for axis in range(3):
- for field in ["Density", "Temperature"]:
+ for field in ["density", "temperature"]:
create_test(TestProjection, "projection_test_%s_%s" % (axis, field),
field = field, axis = axis)
class TestGasDistribution(YTDatasetTest):
field_x = None
field_y = None
- weight = "CellMassMsun"
+ weight = "cell_mass"
n_bins = 32
def run(self):
@@ -172,14 +172,14 @@
# Now we create all our tests, but we're only going to check the binning
# against Density for now.
-for field in ["Temperature", "velocity_x"]:
+for field in ["temperature", "velocity_x"]:
create_test(TestGasDistribution, "profile_density_test_%s" % field,
- field_x = "Density", field_y = field)
+ field_x = "density", field_y = field)
class Test2DGasDistribution(TestGasDistribution):
x_bins = 128
y_bins = 128
- field_z = "CellMassMsun"
+ field_z = "cell_mass"
weight = None
def run(self):
# We're NOT going to use the low-level profiling API here,
diff -r 0abde8f94135e48c58a9a963d9d877024834495b -r 2177f9babc9ef261132a58655cf2564e7223a2db yt/utilities/answer_testing/output_tests.py
--- a/yt/utilities/answer_testing/output_tests.py
+++ b/yt/utilities/answer_testing/output_tests.py
@@ -212,7 +212,7 @@
This is a helper function to return the location of the most dense
point.
"""
- return self.pf.h.find_max("Density")[1]
+ return self.pf.h.find_max("density")[1]
@property
def entire_simulation(self):
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