[yt-svn] commit/yt: MatthewTurk: Merged in MatthewTurk/yt/yt-3.0 (pull request #810)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Apr 13 10:20:40 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/87fe2e111e03/
Changeset: 87fe2e111e03
Branch: yt-3.0
User: MatthewTurk
Date: 2014-04-13 19:20:30
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #810)
Updating Maestro frontend, with two quick fixes
Affected #: 4 files
diff -r cc6b873a4471e049b6fef33146e92615c72f1243 -r 87fe2e111e03663c6da6948be519c390ebd831d8 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -161,6 +161,8 @@
:class:`~yt.data_objects.api.DerivedField`.
"""
+ override = kwargs.pop("force_override", False)
+ if not override and name in self: return
if function is None:
def create_function(function):
self[name] = DerivedField(name, function, **kwargs)
diff -r cc6b873a4471e049b6fef33146e92615c72f1243 -r 87fe2e111e03663c6da6948be519c390ebd831d8 yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -45,7 +45,9 @@
cm_per_mpc
from .fields import \
- BoxlibFieldInfo
+ BoxlibFieldInfo, \
+ MaestroFieldInfo
+
from .io import IOHandlerBoxlib
# This is what we use to find scientific notation that might include d's
# instead of e's.
@@ -457,21 +459,7 @@
elif param == "castro.use_comoving":
vals = self.cosmological_simulation = int(vals)
else:
- # Now we guess some things about the parameter and its type
- v = vals.split()[0] # Just in case there are multiple; we'll go
- # back afterward to using vals.
- try:
- float(v.upper().replace("D","E"))
- except:
- pcast = str
- else:
- syms = (".", "D+", "D-", "E+", "E-")
- if any(sym in v.upper() for sym in syms for v in vals.split()):
- pcast = float
- else:
- pcast = int
- vals = [pcast(v) for v in vals.split()]
- if len(vals) == 1: vals = vals[0]
+ vals = _guess_pcast(vals)
self.parameters[param] = vals
if getattr(self, "cosmological_simulation", 0) == 1:
@@ -759,6 +747,8 @@
class MaestroDataset(BoxlibDataset):
+ _field_info_class = MaestroFieldInfo
+
@classmethod
def _is_valid(cls, *args, **kwargs):
# fill our args
@@ -775,6 +765,19 @@
if any("maestro" in line.lower() for line in lines): return True
return False
+ def _parse_parameter_file(self):
+ super(MaestroDataset, self)._parse_parameter_file()
+ jobinfo_filename = os.path.join(self.output_dir, "job_info")
+ line = ""
+ with open(jobinfo_filename, "r") as f:
+ while not line.startswith(" [*] indicates overridden default"):
+ line = f.next()
+ for line in f:
+ p, v = (_.strip() for _ in line[4:].split("="))
+ if len(v) == 0:
+ self.parameters[p] = ""
+ else:
+ self.parameters[p] = _guess_pcast(v)
class NyxHierarchy(BoxlibHierarchy):
@@ -871,3 +874,23 @@
self.length_unit = YTQuantity(1.0 / (1 + self.current_redshift),
"mpc")
self.velocity_unit = self.length_unit / self.time_unit
+
+def _guess_pcast(vals):
+ # Now we guess some things about the parameter and its type
+ v = vals.split()[0] # Just in case there are multiple; we'll go
+ # back afterward to using vals.
+ try:
+ float(v.upper().replace("D","E"))
+ except:
+ pcast = str
+ if v in ("F", "T"):
+ pcast = bool
+ else:
+ syms = (".", "D+", "D-", "E+", "E-")
+ if any(sym in v.upper() for sym in syms for v in vals.split()):
+ pcast = float
+ else:
+ pcast = int
+ vals = [pcast(v) for v in vals.split()]
+ if len(vals) == 1: vals = vals[0]
+ return vals
diff -r cc6b873a4471e049b6fef33146e92615c72f1243 -r 87fe2e111e03663c6da6948be519c390ebd831d8 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -14,11 +14,16 @@
#-----------------------------------------------------------------------------
import numpy as np
+import string
from yt.utilities.physical_constants import \
mh, boltzmann_constant_cgs, amu_cgs
from yt.fields.field_info_container import \
FieldInfoContainer
+from yt.fields.species_fields import \
+ add_species_field_by_fraction
+from yt.utilities.chemical_formulas import \
+ ChemicalFormula
rho_units = "code_mass / code_length**3"
mom_units = "code_mass / (code_time * code_length**2)"
@@ -108,3 +113,90 @@
self.add_field(("gas", "velocity_%s" % ax),
function = _get_vel(ax),
units = "cm/s")
+
+class MaestroFieldInfo(FieldInfoContainer):
+
+ known_other_fields = (
+ ("density", ("g/cm**3", ["density"], None)),
+ ("x_vel", ("cm/s", ["velocity_x"], None)),
+ ("y_vel", ("cm/s", ["velocity_y"], None)),
+ ("z_vel", ("cm/s", ["velocity_z"], None)),
+ ("magvel", ("cm/s", ["velocity_magnitude"], None)),
+ ("tfromp", ("K", [], None)),
+ ("tfromh", ("K", [], None)),
+ ("Machnumber", ("", ["mach_number"], None)),
+ ("S", ("1/s", [], None)),
+ ("ad_excess", ("", [], "Adiabatic Excess")),
+ ("deltaT", ("", [], None)),
+ ("deltagamma", ("", [], None)),
+ ("deltap", ("", [], None)),
+ ("divw0", ("1/s", [], None)),
+ # Specific entropy
+ ("entropy", ("erg/(g*K)", ["entropy"], None)),
+ ("entropypert", ("", [], None)),
+ ("enucdot", ("ergs/(g*s)", [], None)),
+ ("gpi_x", ("dyne/cm**3", [], None)), # Perturbational pressure grad
+ ("gpi_y", ("dyne/cm**3", [], None)),
+ ("gpi_z", ("dyne/cm**3", [], None)),
+ ("h", ("erg/g", [], "Specific Enthalpy")),
+ ("h0", ("erg/g", [], "Base State Specific Enthalpy")),
+ # Momentum cannot be computed because we need to include base and
+ # full state.
+ ("momentum", ("g*cm/s", ["momentum_magnitude"], None)),
+ ("p0", ("erg/cm**3", [], None)),
+ ("p0pluspi", ("erg/cm**3", [], None)),
+ ("pi", ("erg/cm**3", [], None)),
+ ("pioverp0", ("", [], None)),
+ # Base state density
+ ("rho0", ("g/cm**3", [], None)),
+ ("rhoh", ("erg/cm**3", ["enthalpy_density"], None)),
+ # Base state enthalpy density
+ ("rhoh0", ("erg/cm**3", [], None)),
+ ("rhohpert", ("erg/cm**3", [], None)),
+ ("rhopert", ("g/cm**3", [], None)),
+ ("soundspeed", ("cm/s", ["sound_speed"], None)),
+ ("sponge", ("", [], None)),
+ ("tpert", ("K", [], None)),
+ # Again, base state -- so we can't compute ourselves.
+ ("vort", ("1/s", ["vorticity_magnitude"], None)),
+ # Base state
+ ("w0_x", ("cm/s", [], None)),
+ ("w0_y", ("cm/s", [], None)),
+ ("w0_z", ("cm/s", [], None)),
+ )
+
+ def setup_fluid_fields(self):
+ # Add omegadots, units of 1/s
+ if self.pf.parameters["use_tfromp"]:
+ self.alias(("gas", "temperature"), ("boxlib", "tfromp"),
+ units = "K")
+ else:
+ self.alias(("gas", "temperature"), ("boxlib", "tfromh"),
+ units = "K")
+
+ for _, field in self.pf.field_list:
+ if field.startswith("X("):
+ # We have a fraction
+ nice_name = field[2:-1]
+ self.alias(("gas", "%s_fraction" % nice_name), ("boxlib", field),
+ units = "")
+ def _create_density_func(field_name):
+ def _func(field, data):
+ return data[field_name] * data["gas", "density"]
+ return _func
+ func = _create_density_func(("gas", "%s_fraction" % nice_name))
+ self.add_field(name = ("gas", "%s_density" % nice_name),
+ function = func,
+ units = "g/cm**3")
+ # We know this will either have one letter, or two.
+ if field[3] in string.letters:
+ element, weight = field[2:4], field[4:-1]
+ else:
+ element, weight = field[2:3], field[3:-1]
+ weight = int(weight)
+ # Here we can, later, add number density.
+ if field.startswith("omegadot("):
+ nice_name = field[9:-1]
+ self.add_output_field(("boxlib", field), units = "1/s")
+ self.alias(("gas", "%s_creation_rate" % nice_name),
+ ("boxlib", field), units = "1/s")
diff -r cc6b873a4471e049b6fef33146e92615c72f1243 -r 87fe2e111e03663c6da6948be519c390ebd831d8 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -294,8 +294,9 @@
order += [0, 4, 1, 5, 2, 6, 3, 7]
vertices = np.empty([corners.shape[2]*2*12,3])
+ vertices = self.pf.arr(vertices, "code_length")
for i in xrange(3):
- vertices[:,i] = corners[order,i,:].ravel(order='F')
+ vertices[:,i] = corners[order,i,...].ravel(order='F')
px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
@@ -477,8 +478,9 @@
order += [0, 4, 1, 5, 2, 6, 3, 7]
vertices = np.empty([24,3])
+ vertices = self.pf.arr(vertices, "code_length")
for i in xrange(3):
- vertices[:,i] = corners[order,i,:].ravel(order='F')
+ vertices[:,i] = corners[order,i,...].ravel(order='F')
px, py, dz = self.project_to_plane(vertices, res=im.shape[:2])
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