[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat May 17 08:43:47 PDT 2014


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/648617ea0d27/
Changeset:   648617ea0d27
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-16 23:21:17
Summary:     Enabling libconfig for Enzo
Affected #:  4 files

diff -r 54e87aca90a647aa2a7dceb8d74056884b936de3 -r 648617ea0d27a09a6aaf9eef05a422b787802d08 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -44,6 +44,7 @@
     rho_crit_g_cm3_h2, cm_per_mpc
 from yt.utilities.io_handler import io_registry
 from yt.utilities.logger import ytLogger as mylog
+from yt.utilities.pyparselibconfig import libconfig
 
 from .fields import \
     EnzoFieldInfo
@@ -277,11 +278,19 @@
         si, ei, LE, RE, fn, npart = [], [], [], [], [], []
         all = [si, ei, LE, RE, fn]
         pbar = get_pbar("Parsing Hierarchy ", self.num_grids)
-        if self.parameter_file.parameters["VersionNumber"] > 2.0:
+        version = self.parameter_file.parameters.get("VersionNumber", None)
+        params = self.parameter_file.parameters
+        if version is None and "Internal" in params:
+            version = float(params["Internal"]["Provenance"]["VersionNumber"])
+        if version == 2.0:
             active_particles = True
             nap = {}
             for type in self.parameters.get("AppendActiveParticleType", []):
                 nap[type] = []
+        elif version >= 3.0:
+            active_particles = True
+            nap = dict((ap_type, []) for ap_type in 
+                params["Physics"]["ActiveParticles"]["ActiveParticlesEnabled"])
         else:
             active_particles = False
             nap = None
@@ -731,10 +740,53 @@
         # Let's read the file
         self.unique_identifier = \
             int(os.stat(self.parameter_filename)[stat.ST_CTIME])
-        data_labels = {}
-        data_label_factors = {}
-        conversion_factors = {}
-        for line in (l.strip() for l in open(self.parameter_filename)):
+        with open(self.parameter_filename, "r") as f:
+            line = f.readline().strip() 
+            f.seek(0)
+            if line == "Internal:":
+                self._parse_enzo3_parameter_file(f)
+            else:
+                self._parse_enzo2_parameter_file(f)
+
+    def _parse_enzo3_parameter_file(self, f):
+        self.parameters = p = libconfig(f)
+        sim = p["SimulationControl"]
+        internal = p["Internal"]
+        phys = p["Physics"]
+        self.refine_by = sim["AMR"]["RefineBy"]
+        self.periodicity = tuple(a == 3 for a in
+                            sim["Domain"]["LeftFaceBoundaryCondition"])
+        self.dimensionality = sim["Domain"]["TopGridRank"]
+        self.domain_dimensions = np.array(sim["Domain"]["TopGridDimensions"],
+                                          dtype="int64")
+        self.domain_left_edge = np.array(sim["Domain"]["DomainLeftEdge"],
+                                         dtype="float64")
+        self.domain_right_edge = np.array(sim["Domain"]["DomainRightEdge"],
+                                          dtype="float64")
+        self.gamma = phys["Hydro"]["Gamma"]
+        self.unique_identifier = internal["Provenance"]["CurrentTimeIdentifier"]
+        self.current_time = internal["InitialTime"]
+        self.cosmological_simulation = phys["Cosmology"]["ComovingCoordinates"]
+        if self.cosmological_simulation == 1:
+            cosmo = phys["Cosmology"]
+            self.current_redshift = internal["CosmologyCurrentRedshift"]
+            self.omega_lambda = cosmo["OmegaLambdaNow"]
+            self.omega_matter = cosmo["OmegaMatterNow"]
+            self.hubble_constant = cosmo["HubbleConstantNow"]
+        else:
+            self.current_redshift = self.omega_lambda = self.omega_matter = \
+                self.hubble_constant = self.cosmological_simulation = 0.0
+        self.particle_types = ["DarkMatter"] + \
+            phys["ActiveParticles"]["ActiveParticlesEnabled"]
+        self.particle_types = tuple(self.particle_types)
+        self.particle_types_raw = self.particle_types
+        if self.dimensionality == 1:
+            self._setup_1d()
+        elif self.dimensionality == 2:
+            self._setup_2d()
+
+    def _parse_enzo2_parameter_file(self, f):
+        for line in (l.strip() for l in f):
             if len(line) < 2: continue
             param, vals = (i.strip() for i in line.split("=",1))
             # First we try to decipher what type of value it is.

diff -r 54e87aca90a647aa2a7dceb8d74056884b936de3 -r 648617ea0d27a09a6aaf9eef05a422b787802d08 yt/frontends/enzo/fields.py
--- a/yt/frontends/enzo/fields.py
+++ b/yt/frontends/enzo/fields.py
@@ -96,7 +96,10 @@
     )
 
     def __init__(self, pf, field_list):
-        if pf.parameters["HydroMethod"] == 2:
+        hydro_method = pf.parameters.get("HydroMethod", None)
+        if hydro_method is None:
+            hydro_method = pf.parameters["Physics"]["Hydro"]["HydroMethod"]
+        if hydro_method == 2:
             sl_left = slice(None,-2,None)
             sl_right = slice(1,-1,None)
             div_fac = 1.0
@@ -142,7 +145,11 @@
 
     def setup_fluid_fields(self):
         # Now we conditionally load a few other things.
-        if self.pf.parameters["MultiSpecies"] > 0:
+        params = self.pf.parameters
+        multi_species = params.get("MultiSpecies", None)
+        if multi_species is None:
+            multi_species = params["Physics"]["AtomicPhysics"]["MultiSpecies"]
+        if multi_species > 0:
             self.setup_species_fields()
         self.setup_energy_field()
 
@@ -150,6 +157,16 @@
         # We check which type of field we need, and then we add it.
         ge_name = None
         te_name = None
+        params = self.pf.parameters
+        multi_species = params.get("MultiSpecies", None)
+        if multi_species is None:
+            multi_species = params["Physics"]["AtomicPhysics"]["MultiSpecies"]
+        hydro_method = params.get("HydroMethod", None)
+        if hydro_method is None:
+            hydro_method = params["Physics"]["Hydro"]["HydroMethod"]
+        dual_energy = params.get("DualEnergyFormalism", None)
+        if dual_energy is None:
+            dual_energy = params["Physics"]["Hydro"]["DualEnergyFormalism"]
         if ("enzo", "Gas_Energy") in self.field_list:
             ge_name = "Gas_Energy"
         elif ("enzo", "GasEnergy") in self.field_list:
@@ -159,12 +176,12 @@
         elif ("enzo", "TotalEnergy") in self.field_list:
             te_name = "TotalEnergy"
 
-        if self.pf.parameters["HydroMethod"] == 2:
+        if hydro_method == 2:
             self.add_output_field(("enzo", te_name),
                 units="code_velocity**2")
             self.alias(("gas", "thermal_energy"), ("enzo", te_name))
 
-        elif self.pf.parameters["DualEnergyFormalism"] == 1:
+        elif dual_energy == 1:
             self.add_output_field(
                 ("enzo", ge_name),
                 units="code_velocity**2")
@@ -172,7 +189,7 @@
                 ("gas", "thermal_energy"),
                 ("enzo", ge_name),
                 units = "erg/g")
-        elif self.pf.parameters["HydroMethod"] in (4, 6):
+        elif hydro_method in (4, 6):
             self.add_output_field(
                 ("enzo", te_name),
                 units="code_velocity**2")

diff -r 54e87aca90a647aa2a7dceb8d74056884b936de3 -r 648617ea0d27a09a6aaf9eef05a422b787802d08 yt/utilities/pyparselibconfig/libconfig.py
--- a/yt/utilities/pyparselibconfig/libconfig.py
+++ b/yt/utilities/pyparselibconfig/libconfig.py
@@ -13,11 +13,13 @@
             self.read(config)
 
     def read(self, config):
-        cfile = open(config, 'r')
-        lines = cfile.readlines()
+        if not hasattr(config, "read"):
+            cfile = open(config, 'r')
+        else:
+            cfile = config
 
         # Strip out spaces and blanks
-        lines = [line.strip() for line in lines if len(line) > 0]
+        lines = [line.strip() for line in cfile if len(line) > 0]
 
         # Strip out comments
         lines = [line for line in lines if not (line.startswith('#') or
@@ -63,6 +65,11 @@
                 this_dict[k] = self.correct_type(v)
 
     def correct_type(self, v):
+        if v == "true":
+            v = "True"
+        elif v == "false":
+            v = "False"
+        # ...are we really evaling this?  We should work around that somehow.
         return eval(v)
 
     def write(self, filename):

diff -r 54e87aca90a647aa2a7dceb8d74056884b936de3 -r 648617ea0d27a09a6aaf9eef05a422b787802d08 yt/utilities/setup.py
--- a/yt/utilities/setup.py
+++ b/yt/utilities/setup.py
@@ -163,6 +163,7 @@
                          "yt/utilities/data_point_utilities.c",
                          libraries=["m"])
     config.add_subpackage("tests")
+    config.add_subpackage("pyparselibconfig")
     config.make_config_py()  # installs __config__.py
     # config.make_svn_version_py()
     return config


https://bitbucket.org/yt_analysis/yt/commits/8715c3be62cc/
Changeset:   8715c3be62cc
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-16 23:30:22
Summary:     Adding unit support for newconfig
Affected #:  1 file

diff -r 648617ea0d27a09a6aaf9eef05a422b787802d08 -r 8715c3be62cc69342e1f56fea3dc1c04241532c8 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -887,8 +887,11 @@
         if self.cosmological_simulation:
             k = self.cosmology_get_units()
             # Now some CGS values
-            self.length_unit = \
-                self.quan(self.parameters["CosmologyComovingBoxSize"], "Mpccm/h")
+            box_size = self.parameters.get("CosmologyComovingBoxSize", None)
+            if box_size is None:
+                box_size = self.parameters["Physics"]["Cosmology"]\
+                    ["CosmologyComovingBoxSize"]
+            self.length_unit = self.quan(box_size, "Mpccm/h")
             self.mass_unit = \
                 self.quan(k['urho'], 'g/cm**3') * (self.length_unit.in_cgs())**3
             self.time_unit = self.quan(k['utim'], 's')
@@ -898,6 +901,11 @@
                 length_unit = self.parameters["LengthUnits"]
                 mass_unit = self.parameters["DensityUnits"] * length_unit**3
                 time_unit = self.parameters["TimeUnits"]
+            elif "SimulationControl" in self.parameters:
+                units = self.parameters["SimulationControl"]["Units"]
+                length_unit = units["Length"]
+                mass_unit = units["Density"] * length_unit**3
+                time_unit = units["Time"]
             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")


https://bitbucket.org/yt_analysis/yt/commits/88056872e1bd/
Changeset:   88056872e1bd
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-17 16:38:15
Summary:     Fixing active_particle detection for new datasets.
Affected #:  1 file

diff -r 8715c3be62cc69342e1f56fea3dc1c04241532c8 -r 88056872e1bd42b4a657201277526e5e0d67a8ac yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -282,15 +282,15 @@
         params = self.parameter_file.parameters
         if version is None and "Internal" in params:
             version = float(params["Internal"]["Provenance"]["VersionNumber"])
-        if version == 2.0:
+        if version >= 3.0:
+            active_particles = True
+            nap = dict((ap_type, []) for ap_type in 
+                params["Physics"]["ActiveParticles"]["ActiveParticlesEnabled"])
+        elif version > 2.0:
             active_particles = True
             nap = {}
             for type in self.parameters.get("AppendActiveParticleType", []):
                 nap[type] = []
-        elif version >= 3.0:
-            active_particles = True
-            nap = dict((ap_type, []) for ap_type in 
-                params["Physics"]["ActiveParticles"]["ActiveParticlesEnabled"])
         else:
             active_particles = False
             nap = None

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