[yt-svn] commit/yt: xarthisius: Merged in MatthewTurk/yt/yt-3.0 (pull request #816)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Apr 14 12:14:56 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/b77623d7526e/
Changeset: b77623d7526e
Branch: yt-3.0
User: xarthisius
Date: 2014-04-14 21:14:47
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #816)
Fixing frontend bugs
Affected #: 9 files
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -112,6 +112,7 @@
_index_class = None
field_units = None
derived_field_list = requires_index("derived_field_list")
+ _instantiated = False
class __metaclass__(type):
def __init__(cls, name, b, d):
@@ -147,8 +148,7 @@
"""
# We return early and do NOT initialize a second time if this file has
# already been initialized.
- if self.known_filters is not None:
- return
+ if self._instantiated: return
self.dataset_type = dataset_type
self.file_style = file_style
self.conversion_factors = {}
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -67,7 +67,7 @@
level.
"""
- if self.start_index != None:
+ if self.start_index is not None:
return self.start_index
if self.Parent == []:
iLE = self.LeftEdge - self.pf.domain_left_edge
@@ -81,8 +81,7 @@
def _setup_dx(self):
# has already been read in and stored in index
- self.dds = self.index.dds_list[self.Level]
- self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = self.dds
+ self.dds = self.pf.arr(self.index.dds_list[self.Level], "code_length")
class ChomboHierarchy(GridIndex):
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/fields.py
--- a/yt/frontends/chombo/fields.py
+++ b/yt/frontends/chombo/fields.py
@@ -25,7 +25,7 @@
_temperature
rho_units = "code_mass / code_length**3"
-mom_units = "code_mass * code_length / code_time"
+mom_units = "code_mass / (code_time * code_length**2)"
eden_units = "code_mass / (code_time**2 * code_length)" # erg / cm^3
# We duplicate everything here from Boxlib, because we want to be able to
@@ -69,7 +69,8 @@
def setup_fluid_fields(self):
def _get_vel(axis):
def velocity(field, data):
- return data["%smom" % ax]/data["density"]
+ return data["momentum_%s" % ax]/data["density"]
+ return velocity
for ax in 'xyz':
self.add_field("velocity_%s" % ax, function = _get_vel(ax),
units = "cm/s")
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/chombo/tests/test_outputs.py
--- a/yt/frontends/chombo/tests/test_outputs.py
+++ b/yt/frontends/chombo/tests/test_outputs.py
@@ -21,7 +21,7 @@
data_dir_load
from yt.frontends.chombo.api import ChomboDataset
-_fields = ("density", "velocity_magnitude", "velocity_divergence",
+_fields = ("density", "velocity_magnitude", #"velocity_divergence",
"magnetic_field_x")
gc = "GaussianCloud/data.0077.3d.hdf5"
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/moab/tests/test_c5.py
--- a/yt/frontends/moab/tests/test_c5.py
+++ b/yt/frontends/moab/tests/test_c5.py
@@ -24,7 +24,7 @@
FieldValuesTest
from yt.frontends.moab.api import MoabHex8Dataset
-_fields = (("gas", "flux"),
+_fields = (("moab", "flux"),
)
c5 = "c5/c5.h5m"
@@ -39,12 +39,14 @@
yield assert_almost_equal, pf.index.get_smallest_dx(), 0.00411522633744843, 10
yield assert_equal, dd["x"].shape[0], 63*63*63
yield assert_almost_equal, \
- dd["cell_volume"].in_units("code_length**3").sum(dtype="float64"), \
+ dd["cell_volume"].in_units("code_length**3").sum(dtype="float64").d, \
1.0, 10
for offset_1 in [1e-9, 1e-4, 0.1]:
for offset_2 in [1e-9, 1e-4, 0.1]:
- ray = pf.ray(pf.domain_left_edge + offset_1,
- pf.domain_right_edge - offset_2)
+ DLE = pf.domain_left_edge
+ DRE = pf.domain_right_edge
+ ray = pf.ray(DLE + offset_1 * DLE.uq,
+ DRE - offset_2 * DRE.uq)
yield assert_almost_equal, ray["dts"].sum(dtype="float64"), 1.0, 8
for i, p1 in enumerate(np.random.random((5, 3))):
for j, p2 in enumerate(np.random.random((5, 3))):
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -350,7 +350,7 @@
for domain in self.domains:
pfl.update(set(domain.particle_field_offsets.keys()))
self.particle_field_list = list(pfl)
- self.field_list = [("gas", f) for f in self.fluid_field_list] \
+ self.field_list = [("ramses", f) for f in self.fluid_field_list] \
+ self.particle_field_list
def _setup_auto_fields(self):
@@ -372,8 +372,16 @@
if hydro_fn:
# Read the number of hydro variables
f = open(hydro_fn, "rb")
- fpu.skip(f, 1)
- nvar = fpu.read_vector(f, "i")[0]
+ hydro_header = ( ('ncpu', 1, 'i'),
+ ('nvar', 1, 'i'),
+ ('ndim', 1, 'i'),
+ ('nlevelmax', 1, 'i'),
+ ('nboundary', 1, 'i'),
+ ('gamma', 1, 'd')
+ )
+ hvals = fpu.read_attrs(f, hydro_header)
+ self.pf.gamma = hvals['gamma']
+ nvar = hvals['nvar']
# OK, we got NVAR, now set up the arrays depending on what NVAR is
# Allow some wiggle room for users to add too many variables
if nvar < 5:
@@ -439,6 +447,7 @@
class RAMSESDataset(Dataset):
_index_class = RAMSESIndex
_field_info_class = RAMSESFieldInfo
+ gamma = 1.4 # This will get replaced on hydro_fn open
def __init__(self, filename, dataset_type='ramses',
fields = None, storage_filename = None):
@@ -449,6 +458,7 @@
fields: An array of hydro variable fields in order of position in the hydro_XXXXX.outYYYYY file
If set to None, will try a default set of fields
'''
+ self.fluid_types += ("ramses",)
self._fields_in_file = fields
Dataset.__init__(self, filename, dataset_type)
self.storage_filename = storage_filename
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -29,16 +29,6 @@
)
yield header
# TODO: REMOVE
- '''
- hydro_header = ( ('ncpu', 1, 'i'),
- ('nvar', 1, 'i'),
- ('ndim', 1, 'i'),
- ('nlevelmax', 1, 'i'),
- ('nboundary', 1, 'i'),
- ('gamma', 1, 'd')
- )
- yield hydro_header
- '''
noutput, iout, ifout = hvals['nout']
next_set = ( ('tout', noutput, 'd'),
('aout', noutput, 'd'),
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -70,7 +70,7 @@
("x-velocity", (vel_units, ["velocity_x"], None)),
("y-velocity", (vel_units, ["velocity_y"], None)),
("z-velocity", (vel_units, ["velocity_z"], None)),
- ("Pressure", ("code_mass / (code_length * code_time**2)", [], None)),
+ ("Pressure", ("code_mass / (code_length * code_time**2)", ["pressure"], None)),
("Metallicity", ("", ["metallicity"], None)),
)
known_particle_fields = (
@@ -105,8 +105,8 @@
def _create_field(name, interp_object):
def _func(field, data):
shape = data["Temperature"].shape
- d = {'lognH': np.log10(_X*data["Density"]/mh).ravel(),
- 'logT' : np.log10(data["Temperature"]).ravel()}
+ d = {'lognH': np.log10(_X*data["density"]/mh).ravel(),
+ 'logT' : np.log10(data["temperature"]).ravel()}
rv = 10**interp_object(d).reshape(shape)
return rv
self.add_field(name = name, function=_func,
diff -r eaf23ee4fc06dfd795eab718ef0ff39ab3fb6cb9 -r b77623d7526ed785f1e71651ee98000657d8da56 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -95,6 +95,7 @@
header_spec = "default",
field_spec = "default",
ptype_spec = "default"):
+ if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
self._field_spec = self._setup_binary_spec(
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