[yt-svn] commit/yt: ngoldbaum: Merged in hegan/yt (pull request #1164)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 2 16:00:19 PDT 2014
1 new commit in yt:
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