[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 2 16:00:18 PDT 2014
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/3b1e247bb96f/
Changeset: 3b1e247bb96f
Branch: yt
User: hegan
Date: 2014-08-23 00:38:26
Summary: eagle is working but needs to be cleaned up probably
Affected #: 5 files
diff -r c0b0a189ee4735df3766eb76048180063142eb90 -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d yt/frontends/sph/api.py
--- a/yt/frontends/sph/api.py
+++ b/yt/frontends/sph/api.py
@@ -18,12 +18,15 @@
OWLSDataset, \
GadgetDataset, \
GadgetHDF5Dataset, \
- TipsyDataset
+ TipsyDataset,\
+ EagleDataset
from .io import \
IOHandlerOWLS, \
- IOHandlerGadgetBinary
+ IOHandlerGadgetBinary,\
+ IOHandlerEagle
from .fields import \
SPHFieldInfo, \
- TipsyFieldInfo
+ TipsyFieldInfo,\
+ EagleFieldInfo
diff -r c0b0a189ee4735df3766eb76048180063142eb90 -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d 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, TipsyFieldInfo
+ SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo, EagleFieldInfo
from .definitions import \
gadget_header_specs, \
gadget_field_specs, \
@@ -292,10 +292,9 @@
pass
return False
-class OWLSDataset(GadgetHDF5Dataset):
+class EagleDataset(GadgetHDF5Dataset):
_particle_mass_name = "Mass"
- _field_info_class = OWLSFieldInfo
-
+ _field_info_class = EagleFieldInfo
def _parse_parameter_file(self):
@@ -312,7 +311,7 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
- self.current_time = hvals["Time_GYR"] * sec_conversion["Gyr"]
+ self.current_time = hvals["Time"] * sec_conversion["Gyr"]
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"]
@@ -346,7 +345,71 @@
fileh = h5py.File(args[0], mode='r')
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
- "SUBFIND" not in fileh["/"].keys():
+ "SUBFIND" not in fileh["/"].keys() and \
+ fileh["Config"].attrs['Config_option_019']=='EAGLE ':
+ fileh.close()
+ return True
+ fileh.close()
+ except:
+ pass
+ return False
+
+class OWLSDataset(GadgetHDF5Dataset):
+ _particle_mass_name = "Mass"
+ _field_info_class = OWLSFieldInfo
+
+
+
+ def _parse_parameter_file(self):
+ handle = h5py.File(self.parameter_filename, mode="r")
+ hvals = {}
+ hvals.update((str(k), v) for k, v in handle["/Header"].attrs.items())
+ hvals["NumFiles"] = hvals["NumFilesPerSnapshot"]
+ hvals["Massarr"] = hvals["MassTable"]
+
+ self.dimensionality = 3
+ self.refine_by = 2
+ self.parameters["HydroMethod"] = "sph"
+ self.unique_identifier = \
+ int(os.stat(self.parameter_filename)[stat.ST_CTIME])
+
+ # Set standard values
+ #self.current_time = hvals["Time_GYR"] * sec_conversion["Gyr"]
+ self.current_time = hvals["Time"] * sec_conversion["Gyr"]
+ 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.cosmological_simulation = 1
+ self.periodicity = (True, True, True)
+ self.current_redshift = hvals["Redshift"]
+ self.omega_lambda = hvals["OmegaLambda"]
+ self.omega_matter = hvals["Omega0"]
+ self.hubble_constant = hvals["HubbleParam"]
+ self.parameters = hvals
+
+ prefix = os.path.abspath(self.parameter_filename.split(".", 1)[0])
+ suffix = self.parameter_filename.rsplit(".", 1)[-1]
+ self.filename_template = "%s.%%(num)i.%s" % (prefix, suffix)
+ self.file_count = hvals["NumFilesPerSnapshot"]
+
+ # To avoid having to open files twice
+ self._unit_base = {}
+ self._unit_base.update(
+ (str(k), v) for k, v in handle["/Units"].attrs.items())
+ # Comoving cm is given in the Units
+ self._unit_base['cmcm'] = 1.0 / self._unit_base["UnitLength_in_cm"]
+
+ handle.close()
+
+ @classmethod
+ def _is_valid(self, *args, **kwargs):
+ try:
+ fileh = h5py.File(args[0], mode='r')
+ if "Constants" in fileh["/"].keys() and \
+ "Header" in fileh["/"].keys() and \
+ "SUBFIND" not in fileh["/"].keys() and False:
fileh.close()
return True
fileh.close()
diff -r c0b0a189ee4735df3766eb76048180063142eb90 -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d yt/frontends/sph/definitions.py
--- a/yt/frontends/sph/definitions.py
+++ b/yt/frontends/sph/definitions.py
@@ -56,3 +56,24 @@
("SmoothingLength", "Gas"),
)
)
+
+
+eagle_ions = \
+ ('electron', 'H1', 'H2', 'H_m', 'He1', 'He2','He3', 'C1',\
+ 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C_m', 'N1', 'N2', \
+ 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'O1', 'O2', 'O3', \
+ 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'O_m', 'Ne1', 'Ne2',\
+ 'Ne3', 'Ne4', 'Ne5', 'Ne6', 'Ne7', 'Ne8', 'Ne9', 'Ne10',\
+ 'Ne11', 'Mg1', 'Mg2', 'Mg3', 'Mg4', 'Mg5', 'Mg6', 'Mg7',\
+ 'Mg8', 'Mg9', 'Mg10', 'Mg11', 'Mg12', 'Mg13', 'Si1', 'Si2',\
+ 'Si3', 'Si4', 'Si5', 'Si6', 'Si7', 'Si8', 'Si9', 'Si10',\
+ 'Si11', 'Si12', 'Si13', 'Si14', 'Si15', 'Si16', 'Si17',\
+ 'Ca1', 'Ca2', 'Ca3', 'Ca4', 'Ca5', 'Ca6', 'Ca7', 'Ca8',\
+ 'Ca9', 'Ca10', 'Ca11', 'Ca12', 'Ca13', 'Ca14', 'Ca15',\
+ 'Ca16', 'Ca17', 'Ca18', 'Ca19', 'Ca20', 'Ca21', 'Fe1',\
+ 'Fe2', 'Fe3', 'Fe4', 'Fe5', 'Fe6', 'Fe7', 'Fe8', 'Fe9',\
+ 'Fe10', 'Fe11', 'Fe12', 'Fe13', 'Fe14', 'Fe15', 'Fe16',\
+ 'Fe17', 'Fe18', 'Fe19', 'Fe20', 'Fe21', 'Fe22', 'Fe23',\
+ 'Fe24', 'Fe25', 'Fe25', 'Fe27',)
+
+eagle_ion_lookup = {ion:index for index, ion in enumerate(eagle_ions)}
diff -r c0b0a189ee4735df3766eb76048180063142eb90 -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -25,10 +25,13 @@
from .definitions import \
gadget_ptypes, \
- ghdf5_ptypes
+ ghdf5_ptypes,\
+ eagle_ion_lookup
+from yt.units.yt_array import YTQuantity
from yt.config import ytcfg
from yt.utilities.physical_constants import mh
+from yt.utilities.periodic_table import periodic_table
from yt.fields.species_fields import \
add_species_field_by_fraction, \
add_species_field_by_density, \
@@ -192,6 +195,8 @@
ftype='star'
elif ptype == 'all':
ftype='all'
+ else:
+ ftype='?'
super(OWLSFieldInfo,self).setup_particle_fields(
ptype, num_neighbors=self._num_neighbors, ftype=ftype)
@@ -408,3 +413,54 @@
raise RuntimeError, "Failed to download owls ion data."
return owls_ion_path
+
+
+class EagleFieldInfo(OWLSFieldInfo):
+
+ _ions = \
+ ('H1', 'H2', 'He1', 'He2','He3', 'C1',\
+ 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'N1', 'N2', \
+ 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'O1', 'O2', 'O3', \
+ 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'Ne1', 'Ne2',\
+ 'Ne3', 'Ne4', 'Ne5', 'Ne6', 'Ne7', 'Ne8', 'Ne9', 'Ne10',\
+ 'Ne11', 'Mg1', 'Mg2', 'Mg3', 'Mg4', 'Mg5', 'Mg6', 'Mg7',\
+ 'Mg8', 'Mg9', 'Mg10', 'Mg11', 'Mg12', 'Mg13', 'Si1', 'Si2',\
+ 'Si3', 'Si4', 'Si5', 'Si6', 'Si7', 'Si8', 'Si9', 'Si10',\
+ 'Si11', 'Si12', 'Si13', 'Si14', 'Si15', 'Si16', 'Si17',\
+ 'Ca1', 'Ca2', 'Ca3', 'Ca4', 'Ca5', 'Ca6', 'Ca7', 'Ca8',\
+ 'Ca9', 'Ca10', 'Ca11', 'Ca12', 'Ca13', 'Ca14', 'Ca15',\
+ 'Ca16', 'Ca17', 'Ca18', 'Ca19', 'Ca20', 'Ca21', 'Fe1',\
+ 'Fe2', 'Fe3', 'Fe4', 'Fe5', 'Fe6', 'Fe7', 'Fe8', 'Fe9',\
+ 'Fe10', 'Fe11', 'Fe12', 'Fe13', 'Fe14', 'Fe15', 'Fe16',\
+ 'Fe17', 'Fe18', 'Fe19', 'Fe20', 'Fe21', 'Fe22', 'Fe23',\
+ 'Fe24', 'Fe25', 'Fe25', 'Fe27',)
+
+ def __init__(self, *args, **kwargs):
+
+ super(EagleFieldInfo,self).__init__( *args, **kwargs )
+
+ def _create_ion_density_func( self, ftype, ion ):
+ """ returns a function that calculates the ion density of a particle.
+ """
+
+ def _ion_density(field, data):
+
+ # Lookup the index of the ion
+ index = eagle_ion_lookup[ion]
+
+ # Ion to hydrogen number density ratio
+ ion_chem = data[ftype, "Chemistry_%03i"%index]
+
+ # Mass of a single ion
+ if ion[0:2].isalpha():
+ symbol = ion[0:2].capitalize()
+ else:
+ symbol = ion[0:1].capitalize()
+ m_ion = YTQuantity(periodic_table.elements_by_symbol[symbol].weight, 'amu')
+
+ # hydrogen number density
+ n_H = data["PartType0", "H_number_density"]
+
+ return m_ion*ion_chem*n_H
+
+ return _ion_density
diff -r c0b0a189ee4735df3766eb76048180063142eb90 -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -116,6 +116,9 @@
elif field.startswith("Metallicity_"):
col = int(field.rsplit("_", 1)[-1])
data = g["Metallicity"][:,col][mask]
+ elif field.startswith("Chemistry_"):
+ col = int(field.rsplit("_", 1)[-1])
+ data = g["ChemistryAbundances"][:,col][mask]
else:
data = g[field][:][mask,...]
@@ -192,6 +195,9 @@
# Vector of metallicity
for i in range(g[k].shape[1]):
fields.append((ptype, "Metallicity_%02i" % i))
+ elif k == "ChemistryAbundances" and len(g[k].shape)>1:
+ for i in range(g[k].shape[1]):
+ fields.append((ptype, "Chemistry_%03i" % i))
else:
kk = k
if not hasattr(g[kk], "shape"): continue
@@ -201,6 +207,10 @@
f.close()
return fields, {}
+class IOHandlerEagle(IOHandlerOWLS):
+ _dataset_type = "eagle"
+ _vector_fields = ("Coordinates", "Velocity", "Velocities")
+
class IOHandlerGadgetHDF5(IOHandlerOWLS):
_dataset_type = "gadget_hdf5"
https://bitbucket.org/yt_analysis/yt/commits/fab9c05bba9c/
Changeset: fab9c05bba9c
Branch: yt
User: hegan
Date: 2014-08-23 00:46:35
Summary: Eagle working and changes cleaned up
Affected #: 2 files
diff -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d -r fab9c05bba9c21a959ab9e8c5f0f17adf96c270b yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -346,7 +346,7 @@
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
"SUBFIND" not in fileh["/"].keys() and \
- fileh["Config"].attrs['Config_option_019']=='EAGLE ':
+ "EAGLE " in fileh["Config"].attrs.values():
fileh.close()
return True
fileh.close()
@@ -409,7 +409,8 @@
fileh = h5py.File(args[0], mode='r')
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
- "SUBFIND" not in fileh["/"].keys() and False:
+ "SUBFIND" not in fileh["/"].keys() and \
+ "EAGLE " not in fileh["Config"].attrs.values():
fileh.close()
return True
fileh.close()
diff -r 3b1e247bb96f89b3ae813d76cd666d0fb35d141d -r fab9c05bba9c21a959ab9e8c5f0f17adf96c270b yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -209,7 +209,6 @@
class IOHandlerEagle(IOHandlerOWLS):
_dataset_type = "eagle"
- _vector_fields = ("Coordinates", "Velocity", "Velocities")
class IOHandlerGadgetHDF5(IOHandlerOWLS):
_dataset_type = "gadget_hdf5"
https://bitbucket.org/yt_analysis/yt/commits/f90568015405/
Changeset: f90568015405
Branch: yt
User: hegan
Date: 2014-08-23 00:49:43
Summary: merging
Affected #: 2 files
diff -r fab9c05bba9c21a959ab9e8c5f0f17adf96c270b -r f90568015405f9448b2ca0c8efa84f3b8660aeae yt/fields/cosmology_fields.py
--- a/yt/fields/cosmology_fields.py
+++ b/yt/fields/cosmology_fields.py
@@ -99,7 +99,7 @@
co = data.ds.cosmology
# critical_density(z) ~ omega_lambda + omega_matter * (1 + z)^3
# mean density(z) ~ omega_matter * (1 + z)^3
- return data[ftype, "density"] / data.ds.omega_matter / \
+ return data[ftype, "matter_density"] / data.ds.omega_matter / \
co.critical_density(0.0) / \
(1.0 + data.ds.current_redshift)**3
diff -r fab9c05bba9c21a959ab9e8c5f0f17adf96c270b -r f90568015405f9448b2ca0c8efa84f3b8660aeae yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -442,7 +442,7 @@
if child_mask[i, j, k] == 1 or this_level == 1:
mask[i, j, k] = self.select_cell(pos, dds)
total += mask[i, j, k]
- pos[2] += dds[1]
+ pos[2] += dds[2]
pos[1] += dds[1]
pos[0] += dds[0]
if total == 0: return None
https://bitbucket.org/yt_analysis/yt/commits/21b30181b0b6/
Changeset: 21b30181b0b6
Branch: yt
User: hegan
Date: 2014-08-23 01:17:39
Summary: Changing particle type definitions
Affected #: 1 file
diff -r f90568015405f9448b2ca0c8efa84f3b8660aeae -r 21b30181b0b6c0ec0a856b8473f59a0208414713 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -191,12 +191,16 @@
ftype='gas'
elif ptype == 'PartType1':
ftype='dm'
+ elif ptype == 'PartType2':
+ ftype='PartType2'
+ elif ptype == 'PartType3':
+ ftype='PartType3'
elif ptype == 'PartType4':
ftype='star'
+ elif ptype == 'PartType5':
+ ftype='BH'
elif ptype == 'all':
ftype='all'
- else:
- ftype='?'
super(OWLSFieldInfo,self).setup_particle_fields(
ptype, num_neighbors=self._num_neighbors, ftype=ftype)
https://bitbucket.org/yt_analysis/yt/commits/39c2dc2b3257/
Changeset: 39c2dc2b3257
Branch: yt
User: hegan
Date: 2014-08-29 19:36:31
Summary: streamlined OWLS/Eagle Datasets and Eagle->EagleNetwork
Affected #: 5 files
diff -r 21b30181b0b6c0ec0a856b8473f59a0208414713 -r 39c2dc2b32572e37c0bb19966d4aae8ee22ec726 yt/frontends/sph/api.py
--- a/yt/frontends/sph/api.py
+++ b/yt/frontends/sph/api.py
@@ -19,14 +19,14 @@
GadgetDataset, \
GadgetHDF5Dataset, \
TipsyDataset,\
- EagleDataset
+ EagleNetworkDataset
from .io import \
IOHandlerOWLS, \
IOHandlerGadgetBinary,\
- IOHandlerEagle
+ IOHandlerEagleNetwork
from .fields import \
SPHFieldInfo, \
TipsyFieldInfo,\
- EagleFieldInfo
+ EagleNetworkFieldInfo
diff -r 21b30181b0b6c0ec0a856b8473f59a0208414713 -r 39c2dc2b32572e37c0bb19966d4aae8ee22ec726 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, TipsyFieldInfo, EagleFieldInfo
+ SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo, EagleNetworkFieldInfo
from .definitions import \
gadget_header_specs, \
gadget_field_specs, \
@@ -292,9 +292,11 @@
pass
return False
-class EagleDataset(GadgetHDF5Dataset):
+class OWLSDataset(GadgetHDF5Dataset):
_particle_mass_name = "Mass"
- _field_info_class = EagleFieldInfo
+ _field_info_class = OWLSFieldInfo
+ _time_readin = "Time_GYR"
+
def _parse_parameter_file(self):
@@ -311,7 +313,7 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
- self.current_time = hvals["Time"] * sec_conversion["Gyr"]
+ self.current_time = hvals[self._time_readin] * sec_conversion["Gyr"]
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"]
@@ -345,8 +347,9 @@
fileh = h5py.File(args[0], mode='r')
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
- "SUBFIND" not in fileh["/"].keys() and \
- "EAGLE " in fileh["Config"].attrs.values():
+ "SUBFIND" not in fileh["/"].keys() and not\
+ ("ChemistryAbundances" in fileh["PartType0"].keys()
+ or "ChemicalAbundances" in fileh["PartType0"].keys()):
fileh.close()
return True
fileh.close()
@@ -354,54 +357,10 @@
pass
return False
-class OWLSDataset(GadgetHDF5Dataset):
+class EagleNetworkDataset(OWLSDataset):
_particle_mass_name = "Mass"
- _field_info_class = OWLSFieldInfo
-
-
-
- def _parse_parameter_file(self):
- handle = h5py.File(self.parameter_filename, mode="r")
- hvals = {}
- hvals.update((str(k), v) for k, v in handle["/Header"].attrs.items())
- hvals["NumFiles"] = hvals["NumFilesPerSnapshot"]
- hvals["Massarr"] = hvals["MassTable"]
-
- self.dimensionality = 3
- self.refine_by = 2
- self.parameters["HydroMethod"] = "sph"
- self.unique_identifier = \
- int(os.stat(self.parameter_filename)[stat.ST_CTIME])
-
- # Set standard values
- #self.current_time = hvals["Time_GYR"] * sec_conversion["Gyr"]
- self.current_time = hvals["Time"] * sec_conversion["Gyr"]
- 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.cosmological_simulation = 1
- self.periodicity = (True, True, True)
- self.current_redshift = hvals["Redshift"]
- self.omega_lambda = hvals["OmegaLambda"]
- self.omega_matter = hvals["Omega0"]
- self.hubble_constant = hvals["HubbleParam"]
- self.parameters = hvals
-
- prefix = os.path.abspath(self.parameter_filename.split(".", 1)[0])
- suffix = self.parameter_filename.rsplit(".", 1)[-1]
- self.filename_template = "%s.%%(num)i.%s" % (prefix, suffix)
- self.file_count = hvals["NumFilesPerSnapshot"]
-
- # To avoid having to open files twice
- self._unit_base = {}
- self._unit_base.update(
- (str(k), v) for k, v in handle["/Units"].attrs.items())
- # Comoving cm is given in the Units
- self._unit_base['cmcm'] = 1.0 / self._unit_base["UnitLength_in_cm"]
-
- handle.close()
+ _field_info_class = EagleNetworkFieldInfo
+ _time_readin = 'Time'
@classmethod
def _is_valid(self, *args, **kwargs):
@@ -410,7 +369,8 @@
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
"SUBFIND" not in fileh["/"].keys() and \
- "EAGLE " not in fileh["Config"].attrs.values():
+ ("ChemistryAbundances" in fileh["PartType0"].keys()
+ or "ChemicalAbundances" in fileh["PartType0"].keys()):
fileh.close()
return True
fileh.close()
diff -r 21b30181b0b6c0ec0a856b8473f59a0208414713 -r 39c2dc2b32572e37c0bb19966d4aae8ee22ec726 yt/frontends/sph/definitions.py
--- a/yt/frontends/sph/definitions.py
+++ b/yt/frontends/sph/definitions.py
@@ -58,7 +58,7 @@
)
-eagle_ions = \
+eaglenetwork_ions = \
('electron', 'H1', 'H2', 'H_m', 'He1', 'He2','He3', 'C1',\
'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C_m', 'N1', 'N2', \
'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'O1', 'O2', 'O3', \
@@ -76,4 +76,4 @@
'Fe17', 'Fe18', 'Fe19', 'Fe20', 'Fe21', 'Fe22', 'Fe23',\
'Fe24', 'Fe25', 'Fe25', 'Fe27',)
-eagle_ion_lookup = {ion:index for index, ion in enumerate(eagle_ions)}
+eaglenetwork_ion_lookup = {ion:index for index, ion in enumerate(eaglenetwork_ions)}
diff -r 21b30181b0b6c0ec0a856b8473f59a0208414713 -r 39c2dc2b32572e37c0bb19966d4aae8ee22ec726 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -26,7 +26,7 @@
from .definitions import \
gadget_ptypes, \
ghdf5_ptypes,\
- eagle_ion_lookup
+ eaglenetwork_ion_lookup
from yt.units.yt_array import YTQuantity
from yt.config import ytcfg
@@ -419,7 +419,7 @@
return owls_ion_path
-class EagleFieldInfo(OWLSFieldInfo):
+class EagleNetworkFieldInfo(OWLSFieldInfo):
_ions = \
('H1', 'H2', 'He1', 'He2','He3', 'C1',\
@@ -441,7 +441,7 @@
def __init__(self, *args, **kwargs):
- super(EagleFieldInfo,self).__init__( *args, **kwargs )
+ super(EagleNetworkFieldInfo,self).__init__( *args, **kwargs )
def _create_ion_density_func( self, ftype, ion ):
""" returns a function that calculates the ion density of a particle.
@@ -450,7 +450,7 @@
def _ion_density(field, data):
# Lookup the index of the ion
- index = eagle_ion_lookup[ion]
+ index = eaglenetwork_ion_lookup[ion]
# Ion to hydrogen number density ratio
ion_chem = data[ftype, "Chemistry_%03i"%index]
diff -r 21b30181b0b6c0ec0a856b8473f59a0208414713 -r 39c2dc2b32572e37c0bb19966d4aae8ee22ec726 yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -207,8 +207,8 @@
f.close()
return fields, {}
-class IOHandlerEagle(IOHandlerOWLS):
- _dataset_type = "eagle"
+class IOHandlerEagleNetwork(IOHandlerOWLS):
+ _dataset_type = "eagle_network"
class IOHandlerGadgetHDF5(IOHandlerOWLS):
_dataset_type = "gadget_hdf5"
https://bitbucket.org/yt_analysis/yt/commits/99232fd7d61d/
Changeset: 99232fd7d61d
Branch: yt
User: ngoldbaum
Date: 2014-09-03 01:00:07
Summary: Merged in hegan/yt (pull request #1164)
Eagle Frontend
Affected #: 5 files
diff -r 0e8cce58116d6de321400d39ed6319396b95254b -r 99232fd7d61dac91f4d2e5bbc368559be178883e yt/frontends/sph/api.py
--- a/yt/frontends/sph/api.py
+++ b/yt/frontends/sph/api.py
@@ -18,12 +18,15 @@
OWLSDataset, \
GadgetDataset, \
GadgetHDF5Dataset, \
- TipsyDataset
+ TipsyDataset,\
+ EagleNetworkDataset
from .io import \
IOHandlerOWLS, \
- IOHandlerGadgetBinary
+ IOHandlerGadgetBinary,\
+ IOHandlerEagleNetwork
from .fields import \
SPHFieldInfo, \
- TipsyFieldInfo
+ TipsyFieldInfo,\
+ EagleNetworkFieldInfo
diff -r 0e8cce58116d6de321400d39ed6319396b95254b -r 99232fd7d61dac91f4d2e5bbc368559be178883e 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, TipsyFieldInfo
+ SPHFieldInfo, OWLSFieldInfo, TipsyFieldInfo, EagleNetworkFieldInfo
from .definitions import \
gadget_header_specs, \
gadget_field_specs, \
@@ -295,6 +295,7 @@
class OWLSDataset(GadgetHDF5Dataset):
_particle_mass_name = "Mass"
_field_info_class = OWLSFieldInfo
+ _time_readin = "Time_GYR"
@@ -312,7 +313,7 @@
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
# Set standard values
- self.current_time = hvals["Time_GYR"] * sec_conversion["Gyr"]
+ self.current_time = hvals[self._time_readin] * sec_conversion["Gyr"]
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"]
@@ -346,7 +347,30 @@
fileh = h5py.File(args[0], mode='r')
if "Constants" in fileh["/"].keys() and \
"Header" in fileh["/"].keys() and \
- "SUBFIND" not in fileh["/"].keys():
+ "SUBFIND" not in fileh["/"].keys() and not\
+ ("ChemistryAbundances" in fileh["PartType0"].keys()
+ or "ChemicalAbundances" in fileh["PartType0"].keys()):
+ fileh.close()
+ return True
+ fileh.close()
+ except:
+ pass
+ return False
+
+class EagleNetworkDataset(OWLSDataset):
+ _particle_mass_name = "Mass"
+ _field_info_class = EagleNetworkFieldInfo
+ _time_readin = 'Time'
+
+ @classmethod
+ def _is_valid(self, *args, **kwargs):
+ try:
+ fileh = h5py.File(args[0], mode='r')
+ if "Constants" in fileh["/"].keys() and \
+ "Header" in fileh["/"].keys() and \
+ "SUBFIND" not in fileh["/"].keys() and \
+ ("ChemistryAbundances" in fileh["PartType0"].keys()
+ or "ChemicalAbundances" in fileh["PartType0"].keys()):
fileh.close()
return True
fileh.close()
diff -r 0e8cce58116d6de321400d39ed6319396b95254b -r 99232fd7d61dac91f4d2e5bbc368559be178883e yt/frontends/sph/definitions.py
--- a/yt/frontends/sph/definitions.py
+++ b/yt/frontends/sph/definitions.py
@@ -56,3 +56,24 @@
("SmoothingLength", "Gas"),
)
)
+
+
+eaglenetwork_ions = \
+ ('electron', 'H1', 'H2', 'H_m', 'He1', 'He2','He3', 'C1',\
+ 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C_m', 'N1', 'N2', \
+ 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'O1', 'O2', 'O3', \
+ 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'O_m', 'Ne1', 'Ne2',\
+ 'Ne3', 'Ne4', 'Ne5', 'Ne6', 'Ne7', 'Ne8', 'Ne9', 'Ne10',\
+ 'Ne11', 'Mg1', 'Mg2', 'Mg3', 'Mg4', 'Mg5', 'Mg6', 'Mg7',\
+ 'Mg8', 'Mg9', 'Mg10', 'Mg11', 'Mg12', 'Mg13', 'Si1', 'Si2',\
+ 'Si3', 'Si4', 'Si5', 'Si6', 'Si7', 'Si8', 'Si9', 'Si10',\
+ 'Si11', 'Si12', 'Si13', 'Si14', 'Si15', 'Si16', 'Si17',\
+ 'Ca1', 'Ca2', 'Ca3', 'Ca4', 'Ca5', 'Ca6', 'Ca7', 'Ca8',\
+ 'Ca9', 'Ca10', 'Ca11', 'Ca12', 'Ca13', 'Ca14', 'Ca15',\
+ 'Ca16', 'Ca17', 'Ca18', 'Ca19', 'Ca20', 'Ca21', 'Fe1',\
+ 'Fe2', 'Fe3', 'Fe4', 'Fe5', 'Fe6', 'Fe7', 'Fe8', 'Fe9',\
+ 'Fe10', 'Fe11', 'Fe12', 'Fe13', 'Fe14', 'Fe15', 'Fe16',\
+ 'Fe17', 'Fe18', 'Fe19', 'Fe20', 'Fe21', 'Fe22', 'Fe23',\
+ 'Fe24', 'Fe25', 'Fe25', 'Fe27',)
+
+eaglenetwork_ion_lookup = {ion:index for index, ion in enumerate(eaglenetwork_ions)}
diff -r 0e8cce58116d6de321400d39ed6319396b95254b -r 99232fd7d61dac91f4d2e5bbc368559be178883e yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -25,10 +25,13 @@
from .definitions import \
gadget_ptypes, \
- ghdf5_ptypes
+ ghdf5_ptypes,\
+ eaglenetwork_ion_lookup
+from yt.units.yt_array import YTQuantity
from yt.config import ytcfg
from yt.utilities.physical_constants import mh
+from yt.utilities.periodic_table import periodic_table
from yt.fields.species_fields import \
add_species_field_by_fraction, \
add_species_field_by_density, \
@@ -188,8 +191,14 @@
ftype='gas'
elif ptype == 'PartType1':
ftype='dm'
+ elif ptype == 'PartType2':
+ ftype='PartType2'
+ elif ptype == 'PartType3':
+ ftype='PartType3'
elif ptype == 'PartType4':
ftype='star'
+ elif ptype == 'PartType5':
+ ftype='BH'
elif ptype == 'all':
ftype='all'
@@ -408,3 +417,54 @@
raise RuntimeError, "Failed to download owls ion data."
return owls_ion_path
+
+
+class EagleNetworkFieldInfo(OWLSFieldInfo):
+
+ _ions = \
+ ('H1', 'H2', 'He1', 'He2','He3', 'C1',\
+ 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'N1', 'N2', \
+ 'N3', 'N4', 'N5', 'N6', 'N7', 'N8', 'O1', 'O2', 'O3', \
+ 'O4', 'O5', 'O6', 'O7', 'O8', 'O9', 'Ne1', 'Ne2',\
+ 'Ne3', 'Ne4', 'Ne5', 'Ne6', 'Ne7', 'Ne8', 'Ne9', 'Ne10',\
+ 'Ne11', 'Mg1', 'Mg2', 'Mg3', 'Mg4', 'Mg5', 'Mg6', 'Mg7',\
+ 'Mg8', 'Mg9', 'Mg10', 'Mg11', 'Mg12', 'Mg13', 'Si1', 'Si2',\
+ 'Si3', 'Si4', 'Si5', 'Si6', 'Si7', 'Si8', 'Si9', 'Si10',\
+ 'Si11', 'Si12', 'Si13', 'Si14', 'Si15', 'Si16', 'Si17',\
+ 'Ca1', 'Ca2', 'Ca3', 'Ca4', 'Ca5', 'Ca6', 'Ca7', 'Ca8',\
+ 'Ca9', 'Ca10', 'Ca11', 'Ca12', 'Ca13', 'Ca14', 'Ca15',\
+ 'Ca16', 'Ca17', 'Ca18', 'Ca19', 'Ca20', 'Ca21', 'Fe1',\
+ 'Fe2', 'Fe3', 'Fe4', 'Fe5', 'Fe6', 'Fe7', 'Fe8', 'Fe9',\
+ 'Fe10', 'Fe11', 'Fe12', 'Fe13', 'Fe14', 'Fe15', 'Fe16',\
+ 'Fe17', 'Fe18', 'Fe19', 'Fe20', 'Fe21', 'Fe22', 'Fe23',\
+ 'Fe24', 'Fe25', 'Fe25', 'Fe27',)
+
+ def __init__(self, *args, **kwargs):
+
+ super(EagleNetworkFieldInfo,self).__init__( *args, **kwargs )
+
+ def _create_ion_density_func( self, ftype, ion ):
+ """ returns a function that calculates the ion density of a particle.
+ """
+
+ def _ion_density(field, data):
+
+ # Lookup the index of the ion
+ index = eaglenetwork_ion_lookup[ion]
+
+ # Ion to hydrogen number density ratio
+ ion_chem = data[ftype, "Chemistry_%03i"%index]
+
+ # Mass of a single ion
+ if ion[0:2].isalpha():
+ symbol = ion[0:2].capitalize()
+ else:
+ symbol = ion[0:1].capitalize()
+ m_ion = YTQuantity(periodic_table.elements_by_symbol[symbol].weight, 'amu')
+
+ # hydrogen number density
+ n_H = data["PartType0", "H_number_density"]
+
+ return m_ion*ion_chem*n_H
+
+ return _ion_density
diff -r 0e8cce58116d6de321400d39ed6319396b95254b -r 99232fd7d61dac91f4d2e5bbc368559be178883e yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -116,6 +116,9 @@
elif field.startswith("Metallicity_"):
col = int(field.rsplit("_", 1)[-1])
data = g["Metallicity"][:,col][mask]
+ elif field.startswith("Chemistry_"):
+ col = int(field.rsplit("_", 1)[-1])
+ data = g["ChemistryAbundances"][:,col][mask]
else:
data = g[field][:][mask,...]
@@ -192,6 +195,9 @@
# Vector of metallicity
for i in range(g[k].shape[1]):
fields.append((ptype, "Metallicity_%02i" % i))
+ elif k == "ChemistryAbundances" and len(g[k].shape)>1:
+ for i in range(g[k].shape[1]):
+ fields.append((ptype, "Chemistry_%03i" % i))
else:
kk = k
if not hasattr(g[kk], "shape"): continue
@@ -201,6 +207,9 @@
f.close()
return fields, {}
+class IOHandlerEagleNetwork(IOHandlerOWLS):
+ _dataset_type = "eagle_network"
+
class IOHandlerGadgetHDF5(IOHandlerOWLS):
_dataset_type = "gadget_hdf5"
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