[yt-svn] commit/yt-3.0: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Sep 28 14:15:57 PDT 2013
5 new commits in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/commits/83cef72ca0d0/
Changeset: 83cef72ca0d0
Branch: yt-3.0
User: MatthewTurk
Date: 2013-09-24 19:51:41
Summary: First pass at GadgetHDF5, and enabling a bounding box indexing system.
Affected #: 1 file
diff -r 97b4dd0e60c14fc770dbcf4c6bfbaff3dac3bb8e -r 83cef72ca0d012510bc2ceff2ab6a2093d51b19f yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -142,7 +142,8 @@
def __init__(self, filename, data_style="gadget_binary",
additional_fields=(),
unit_base=None, n_ref=64,
- over_refine_factor=1):
+ over_refine_factor=1,
+ bounding_box = None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
self.storage_filename = None
@@ -151,13 +152,18 @@
# integration the redshift will be zero.
unit_base['cmcm'] = unit_base["UnitLength_in_cm"]
self._unit_base = unit_base
+ if bounding_box is not None:
+ bbox = np.array(bounding_box, dtype="float64")
+ self.domain_left_edge = bbox[:,0]
+ self.domain_right_edge = bbox[:,1]
+ else:
+ self.domain_left_edge = self.domain_right_edge = None
super(GadgetStaticOutput, self).__init__(filename, data_style)
def __repr__(self):
return os.path.basename(self.parameter_filename).split(".")[0]
- def _parse_parameter_file(self):
-
+ def _get_hvals(self):
# The entries in this header are capitalized and named to match Table 4
# in the GADGET-2 user guide.
@@ -167,6 +173,10 @@
if len(hvals[i]) == 1:
hvals[i] = hvals[i][0]
+ def _parse_parameter_file(self):
+
+ hvals = self._get_hvals()
+
self.dimensionality = 3
self.refine_by = 2
self.parameters["HydroMethod"] = "sph"
@@ -174,8 +184,10 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
- self.domain_left_edge = np.zeros(3, "float64")
- self.domain_right_edge = np.ones(3, "float64") * hvals["BoxSize"]
+ # We may have an overridden bounding box.
+ if self.domain_left_edge is None:
+ self.domain_left_edge = np.zeros(3, "float64")
+ self.domain_right_edge = np.ones(3, "float64") * hvals["BoxSize"]
nz = 1 << self.over_refine_factor
self.domain_dimensions = np.ones(3, "int32") * nz
self.periodicity = (True, True, True)
@@ -221,8 +233,6 @@
self.file_count = hvals["NumFiles"]
- f.close()
-
def _set_units(self):
super(GadgetStaticOutput, self)._set_units()
length_unit = self.units['cm']
@@ -322,6 +332,45 @@
pass
return False
+class GadgetHDF5StaticOutput(GadgetStaticOutput):
+ _hierarchy_class = ParticleGeometryHandler
+ _file_class = ParticleFile
+ _fieldinfo_fallback = OWLSFieldInfo
+ _fieldinfo_known = KnownOWLSFields
+ _particle_mass_name = "Mass"
+ _particle_coordinates_name = "Coordinates"
+
+ def __init__(self, filename, data_style="OWLS",
+ unit_base = None, n_ref=64,
+ over_refine_factor=1,
+ bounding_box = None):
+ self.storage_filename = None
+ filename = os.path.abspath(filename)
+ super(GadgetHDF5StaticOutput, self).__init__(
+ filename, data_style, unit_base=unit_base, n_ref=n_ref,
+ over_refine_factor=over_refine_factor,
+ bounding_box = bounding_box)
+
+ def _get_hvals(self):
+ handle = h5py.File(self.parameter_filename, mode="r")
+ hvals = {}
+ hvals.update((str(k), v) for k, v in handle["/Header"].attrs.items())
+ # Compat reasons.
+ hvals["NumFiles"] = hvals["NumFilesPerSnapshot"]
+ return hvals
+
+ @classmethod
+ def _is_valid(self, *args, **kwargs):
+ try:
+ fileh = h5py.File(args[0], mode='r')
+ if "Constants" not in fileh["/"].keys() and \
+ "Header" in fileh["/"].keys():
+ fileh.close()
+ return True
+ fileh.close()
+ except:
+ pass
+ return False
class TipsyFile(ParticleFile):
https://bitbucket.org/yt_analysis/yt-3.0/commits/d996eff32038/
Changeset: d996eff32038
Branch: yt-3.0
User: MatthewTurk
Date: 2013-09-24 20:25:48
Summary: Correcting some gadget non-cosmo units issues and finishing Gadget-HDF5.
Affected #: 3 files
diff -r 83cef72ca0d012510bc2ceff2ab6a2093d51b19f -r d996eff320383d1a4247a157d22762d4ea06f2fa yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -40,6 +40,8 @@
KnownOWLSFields, \
GadgetFieldInfo, \
KnownGadgetFields, \
+ GadgetHDF5FieldInfo, \
+ KnownGadgetHDF5Fields, \
TipsyFieldInfo, \
KnownTipsyFields
@@ -100,6 +102,8 @@
mpch['%shcm' % unit] = (mpch["%sh" % unit] *
(1 + self.current_redshift))
mpch['%scm' % unit] = mpch[unit] * (1 + self.current_redshift)
+ elif 'cmcm' in unit_base:
+ unit_base['cm'] = self.units['cm'] = unit_base.pop("cmcm")
# ud == unit destination
# ur == unit registry
for ud, ur in [(self.units, mpch), (self.time_units, sec_conversion)]:
@@ -150,7 +154,7 @@
if unit_base is not None and "UnitLength_in_cm" in unit_base:
# We assume this is comoving, because in the absence of comoving
# integration the redshift will be zero.
- unit_base['cmcm'] = unit_base["UnitLength_in_cm"]
+ unit_base['cmcm'] = 1.0 / unit_base["UnitLength_in_cm"]
self._unit_base = unit_base
if bounding_box is not None:
bbox = np.array(bounding_box, dtype="float64")
@@ -333,14 +337,11 @@
return False
class GadgetHDF5StaticOutput(GadgetStaticOutput):
- _hierarchy_class = ParticleGeometryHandler
_file_class = ParticleFile
- _fieldinfo_fallback = OWLSFieldInfo
- _fieldinfo_known = KnownOWLSFields
- _particle_mass_name = "Mass"
- _particle_coordinates_name = "Coordinates"
+ _fieldinfo_fallback = GadgetHDF5FieldInfo
+ _fieldinfo_known = KnownGadgetHDF5Fields
- def __init__(self, filename, data_style="OWLS",
+ def __init__(self, filename, data_style="gadget_hdf5",
unit_base = None, n_ref=64,
over_refine_factor=1,
bounding_box = None):
@@ -357,6 +358,7 @@
hvals.update((str(k), v) for k, v in handle["/Header"].attrs.items())
# Compat reasons.
hvals["NumFiles"] = hvals["NumFilesPerSnapshot"]
+ hvals["Massarr"] = hvals["MassTable"]
return hvals
@classmethod
diff -r 83cef72ca0d012510bc2ceff2ab6a2093d51b19f -r d996eff320383d1a4247a157d22762d4ea06f2fa yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -47,6 +47,9 @@
KnownGadgetFields = FieldInfoContainer()
add_gadget_field = KnownGadgetFields.add_field
+GadgetHDF5FieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
+KnownGadgetHDF5Fields = FieldInfoContainer()
+
TipsyFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
add_Tipsy_field = TipsyFieldInfo.add_field
@@ -98,55 +101,68 @@
# Among other things we need to set up Coordinates
+def _setup_gadget_fields(ptypes, field_registry, known_registry):
+
+ # This has to be done manually for Gadget, because some of the particles will
+ # have uniform mass
+ def _gadget_particle_fields(ptype):
+ def _Mass(field, data):
+ pind = ptypes.index(ptype)
+ if data.pf["Massarr"][pind] == 0.0:
+ return data[ptype, "Masses"].copy()
+ mass = np.ones(data[ptype, "ParticleIDs"].shape[0], dtype="float64")
+ # Note that this is an alias, which is why we need to apply conversion
+ # here. Otherwise we'd have an asymmetry.
+ mass *= data.pf["Massarr"][pind] * data.convert("mass")
+ return mass
+ field_registry.add_field((ptype, "Mass"), function=_Mass,
+ particle_type = True)
+
+ for fname in ["Coordinates", "Velocities", "ParticleIDs",
+ # Note: Mass, not Masses
+ "Mass"]:
+ func = _field_concat(fname)
+ field_registry.add_field(("all", fname), function=func,
+ particle_type = True)
+
+ for ptype in ptypes:
+ known_registry.add_field((ptype, "Masses"), function=NullFunc,
+ particle_type = True,
+ convert_function=_get_conv("mass"),
+ units = r"\mathrm{g}")
+ _gadget_particle_fields(ptype)
+ known_registry.add_field((ptype, "Velocities"), function=NullFunc,
+ particle_type = True,
+ convert_function=_get_conv("velocity"),
+ units = r"\mathrm{cm}/\mathrm{s}")
+ particle_deposition_functions(ptype, "Coordinates", "Mass", field_registry)
+ particle_scalar_functions(ptype, "Coordinates", "Velocities", field_registry)
+ known_registry.add_field((ptype, "Coordinates"), function=NullFunc,
+ particle_type = True)
+ particle_deposition_functions("all", "Coordinates", "Mass", field_registry)
+
+ # Now we have to manually apply the splits for "all", since we don't want to
+ # use the splits defined above.
+
+ for iname, oname in [("Coordinates", "particle_position_"),
+ ("Velocities", "particle_velocity_")]:
+ for axi, ax in enumerate("xyz"):
+ func = _field_concat_slice(iname, axi)
+ field_registry.add_field(("all", oname + ax), function=func,
+ particle_type = True)
+
+# Note that we call the same function a few times here.
_gadget_ptypes = ("Gas", "Halo", "Disk", "Bulge", "Stars", "Bndry")
+_ghdf5_ptypes = ("PartType0", "PartType1", "PartType2", "PartType3",
+ "PartType4", "PartType5")
-# This has to be done manually for Gadget, because some of the particles will
-# have uniform mass
-def _gadget_particle_fields(ptype):
- def _Mass(field, data):
- pind = _gadget_ptypes.index(ptype)
- if data.pf["Massarr"][pind] == 0.0:
- return data[ptype, "Masses"].copy()
- mass = np.ones(data[ptype, "ParticleIDs"].shape[0], dtype="float64")
- # Note that this is an alias, which is why we need to apply conversion
- # here. Otherwise we'd have an asymmetry.
- mass *= data.pf["Massarr"][pind] * data.convert("mass")
- return mass
- GadgetFieldInfo.add_field((ptype, "Mass"), function=_Mass,
- particle_type = True)
+_setup_gadget_fields(_gadget_ptypes,
+ GadgetFieldInfo,
+ KnownGadgetFields)
+_setup_gadget_fields(_ghdf5_ptypes,
+ GadgetHDF5FieldInfo,
+ KnownGadgetHDF5Fields)
-for fname in ["Coordinates", "Velocities", "ParticleIDs",
- # Note: Mass, not Masses
- "Mass"]:
- func = _field_concat(fname)
- GadgetFieldInfo.add_field(("all", fname), function=func,
- particle_type = True)
-
-for ptype in _gadget_ptypes:
- KnownGadgetFields.add_field((ptype, "Masses"), function=NullFunc,
- particle_type = True,
- convert_function=_get_conv("mass"),
- units = r"\mathrm{g}")
- _gadget_particle_fields(ptype)
- KnownGadgetFields.add_field((ptype, "Velocities"), function=NullFunc,
- particle_type = True,
- convert_function=_get_conv("velocity"),
- units = r"\mathrm{cm}/\mathrm{s}")
- particle_deposition_functions(ptype, "Coordinates", "Mass", GadgetFieldInfo)
- particle_scalar_functions(ptype, "Coordinates", "Velocities", GadgetFieldInfo)
- KnownGadgetFields.add_field((ptype, "Coordinates"), function=NullFunc,
- particle_type = True)
-particle_deposition_functions("all", "Coordinates", "Mass", GadgetFieldInfo)
-
-# Now we have to manually apply the splits for "all", since we don't want to
-# use the splits defined above.
-
-for iname, oname in [("Coordinates", "particle_position_"),
- ("Velocities", "particle_velocity_")]:
- for axi, ax in enumerate("xyz"):
- func = _field_concat_slice(iname, axi)
- GadgetFieldInfo.add_field(("all", oname + ax), function=func,
- particle_type = True)
# OWLS
# ====
@@ -155,7 +171,7 @@
# make OWLS a subclass of Gadget fields.
_owls_ptypes = ("PartType0", "PartType1", "PartType2", "PartType3",
- "PartType4")
+ "PartType4", "PartType5")
for fname in ["Coordinates", "Velocities", "ParticleIDs",
# Note: Mass, not Masses
diff -r 83cef72ca0d012510bc2ceff2ab6a2093d51b19f -r d996eff320383d1a4247a157d22762d4ea06f2fa yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -134,6 +134,8 @@
f.close()
return fields
+class IOHandlerGadgetHDF5(IOHandlerOWLS):
+ _data_style = "gadget_hdf5"
ZeroMass = object()
https://bitbucket.org/yt_analysis/yt-3.0/commits/a9ac49222ae6/
Changeset: a9ac49222ae6
Branch: yt-3.0
User: MatthewTurk
Date: 2013-09-27 23:33:26
Summary: Updating to return hvals for binary Gadget and to use convention of mpchcm==1
for cosmological Gadget runs.
Affected #: 1 file
diff -r d996eff320383d1a4247a157d22762d4ea06f2fa -r a9ac49222ae65384288199c974678a6fbe3b070e yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -176,6 +176,7 @@
for i in hvals:
if len(hvals[i]) == 1:
hvals[i] = hvals[i][0]
+ return hvals
def _parse_parameter_file(self):
@@ -238,6 +239,9 @@
self.file_count = hvals["NumFiles"]
def _set_units(self):
+ if self._unit_base is None and self.cosmological_simulation == 1:
+ mylog.info("Assuming length units are in Mpc/h (comoving)")
+ self._unit_base = dict(mpchcm = 1.0)
super(GadgetStaticOutput, self)._set_units()
length_unit = self.units['cm']
unit_base = self._unit_base or {}
https://bitbucket.org/yt_analysis/yt-3.0/commits/28099365747f/
Changeset: 28099365747f
Branch: yt-3.0
User: MatthewTurk
Date: 2013-09-28 23:04:48
Summary: Adding GadgetHDF5 to imports.
Affected #: 2 files
diff -r a9ac49222ae65384288199c974678a6fbe3b070e -r 28099365747f426f8e1a681317daa3c0aa78b57a yt/frontends/sph/api.py
--- a/yt/frontends/sph/api.py
+++ b/yt/frontends/sph/api.py
@@ -17,6 +17,7 @@
from .data_structures import \
OWLSStaticOutput, \
GadgetStaticOutput, \
+ GadgetHDF5StaticOutput, \
TipsyStaticOutput
from .io import \
diff -r a9ac49222ae65384288199c974678a6fbe3b070e -r 28099365747f426f8e1a681317daa3c0aa78b57a yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -118,7 +118,8 @@
from yt.frontends.sph.api import \
OWLSStaticOutput, OWLSFieldInfo, add_owls_field, \
- GadgetStaticOutput, GadgetFieldInfo, add_gadget_field, \
+ GadgetStaticOutput, GadgetHDF5StaticOutput, \
+ GadgetFieldInfo, add_gadget_field, \
TipsyStaticOutput, TipsyFieldInfo, add_tipsy_field
from yt.analysis_modules.list_modules import \
https://bitbucket.org/yt_analysis/yt-3.0/commits/784c1947f61e/
Changeset: 784c1947f61e
Branch: yt-3.0
User: ngoldbaum
Date: 2013-09-28 23:15:53
Summary: Merged in MatthewTurk/yt-3.0 (pull request #99)
Implement Gadget HDF5 and some helpful things for non-cosmo gadget datasets
Affected #: 5 files
diff -r 2404bce41fc387fd35cc4c22203373ef8bef418e -r 784c1947f61e7b47b5ffcc871a8a22971d1525c7 yt/frontends/sph/api.py
--- a/yt/frontends/sph/api.py
+++ b/yt/frontends/sph/api.py
@@ -17,6 +17,7 @@
from .data_structures import \
OWLSStaticOutput, \
GadgetStaticOutput, \
+ GadgetHDF5StaticOutput, \
TipsyStaticOutput
from .io import \
diff -r 2404bce41fc387fd35cc4c22203373ef8bef418e -r 784c1947f61e7b47b5ffcc871a8a22971d1525c7 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -40,6 +40,8 @@
KnownOWLSFields, \
GadgetFieldInfo, \
KnownGadgetFields, \
+ GadgetHDF5FieldInfo, \
+ KnownGadgetHDF5Fields, \
TipsyFieldInfo, \
KnownTipsyFields
@@ -100,6 +102,8 @@
mpch['%shcm' % unit] = (mpch["%sh" % unit] *
(1 + self.current_redshift))
mpch['%scm' % unit] = mpch[unit] * (1 + self.current_redshift)
+ elif 'cmcm' in unit_base:
+ unit_base['cm'] = self.units['cm'] = unit_base.pop("cmcm")
# ud == unit destination
# ur == unit registry
for ud, ur in [(self.units, mpch), (self.time_units, sec_conversion)]:
@@ -142,22 +146,28 @@
def __init__(self, filename, data_style="gadget_binary",
additional_fields=(),
unit_base=None, n_ref=64,
- over_refine_factor=1):
+ over_refine_factor=1,
+ bounding_box = None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
self.storage_filename = None
if unit_base is not None and "UnitLength_in_cm" in unit_base:
# We assume this is comoving, because in the absence of comoving
# integration the redshift will be zero.
- unit_base['cmcm'] = unit_base["UnitLength_in_cm"]
+ unit_base['cmcm'] = 1.0 / unit_base["UnitLength_in_cm"]
self._unit_base = unit_base
+ if bounding_box is not None:
+ bbox = np.array(bounding_box, dtype="float64")
+ self.domain_left_edge = bbox[:,0]
+ self.domain_right_edge = bbox[:,1]
+ else:
+ self.domain_left_edge = self.domain_right_edge = None
super(GadgetStaticOutput, self).__init__(filename, data_style)
def __repr__(self):
return os.path.basename(self.parameter_filename).split(".")[0]
- def _parse_parameter_file(self):
-
+ def _get_hvals(self):
# The entries in this header are capitalized and named to match Table 4
# in the GADGET-2 user guide.
@@ -166,6 +176,11 @@
for i in hvals:
if len(hvals[i]) == 1:
hvals[i] = hvals[i][0]
+ return hvals
+
+ def _parse_parameter_file(self):
+
+ hvals = self._get_hvals()
self.dimensionality = 3
self.refine_by = 2
@@ -174,8 +189,10 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
- self.domain_left_edge = np.zeros(3, "float64")
- self.domain_right_edge = np.ones(3, "float64") * hvals["BoxSize"]
+ # We may have an overridden bounding box.
+ if self.domain_left_edge is None:
+ self.domain_left_edge = np.zeros(3, "float64")
+ self.domain_right_edge = np.ones(3, "float64") * hvals["BoxSize"]
nz = 1 << self.over_refine_factor
self.domain_dimensions = np.ones(3, "int32") * nz
self.periodicity = (True, True, True)
@@ -221,9 +238,10 @@
self.file_count = hvals["NumFiles"]
- f.close()
-
def _set_units(self):
+ if self._unit_base is None and self.cosmological_simulation == 1:
+ mylog.info("Assuming length units are in Mpc/h (comoving)")
+ self._unit_base = dict(mpchcm = 1.0)
super(GadgetStaticOutput, self)._set_units()
length_unit = self.units['cm']
unit_base = self._unit_base or {}
@@ -322,6 +340,43 @@
pass
return False
+class GadgetHDF5StaticOutput(GadgetStaticOutput):
+ _file_class = ParticleFile
+ _fieldinfo_fallback = GadgetHDF5FieldInfo
+ _fieldinfo_known = KnownGadgetHDF5Fields
+
+ def __init__(self, filename, data_style="gadget_hdf5",
+ unit_base = None, n_ref=64,
+ over_refine_factor=1,
+ bounding_box = None):
+ self.storage_filename = None
+ filename = os.path.abspath(filename)
+ super(GadgetHDF5StaticOutput, self).__init__(
+ filename, data_style, unit_base=unit_base, n_ref=n_ref,
+ over_refine_factor=over_refine_factor,
+ bounding_box = bounding_box)
+
+ def _get_hvals(self):
+ handle = h5py.File(self.parameter_filename, mode="r")
+ hvals = {}
+ hvals.update((str(k), v) for k, v in handle["/Header"].attrs.items())
+ # Compat reasons.
+ hvals["NumFiles"] = hvals["NumFilesPerSnapshot"]
+ hvals["Massarr"] = hvals["MassTable"]
+ return hvals
+
+ @classmethod
+ def _is_valid(self, *args, **kwargs):
+ try:
+ fileh = h5py.File(args[0], mode='r')
+ if "Constants" not in fileh["/"].keys() and \
+ "Header" in fileh["/"].keys():
+ fileh.close()
+ return True
+ fileh.close()
+ except:
+ pass
+ return False
class TipsyFile(ParticleFile):
diff -r 2404bce41fc387fd35cc4c22203373ef8bef418e -r 784c1947f61e7b47b5ffcc871a8a22971d1525c7 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -47,6 +47,9 @@
KnownGadgetFields = FieldInfoContainer()
add_gadget_field = KnownGadgetFields.add_field
+GadgetHDF5FieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
+KnownGadgetHDF5Fields = FieldInfoContainer()
+
TipsyFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
add_Tipsy_field = TipsyFieldInfo.add_field
@@ -98,55 +101,68 @@
# Among other things we need to set up Coordinates
+def _setup_gadget_fields(ptypes, field_registry, known_registry):
+
+ # This has to be done manually for Gadget, because some of the particles will
+ # have uniform mass
+ def _gadget_particle_fields(ptype):
+ def _Mass(field, data):
+ pind = ptypes.index(ptype)
+ if data.pf["Massarr"][pind] == 0.0:
+ return data[ptype, "Masses"].copy()
+ mass = np.ones(data[ptype, "ParticleIDs"].shape[0], dtype="float64")
+ # Note that this is an alias, which is why we need to apply conversion
+ # here. Otherwise we'd have an asymmetry.
+ mass *= data.pf["Massarr"][pind] * data.convert("mass")
+ return mass
+ field_registry.add_field((ptype, "Mass"), function=_Mass,
+ particle_type = True)
+
+ for fname in ["Coordinates", "Velocities", "ParticleIDs",
+ # Note: Mass, not Masses
+ "Mass"]:
+ func = _field_concat(fname)
+ field_registry.add_field(("all", fname), function=func,
+ particle_type = True)
+
+ for ptype in ptypes:
+ known_registry.add_field((ptype, "Masses"), function=NullFunc,
+ particle_type = True,
+ convert_function=_get_conv("mass"),
+ units = r"\mathrm{g}")
+ _gadget_particle_fields(ptype)
+ known_registry.add_field((ptype, "Velocities"), function=NullFunc,
+ particle_type = True,
+ convert_function=_get_conv("velocity"),
+ units = r"\mathrm{cm}/\mathrm{s}")
+ particle_deposition_functions(ptype, "Coordinates", "Mass", field_registry)
+ particle_scalar_functions(ptype, "Coordinates", "Velocities", field_registry)
+ known_registry.add_field((ptype, "Coordinates"), function=NullFunc,
+ particle_type = True)
+ particle_deposition_functions("all", "Coordinates", "Mass", field_registry)
+
+ # Now we have to manually apply the splits for "all", since we don't want to
+ # use the splits defined above.
+
+ for iname, oname in [("Coordinates", "particle_position_"),
+ ("Velocities", "particle_velocity_")]:
+ for axi, ax in enumerate("xyz"):
+ func = _field_concat_slice(iname, axi)
+ field_registry.add_field(("all", oname + ax), function=func,
+ particle_type = True)
+
+# Note that we call the same function a few times here.
_gadget_ptypes = ("Gas", "Halo", "Disk", "Bulge", "Stars", "Bndry")
+_ghdf5_ptypes = ("PartType0", "PartType1", "PartType2", "PartType3",
+ "PartType4", "PartType5")
-# This has to be done manually for Gadget, because some of the particles will
-# have uniform mass
-def _gadget_particle_fields(ptype):
- def _Mass(field, data):
- pind = _gadget_ptypes.index(ptype)
- if data.pf["Massarr"][pind] == 0.0:
- return data[ptype, "Masses"].copy()
- mass = np.ones(data[ptype, "ParticleIDs"].shape[0], dtype="float64")
- # Note that this is an alias, which is why we need to apply conversion
- # here. Otherwise we'd have an asymmetry.
- mass *= data.pf["Massarr"][pind] * data.convert("mass")
- return mass
- GadgetFieldInfo.add_field((ptype, "Mass"), function=_Mass,
- particle_type = True)
+_setup_gadget_fields(_gadget_ptypes,
+ GadgetFieldInfo,
+ KnownGadgetFields)
+_setup_gadget_fields(_ghdf5_ptypes,
+ GadgetHDF5FieldInfo,
+ KnownGadgetHDF5Fields)
-for fname in ["Coordinates", "Velocities", "ParticleIDs",
- # Note: Mass, not Masses
- "Mass"]:
- func = _field_concat(fname)
- GadgetFieldInfo.add_field(("all", fname), function=func,
- particle_type = True)
-
-for ptype in _gadget_ptypes:
- KnownGadgetFields.add_field((ptype, "Masses"), function=NullFunc,
- particle_type = True,
- convert_function=_get_conv("mass"),
- units = r"\mathrm{g}")
- _gadget_particle_fields(ptype)
- KnownGadgetFields.add_field((ptype, "Velocities"), function=NullFunc,
- particle_type = True,
- convert_function=_get_conv("velocity"),
- units = r"\mathrm{cm}/\mathrm{s}")
- particle_deposition_functions(ptype, "Coordinates", "Mass", GadgetFieldInfo)
- particle_scalar_functions(ptype, "Coordinates", "Velocities", GadgetFieldInfo)
- KnownGadgetFields.add_field((ptype, "Coordinates"), function=NullFunc,
- particle_type = True)
-particle_deposition_functions("all", "Coordinates", "Mass", GadgetFieldInfo)
-
-# Now we have to manually apply the splits for "all", since we don't want to
-# use the splits defined above.
-
-for iname, oname in [("Coordinates", "particle_position_"),
- ("Velocities", "particle_velocity_")]:
- for axi, ax in enumerate("xyz"):
- func = _field_concat_slice(iname, axi)
- GadgetFieldInfo.add_field(("all", oname + ax), function=func,
- particle_type = True)
# OWLS
# ====
@@ -155,7 +171,7 @@
# make OWLS a subclass of Gadget fields.
_owls_ptypes = ("PartType0", "PartType1", "PartType2", "PartType3",
- "PartType4")
+ "PartType4", "PartType5")
for fname in ["Coordinates", "Velocities", "ParticleIDs",
# Note: Mass, not Masses
diff -r 2404bce41fc387fd35cc4c22203373ef8bef418e -r 784c1947f61e7b47b5ffcc871a8a22971d1525c7 yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -134,6 +134,8 @@
f.close()
return fields
+class IOHandlerGadgetHDF5(IOHandlerOWLS):
+ _data_style = "gadget_hdf5"
ZeroMass = object()
diff -r 2404bce41fc387fd35cc4c22203373ef8bef418e -r 784c1947f61e7b47b5ffcc871a8a22971d1525c7 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -118,7 +118,8 @@
from yt.frontends.sph.api import \
OWLSStaticOutput, OWLSFieldInfo, add_owls_field, \
- GadgetStaticOutput, GadgetFieldInfo, add_gadget_field, \
+ GadgetStaticOutput, GadgetHDF5StaticOutput, \
+ GadgetFieldInfo, add_gadget_field, \
TipsyStaticOutput, TipsyFieldInfo, add_tipsy_field
from yt.analysis_modules.list_modules import \
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
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