[yt-svn] commit/yt: 6 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Jan 20 14:21:12 PST 2014
6 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/0a7877db9e9d/
Changeset: 0a7877db9e9d
Branch: yt-3.0
User: jsoishi
Date: 2013-11-01 16:53:07
Summary: merged.
Affected #: 40 files
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,4 +1,4 @@
-include distribute_setup.py README* CREDITS FUNDING LICENSE.txt
+include distribute_setup.py README* CREDITS COPYING.txt CITATION
recursive-include yt/gui/reason/html *.html *.png *.ico *.js
-recursive-include yt *.pyx *.pxd *.hh *.h README*
-recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE
\ No newline at end of file
+recursive-include yt *.pyx *.pxd *.h README*
+recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE kdtree2-README
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/data_objects/derived_quantities.py
--- a/yt/data_objects/derived_quantities.py
+++ b/yt/data_objects/derived_quantities.py
@@ -88,8 +88,12 @@
class DerivedQuantityCollection(object):
functions = quantity_info
- def __init__(self, data_source):
- self.data_source = data_source
+ def __new__(cls, data_source, *args, **kwargs):
+ inst = object.__new__(cls)
+ inst.data_source = data_source
+ for f in inst.keys():
+ setattr(inst, camelcase_to_underscore(f), inst[f])
+ return inst
def __getitem__(self, key):
if key not in self.functions:
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/data_objects/grid_patch.py
--- a/yt/data_objects/grid_patch.py
+++ b/yt/data_objects/grid_patch.py
@@ -259,7 +259,8 @@
new_field[1:,1:,:-1] += of
new_field[1:,1:,1:] += of
np.multiply(new_field, 0.125, new_field)
- if self.pf.field_info[field].take_log:
+ finfo = self.pf._get_field_info(field)
+ if finfo.take_log:
new_field = np.log10(new_field)
new_field[:,:, -1] = 2.0*new_field[:,:,-2] - new_field[:,:,-3]
@@ -269,7 +270,7 @@
new_field[-1,:,:] = 2.0*new_field[-2,:,:] - new_field[-3,:,:]
new_field[0,:,:] = 2.0*new_field[1,:,:] - new_field[2,:,:]
- if self.pf.field_info[field].take_log:
+ if finfo.take_log:
np.power(10.0, new_field, new_field)
else:
cg = self.retrieve_ghost_zones(1, field, smoothed=smoothed)
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -291,7 +291,9 @@
_last_freq = (None, None)
_last_finfo = None
- def _get_field_info(self, ftype, fname):
+ def _get_field_info(self, ftype, fname = None):
+ if fname is None:
+ ftype, fname = "unknown", ftype
guessing_type = False
if ftype == "unknown" and self._last_freq[0] != None:
ftype = self._last_freq[0]
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/fields/universal_fields.py
--- a/yt/fields/universal_fields.py
+++ b/yt/fields/universal_fields.py
@@ -375,7 +375,7 @@
convert_function=_convertCellMassCode)
def _TotalMass(field,data):
- return (data["gas","Density"]+data[("deposit", "particle_density")]) * \
+ return (data["gas","Density"]+data[("deposit", "all_density")]) * \
data["CellVolume"]
add_field("TotalMass", function=_TotalMass, units=r"\rm{g}")
add_field("TotalMassMsun", units=r"M_{\odot}",
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -121,6 +121,8 @@
self.parameter_file.particle_types = ["darkmatter", "stars"]
for specie in range(nspecies):
self.parameter_file.particle_types.append("specie%i" % specie)
+ self.parameter_file.particle_types_raw = tuple(
+ self.parameter_file.particle_types)
else:
self.parameter_file.particle_types = []
for ptype in self.parameter_file.particle_types:
@@ -424,7 +426,7 @@
try:
amr_header_vals = read_attrs(fh, amr_header_struct, '>')
return True
- except AssertionError:
+ except:
return False
return False
@@ -459,8 +461,9 @@
for j in range(2):
for k in range(2):
ii = ((k*2)+j)*2+i
+ # Note: C order because our index converts C to F.
source[field][:,ii] = \
- dt[i::2,j::2,k::2].ravel(order="F")
+ dt[i::2,j::2,k::2].ravel(order="C")
oct_handler.fill_level(0, levels, cell_inds, file_inds, tr, source)
del source
# Now we continue with the additional levels.
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/art/io.py
--- a/yt/frontends/art/io.py
+++ b/yt/frontends/art/io.py
@@ -36,10 +36,10 @@
masks = None
caching = True
- def __init__(self):
+ def __init__(self, *args, **kwargs):
self.cache = {}
self.masks = {}
- super(IOHandlerART, self).__init__()
+ super(IOHandlerART, self).__init__(*args, **kwargs)
def _read_fluid_selection(self, chunks, selector, fields, size):
# Chunks in this case will have affiliated domain subset objects
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/boxlib/__init__.py
--- a/yt/frontends/boxlib/__init__.py
+++ b/yt/frontends/boxlib/__init__.py
@@ -1,5 +1,5 @@
"""
-API for yt.frontends.orion
+API for yt.frontends.boxlib
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/boxlib/setup.py
--- a/yt/frontends/boxlib/setup.py
+++ b/yt/frontends/boxlib/setup.py
@@ -7,7 +7,7 @@
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
- config = Configuration('orion', parent_package, top_path)
+ config = Configuration('boxlib', parent_package, top_path)
config.make_config_py() # installs __config__.py
#config.make_svn_version_py()
return config
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/enzo/io.py
--- a/yt/frontends/enzo/io.py
+++ b/yt/frontends/enzo/io.py
@@ -150,7 +150,6 @@
if fid: fid.close()
return rv
-
class IOHandlerPackedHDF5GhostZones(IOHandlerPackedHDF5):
_data_style = "enzo_packed_3d_gz"
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/gdf/data_structures.py
--- a/yt/frontends/gdf/data_structures.py
+++ b/yt/frontends/gdf/data_structures.py
@@ -16,35 +16,37 @@
import h5py
import numpy as np
import weakref
-from yt.funcs import *
+import os
+from yt.funcs import \
+ just_one, ensure_tuple
from yt.data_objects.grid_patch import \
- AMRGridPatch
+ AMRGridPatch
from yt.geometry.grid_geometry_handler import \
- GridGeometryHandler
+ GridGeometryHandler
from yt.data_objects.static_output import \
- StaticOutput
+ StaticOutput
from yt.utilities.lib import \
get_box_grids_level
-from yt.utilities.io_handler import \
- io_registry
from yt.utilities.definitions import \
mpc_conversion, sec_conversion
from .fields import GDFFieldInfo, KnownGDFFields
from yt.data_objects.field_info_container import \
- FieldInfoContainer, NullFunc
-import pdb
+ NullFunc
+
def _get_convert(fname):
def _conv(data):
- return data.convert(fname)
+ return 1.0 # data.convert(fname) FIXME
return _conv
+
class GDFGrid(AMRGridPatch):
_id_offset = 0
+
def __init__(self, id, hierarchy, level, start, dimensions):
- AMRGridPatch.__init__(self, id, filename = hierarchy.hierarchy_filename,
- hierarchy = hierarchy)
+ AMRGridPatch.__init__(self, id, filename=hierarchy.hierarchy_filename,
+ hierarchy=hierarchy)
self.Parent = []
self.Children = []
self.Level = level
@@ -59,39 +61,41 @@
if len(self.Parent) > 0:
self.dds = self.Parent[0].dds / self.pf.refine_by
else:
- LE, RE = self.hierarchy.grid_left_edge[id,:], \
- self.hierarchy.grid_right_edge[id,:]
- self.dds = np.array((RE-LE)/self.ActiveDimensions)
+ LE, RE = self.hierarchy.grid_left_edge[id, :], \
+ self.hierarchy.grid_right_edge[id, :]
+ self.dds = np.array((RE - LE) / self.ActiveDimensions)
if self.pf.data_software != "piernik":
- if self.pf.dimensionality < 2: self.dds[1] = 1.0
- if self.pf.dimensionality < 3: self.dds[2] = 1.0
- self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = self.dds
+ if self.pf.dimensionality < 2:
+ self.dds[1] = 1.0
+ if self.pf.dimensionality < 3:
+ self.dds[2] = 1.0
+ self.field_data['dx'], self.field_data['dy'], self.field_data['dz'] = \
+ self.dds
- @property
- def filename(self):
- return None
class GDFHierarchy(GridGeometryHandler):
grid = GDFGrid
+ filtered_particle_types = []
def __init__(self, pf, data_style='grid_data_format'):
self.parameter_file = weakref.proxy(pf)
+ self.hierarchy_filename = self.parameter_file.parameter_filename
+ h5f = h5py.File(self.hierarchy_filename, 'r')
self.data_style = data_style
+ GridGeometryHandler.__init__(self, pf, data_style)
self.max_level = 10 # FIXME
# for now, the hierarchy file is the parameter file!
- self.hierarchy_filename = self.parameter_file.parameter_filename
self.directory = os.path.dirname(self.hierarchy_filename)
- self._fhandle = h5py.File(self.hierarchy_filename,'r')
- GridGeometryHandler.__init__(self,pf,data_style)
-
- self._fhandle.close()
+ h5f.close()
def _initialize_data_storage(self):
pass
def _detect_fields(self):
- self.field_list = self._fhandle['field_types'].keys()
+ h5f = h5py.File(self.hierarchy_filename, 'r')
+ self.field_list = h5f['field_types'].keys()
+ h5f.close()
def _setup_classes(self):
dd = self._get_data_reader_dict()
@@ -99,15 +103,17 @@
self.object_types.sort()
def _count_grids(self):
- self.num_grids = self._fhandle['/grid_parent_id'].shape[0]
+ h5f = h5py.File(self.hierarchy_filename, 'r')
+ self.num_grids = h5f['/grid_parent_id'].shape[0]
+ h5f.close()
def _parse_hierarchy(self):
- f = self._fhandle
+ h5f = h5py.File(self.hierarchy_filename, 'r')
dxs = []
self.grids = np.empty(self.num_grids, dtype='object')
- levels = (f['grid_level'][:]).copy()
- glis = (f['grid_left_index'][:]).copy()
- gdims = (f['grid_dimensions'][:]).copy()
+ levels = (h5f['grid_level'][:]).copy()
+ glis = (h5f['grid_left_index'][:]).copy()
+ gdims = (h5f['grid_dimensions'][:]).copy()
active_dims = ~((np.max(gdims, axis=0) == 1) &
(self.parameter_file.domain_dimensions == 1))
@@ -117,16 +123,18 @@
gdims[i])
self.grids[i]._level_id = levels[i]
- dx = (self.parameter_file.domain_right_edge-
- self.parameter_file.domain_left_edge)/self.parameter_file.domain_dimensions
- dx[active_dims] = dx[active_dims]/self.parameter_file.refine_by**(levels[i])
+ dx = (self.parameter_file.domain_right_edge -
+ self.parameter_file.domain_left_edge) / \
+ self.parameter_file.domain_dimensions
+ dx[active_dims] /= self.parameter_file.refine_by ** levels[i]
dxs.append(dx)
dx = np.array(dxs)
- self.grid_left_edge = self.parameter_file.domain_left_edge + dx*glis
+ self.grid_left_edge = self.parameter_file.domain_left_edge + dx * glis
self.grid_dimensions = gdims.astype("int32")
- self.grid_right_edge = self.grid_left_edge + dx*self.grid_dimensions
- self.grid_particle_count = f['grid_particle_count'][:]
+ self.grid_right_edge = self.grid_left_edge + dx * self.grid_dimensions
+ self.grid_particle_count = h5f['grid_particle_count'][:]
del levels, glis, gdims
+ h5f.close()
def _populate_grid_objects(self):
mask = np.empty(self.grids.size, dtype='int32')
@@ -138,8 +146,8 @@
g.Children = self._get_grid_children(g)
for g1 in g.Children:
g1.Parent.append(g)
- get_box_grids_level(self.grid_left_edge[gi,:],
- self.grid_right_edge[gi,:],
+ get_box_grids_level(self.grid_left_edge[gi, :],
+ self.grid_right_edge[gi, :],
self.grid_levels[gi],
self.grid_left_edge, self.grid_right_edge,
self.grid_levels, mask)
@@ -151,39 +159,40 @@
self.max_level = self.grid_levels.max()
def _setup_derived_fields(self):
- self.derived_field_list = []
+ super(GDFHierarchy, self)._setup_derived_fields()
def _get_box_grids(self, left_edge, right_edge):
"""
Gets back all the grids between a left edge and right edge
"""
eps = np.finfo(np.float64).eps
- grid_i = np.where((np.all((self.grid_right_edge - left_edge) > eps, axis=1) \
- & np.all((right_edge - self.grid_left_edge) > eps, axis=1)) == True)
+ grid_i = np.where(np.all((self.grid_right_edge - left_edge) > eps, axis=1) &
+ np.all((right_edge - self.grid_left_edge) > eps, axis=1))
return self.grids[grid_i], grid_i
-
def _get_grid_children(self, grid):
mask = np.zeros(self.num_grids, dtype='bool')
grids, grid_ind = self._get_box_grids(grid.LeftEdge, grid.RightEdge)
mask[grid_ind] = True
return [g for g in self.grids[mask] if g.Level == grid.Level + 1]
+
class GDFStaticOutput(StaticOutput):
_hierarchy_class = GDFHierarchy
_fieldinfo_fallback = GDFFieldInfo
_fieldinfo_known = KnownGDFFields
def __init__(self, filename, data_style='grid_data_format',
- storage_filename = None):
+ storage_filename=None):
StaticOutput.__init__(self, filename, data_style)
self.storage_filename = storage_filename
self.filename = filename
def _set_units(self):
"""
- Generates the conversion to various physical _units based on the parameter file
+ Generates the conversion to various physical _units
+ based on the parameter file
"""
self.units = {}
self.time_units = {}
@@ -192,16 +201,17 @@
self.time_units['1'] = 1
self.units['1'] = 1.0
self.units['cm'] = 1.0
- self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
+ self.units['unitary'] = 1.0 / (self.domain_right_edge -
+ self.domain_left_edge).max()
for unit in mpc_conversion.keys():
- self.units[unit] = 1.0 * mpc_conversion[unit] / mpc_conversion["cm"]
+ self.units[unit] = mpc_conversion[unit] / mpc_conversion["cm"]
for unit in sec_conversion.keys():
self.time_units[unit] = 1.0 / sec_conversion[unit]
# This should be improved.
- self._handle = h5py.File(self.parameter_filename, "r")
- for field_name in self._handle["/field_types"]:
- current_field = self._handle["/field_types/%s" % field_name]
+ h5f = h5py.File(self.parameter_filename, "r")
+ for field_name in h5f["/field_types"]:
+ current_field = h5f["/field_types/%s" % field_name]
if 'field_to_cgs' in current_field.attrs:
self.units[field_name] = current_field.attrs['field_to_cgs']
else:
@@ -210,15 +220,16 @@
if type(current_field.attrs['field_units']) == str:
current_fields_unit = current_field.attrs['field_units']
else:
- current_fields_unit = just_one(current_field.attrs['field_units'])
+ current_fields_unit = \
+ just_one(current_field.attrs['field_units'])
else:
current_fields_unit = ""
- self._fieldinfo_known.add_field(field_name, function=NullFunc, take_log=False,
- units=current_fields_unit, projected_units="",
- convert_function=_get_convert(field_name))
+ self._fieldinfo_known.add_field(
+ field_name, function=NullFunc, take_log=False,
+ units=current_fields_unit, projected_units="",
+ convert_function=_get_convert(field_name))
- self._handle.close()
- del self._handle
+ h5f.close()
def _parse_parameter_file(self):
self._handle = h5py.File(self.parameter_filename, "r")
@@ -232,13 +243,15 @@
self.domain_right_edge = sp["domain_right_edge"][:]
self.domain_dimensions = sp["domain_dimensions"][:]
refine_by = sp["refine_by"]
- if refine_by is None: refine_by = 2
+ if refine_by is None:
+ refine_by = 2
self.refine_by = refine_by
self.dimensionality = sp["dimensionality"]
self.current_time = sp["current_time"]
self.unique_identifier = sp["unique_identifier"]
self.cosmological_simulation = sp["cosmological_simulation"]
- if sp["num_ghost_zones"] != 0: raise RuntimeError
+ if sp["num_ghost_zones"] != 0:
+ raise RuntimeError
self.num_ghost_zones = sp["num_ghost_zones"]
self.field_ordering = sp["field_ordering"]
self.boundary_conditions = sp["boundary_conditions"][:]
@@ -252,15 +265,16 @@
else:
self.current_redshift = self.omega_lambda = self.omega_matter = \
self.hubble_constant = self.cosmological_simulation = 0.0
- self.parameters['Time'] = 1.0 # Hardcode time conversion for now.
- self.parameters["HydroMethod"] = 0 # Hardcode for now until field staggering is supported.
+ self.parameters['Time'] = 1.0 # Hardcode time conversion for now.
+ # Hardcode for now until field staggering is supported.
+ self.parameters["HydroMethod"] = 0
self._handle.close()
del self._handle
@classmethod
def _is_valid(self, *args, **kwargs):
try:
- fileh = h5py.File(args[0],'r')
+ fileh = h5py.File(args[0], 'r')
if "gridded_data_format" in fileh:
fileh.close()
return True
@@ -271,4 +285,3 @@
def __repr__(self):
return self.basename.rsplit(".", 1)[0]
-
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/gdf/fields.py
--- a/yt/frontends/gdf/fields.py
+++ b/yt/frontends/gdf/fields.py
@@ -16,14 +16,8 @@
from yt.data_objects.field_info_container import \
FieldInfoContainer, \
FieldInfo, \
- ValidateParameter, \
- ValidateDataField, \
- ValidateProperty, \
- ValidateSpatial, \
- ValidateGridType, \
NullFunc, \
TranslationFunc
-import yt.fields.universal_fields
log_translation_dict = {"Density": "density",
"Pressure": "pressure"}
@@ -31,7 +25,7 @@
translation_dict = {"x-velocity": "velocity_x",
"y-velocity": "velocity_y",
"z-velocity": "velocity_z"}
-
+
# translation_dict = {"mag_field_x": "cell_centered_B_x ",
# "mag_field_y": "cell_centered_B_y ",
# "mag_field_z": "cell_centered_B_z "}
@@ -43,39 +37,39 @@
add_gdf_field = KnownGDFFields.add_field
add_gdf_field("density", function=NullFunc, take_log=True,
- units=r"\rm{g}/\rm{cm}^3",
- projected_units =r"\rm{g}/\rm{cm}^2")
+ units=r"\rm{g}/\rm{cm}^3",
+ projected_units=r"\rm{g}/\rm{cm}^2")
add_gdf_field("specific_energy", function=NullFunc, take_log=True,
- units=r"\rm{erg}/\rm{g}")
+ units=r"\rm{erg}/\rm{g}")
add_gdf_field("pressure", function=NullFunc, take_log=True,
- units=r"\rm{erg}/\rm{g}")
+ units=r"\rm{erg}/\rm{g}")
add_gdf_field("velocity_x", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
add_gdf_field("velocity_y", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
add_gdf_field("velocity_z", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
add_gdf_field("mag_field_x", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
add_gdf_field("mag_field_y", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
add_gdf_field("mag_field_z", function=NullFunc, take_log=False,
- units=r"\rm{cm}/\rm{s}")
+ units=r"\rm{cm}/\rm{s}")
-for f,v in log_translation_dict.items():
+for f, v in log_translation_dict.items():
add_field(f, TranslationFunc(v), take_log=True,
units=KnownGDFFields[v].get_units(),
projected_units=KnownGDFFields[v].get_projected_units())
-for f,v in translation_dict.items():
+for f, v in translation_dict.items():
add_field(f, TranslationFunc(v), take_log=False,
units=KnownGDFFields[v].get_units(),
projected_units=KnownGDFFields[v].get_projected_units())
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/gdf/io.py
--- a/yt/frontends/gdf/io.py
+++ b/yt/frontends/gdf/io.py
@@ -14,14 +14,20 @@
#-----------------------------------------------------------------------------
import numpy as np
+import h5py
+import exceptions
from yt.funcs import \
mylog
from yt.utilities.io_handler import \
BaseIOHandler
-def field_dname(grid_id, field_name):
- return "/data/grid_%010i/%s" % (grid_id, field_name)
+def _grid_dname(grid_id):
+ return "/data/grid_%010i" % grid_id
+
+
+def _field_dname(grid_id, field_name):
+ return "%s/%s" % (_grid_dname(grid_id), field_name)
# TODO all particle bits were removed
@@ -30,50 +36,84 @@
_offset_string = 'data:offsets=0'
_data_string = 'data:datatype=0'
- def __init__(self, pf, *args, **kwargs):
- # TODO check if _num_per_stride is needed
- self._num_per_stride = kwargs.pop("num_per_stride", 1000000)
- BaseIOHandler.__init__(self, *args, **kwargs)
- self.pf = pf
- self._handle = pf._handle
+ def _read_field_names(self, grid):
+ if grid.filename is None:
+ return []
+ print 'grid.filename = %', grid.filename
+ h5f = h5py.File(grid.filename, mode="r")
+ group = h5f[_grid_dname(grid.id)]
+ fields = []
+ for name, v in group.iteritems():
+ # NOTE: This won't work with 1D datasets.
+ if not hasattr(v, "shape"):
+ continue
+ elif len(v.dims) == 1:
+ fields.append(("io", str(name)))
+ else:
+ fields.append(("gas", str(name)))
+ h5f.close()
+ return fields
-
- def _read_data_set(self, grid, field):
- if self.pf.field_ordering == 1:
- data = self._handle[field_dname(grid.id, field)][:].swapaxes(0, 2)
- else:
- data = self._handle[field_dname(grid.id, field)][:, :, :]
- return data.astype("float64")
-
- def _read_data_slice(self, grid, field, axis, coord):
- slc = [slice(None), slice(None), slice(None)]
- slc[axis] = slice(coord, coord + 1)
- if self.pf.field_ordering == 1:
- data = self._handle[field_dname(grid.id, field)][:].swapaxes(0, 2)[slc]
- else:
- data = self._handle[field_dname(grid.id, field)][slc]
- return data.astype("float64")
+ @property
+ def _read_exception(self):
+ return (exceptions.KeyError, )
def _read_fluid_selection(self, chunks, selector, fields, size):
+ rv = {}
chunks = list(chunks)
+
+ if selector.__class__.__name__ == "GridSelector":
+ if not (len(chunks) == len(chunks[0].objs) == 1):
+ raise RuntimeError
+ grid = chunks[0].objs[0]
+ h5f = h5py.File(grid.filename, 'r')
+ gds = h5f.get(_grid_dname(grid.id))
+ for ftype, fname in fields:
+ if self.pf.field_ordering == 1:
+ rv[(ftype, fname)] = gds.get(fname).value.swapaxes(0, 2)
+ else:
+ rv[(ftype, fname)] = gds.get(fname).value
+ h5f.close()
+ return rv
+ if size is None:
+ size = sum((grid.count(selector) for chunk in chunks
+ for grid in chunk.objs))
+
if any((ftype != "gas" for ftype, fname in fields)):
raise NotImplementedError
- fhandle = self._handle
- rv = {}
+
for field in fields:
ftype, fname = field
- rv[field] = np.empty(
- size, dtype=fhandle[field_dname(0, fname)].dtype)
+ fsize = size
+ # check the dtype instead
+ rv[field] = np.empty(fsize, dtype="float64")
ngrids = sum(len(chunk.objs) for chunk in chunks)
mylog.debug("Reading %s cells of %s fields in %s blocks",
size, [fname for ftype, fname in fields], ngrids)
- for field in fields:
- ftype, fname = field
- ind = 0
- for chunk in chunks:
- for grid in chunk.objs:
- data = fhandle[field_dname(grid.id, fname)][:]
- if self.pf.field_ordering == 1:
- data = data.swapaxes(0, 2)
- ind += g.select(selector, data, rv[field], ind) # caches
+ ind = 0
+ for chunk in chunks:
+ fid = None
+ for grid in chunk.objs:
+ if grid.filename is None:
+ continue
+ if fid is None:
+ fid = h5py.h5f.open(grid.filename, h5py.h5f.ACC_RDONLY)
+ if self.pf.field_ordering == 1:
+ # check the dtype instead
+ data = np.empty(grid.ActiveDimensions[::-1],
+ dtype="float64")
+ data_view = data.swapaxes(0, 2)
+ else:
+ # check the dtype instead
+ data_view = data = np.empty(grid.ActiveDimensions,
+ dtype="float64")
+ for field in fields:
+ ftype, fname = field
+ dg = h5py.h5d.open(fid, _field_dname(grid.id, fname))
+ dg.read(h5py.h5s.ALL, h5py.h5s.ALL, data)
+ # caches
+ nd = grid.select(selector, data_view, rv[field], ind)
+ ind += nd # I don't get that part, only last nd is added
+ if fid is not None:
+ fid.close()
return rv
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/moab/data_structures.py
--- a/yt/frontends/moab/data_structures.py
+++ b/yt/frontends/moab/data_structures.py
@@ -141,9 +141,9 @@
def _initialize_mesh(self):
from itaps import iBase, iMesh
- ent = self.pyne_mesh.structured_set.getEntities(iBase.Type.vertex)
- coords = self.pyne_mesh.mesh.getVtxCoords(ent).astype("float64")
- vind = self.pyne_mesh.structured_set.getAdjEntIndices(
+ ents = self.pyne_mesh.mesh.rootSet.getEntities(iBase.Type.vertex)
+ coords = self.pyne_mesh.mesh.getVtxCoords(ents).astype("float64")
+ vind = self.pyne_mesh.mesh.rootSet.getAdjEntIndices(
iBase.Type.region, iMesh.Topology.hexahedron,
iBase.Type.vertex)[1].indices.data.astype("int64")
# Divide by float so it throws an error if it's not 8
@@ -152,16 +152,7 @@
vind, coords, self)]
def _detect_fields(self):
- # Currently, I don't know a better way to do this. This code, for
- # example, does not work:
- #self.field_list = self.pyne_mesh.mesh.getAllTags(
- # self.pyne_mesh.mesh.rootSet)
- # So we have to look at each entity.
- tags = set([])
- for ent in self.pyne_mesh.mesh.rootSet:
- for tag in self.pyne_mesh.mesh.getAllTags(ent):
- tags.add(tag.name)
- self.field_list = list(tags)
+ self.field_list = self.pyne_mesh.tags.keys()
def _count_grids(self):
self.num_grids = 1
@@ -201,8 +192,8 @@
def _parse_parameter_file(self):
from itaps import iBase
- ent = self.pyne_mesh.structured_set.getEntities(iBase.Type.vertex)
- coords = self.pyne_mesh.mesh.getVtxCoords(ent)
+ ents = self.pyne_mesh.mesh.rootSet.getEntities(iBase.Type.vertex)
+ coords = self.pyne_mesh.mesh.getVtxCoords(ents)
self.domain_left_edge = coords[0]
self.domain_right_edge = coords[-1]
self.domain_dimensions = self.domain_right_edge - self.domain_left_edge
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/moab/io.py
--- a/yt/frontends/moab/io.py
+++ b/yt/frontends/moab/io.py
@@ -55,20 +55,16 @@
assert(len(chunks) == 1)
tags = {}
rv = {}
- mesh = self.pf.pyne_mesh.mesh
+ pyne_mesh = self.pf.pyne_mesh
+ mesh = pyne_mesh.mesh
for field in fields:
- ftype, fname = field
rv[field] = np.empty(size, dtype="float64")
- tags[field] = mesh.getTagHandle(fname)
- from itaps import iBase
- ents = self.pf.pyne_mesh.structured_set.getEntities(
- iBase.Type.region)
ngrids = sum(len(chunk.objs) for chunk in chunks)
mylog.debug("Reading %s cells of %s fields in %s blocks",
size, [fname for ftype, fname in fields], ngrids)
for field in fields:
ftype, fname = field
- ds = tags[field][ents]
+ ds = np.asarray(getattr(pyne_mesh, fname)[:], 'float64')
ind = 0
for chunk in chunks:
for g in chunk.objs:
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/setup.py
--- a/yt/frontends/setup.py
+++ b/yt/frontends/setup.py
@@ -22,7 +22,6 @@
config.add_subpackage("ramses")
config.add_subpackage("sph")
config.add_subpackage("stream")
- config.add_subpackage("tiger")
config.add_subpackage("boxlib/tests")
config.add_subpackage("flash/tests")
config.add_subpackage("enzo/tests")
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -128,7 +128,8 @@
function = TranslationFunc((ptype, "ParticleIDs")),
particle_type = True)
standard_particle_fields(self.field_info, ptype)
- _setup_particle_fields(self.field_info, ptype)
+ _setup_particle_fields(self.field_info, ptype,
+ self._particle_mass_name)
return [n for n, v in set(self.field_info.items()).difference(orig)]
class GadgetStaticOutput(ParticleStaticOutput):
@@ -286,6 +287,7 @@
_file_class = ParticleFile
_fieldinfo_fallback = GadgetHDF5FieldInfo
_fieldinfo_known = KnownGadgetHDF5Fields
+ _particle_mass_name = "Masses"
_suffix = ".hdf5"
def __init__(self, filename, data_style="gadget_hdf5",
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/sph/fields.py
--- a/yt/frontends/sph/fields.py
+++ b/yt/frontends/sph/fields.py
@@ -66,11 +66,8 @@
return data.convert(cf)
return _convert
-# TIPSY
-# =====
-
-def _setup_particle_fields(registry, ptype):
- registry.add_field((ptype, "Mass"), function=NullFunc,
+def _setup_particle_fields(registry, ptype, mass_name = "Mass"):
+ registry.add_field((ptype, mass_name), function=NullFunc,
particle_type = True,
convert_function=_get_conv("mass"),
units = r"\mathrm{g}")
@@ -80,7 +77,7 @@
units = r"\mathrm{cm}/\mathrm{s}")
# Note that we have to do this last so that TranslationFunc operates
# correctly.
- particle_deposition_functions(ptype, "Coordinates", "Mass",
+ particle_deposition_functions(ptype, "Coordinates", mass_name,
registry)
particle_scalar_functions(ptype, "Coordinates", "Velocities",
registry)
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/sph/io.py
--- a/yt/frontends/sph/io.py
+++ b/yt/frontends/sph/io.py
@@ -94,7 +94,7 @@
del coords
if mask is None: continue
for field in field_list:
- if field in ("Mass", "Mass") and \
+ if field in ("Mass", "Masses") and \
ptype not in self.var_mass:
data = np.empty(mask.sum(), dtype="float64")
ind = self._known_ptypes.index(ptype)
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -1051,7 +1051,8 @@
left_edge = self.pf.domain_left_edge,
right_edge = self.pf.domain_right_edge,
octree = self.pf.octree_mask,
- over_refine = self.pf.over_refine_factor)
+ over_refine = self.pf.over_refine_factor,
+ partial_coverage = self.pf.partial_coverage)
self.oct_handler = OctreeContainer.load_octree(header)
def _identify_base_chunk(self, dobj):
@@ -1101,7 +1102,7 @@
def load_octree(octree_mask, data, sim_unit_to_cm,
bbox=None, sim_time=0.0, periodicity=(True, True, True),
- over_refine_factor = 1):
+ over_refine_factor = 1, partial_coverage = 1):
r"""Load an octree mask into yt.
Octrees can be saved out by calling save_octree on an OctreeContainer.
@@ -1113,7 +1114,10 @@
Parameters
----------
octree_mask : np.ndarray[uint8_t]
- This is a depth-first refinement mask for an Octree.
+ This is a depth-first refinement mask for an Octree. It should be of
+ size n_octs * 8, where each item is 1 for an oct-cell being refined and
+ 0 for it not being refined. Note that for over_refine_factors != 1,
+ the children count will still be 8, so this is always 8.
data : dict
A dictionary of 1D arrays. Note that these must of the size of the
number of "False" values in the ``octree_mask``.
@@ -1126,6 +1130,9 @@
periodicity : tuple of booleans
Determines whether the data will be treated as periodic along
each axis
+ partial_coverage : boolean
+ Whether or not an oct can be refined cell-by-cell, or whether all 8 get
+ refined.
"""
@@ -1172,6 +1179,7 @@
spf = StreamOctreeStaticOutput(handler)
spf.octree_mask = octree_mask
+ spf.partial_coverage = partial_coverage
spf.units["cm"] = sim_unit_to_cm
spf.units['1'] = 1.0
spf.units["unitary"] = 1.0
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/__init__.py
--- a/yt/frontends/tiger/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""
-API for yt.frontends.tiger
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/api.py
--- a/yt/frontends/tiger/api.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-API for yt.frontends.tiger
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-from .data_structures import \
- TigerGrid, \
- TigerHierarchy, \
- TigerStaticOutput
-
-from .fields import \
- TigerFieldInfo, \
- add_tiger_field
-
-from .io import \
- IOHandlerTiger
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/data_structures.py
--- a/yt/frontends/tiger/data_structures.py
+++ /dev/null
@@ -1,195 +0,0 @@
-"""
-TIGER-specific data structures
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-from yt.funcs import *
-from yt.data_objects.grid_patch import \
- AMRGridPatch
-from yt.geometry.grid_geometry_handler import \
- GridGeometryHandler
-from yt.data_objects.static_output import \
- StaticOutput
-
-from yt.data_objects.field_info_container import \
- FieldInfoContainer, NullFunc
-from .fields import TigerFieldInfo, KnownTigerFields
-
-class TigerGrid(AMRGridPatch):
- _id_offset = 0
-
- def __init__(self, id, hierarchy, left_edge, right_edge, left_dims, right_dims):
- AMRGridPatch.__init__(self, id, hierarchy = hierarchy)
- self.LeftEdge = left_edge
- self.RightEdge = right_edge
- self.Level = 0
- self.NumberOfParticles = 0
- self.left_dims = np.array(left_dims, dtype='int32')
- self.right_dims = np.array(right_dims, dtype='int32')
- self.ActiveDimensions = self.right_dims - self.left_dims
- self.Parent = None
- self.Children = []
-
- @property
- def child_mask(self):
- return np.ones(self.ActiveDimensions, dtype='int32')
-
- def __repr__(self):
- return "TigerGrid_%04i (%s)" % (self.id, self.ActiveDimensions)
-
-class TigerHierarchy(GridGeometryHandler):
-
- grid = TigerGrid
-
- def __init__(self, pf, data_style):
- self.directory = pf.fullpath
- self.data_style = data_style
- GridGeometryHandler.__init__(self, pf, data_style)
-
- def _count_grids(self):
- # Tiger is unigrid
- self.ngdims = [i/j for i,j in
- izip(self.pf.root_size, self.pf.max_grid_size)]
- self.num_grids = np.prod(self.ngdims)
- self.max_level = 0
-
- def _setup_classes(self):
- dd = self._get_data_reader_dict()
- GridGeometryHandler._setup_classes(self, dd)
- self.object_types.sort()
-
- def _parse_hierarchy(self):
- grids = []
- # We need to fill in dims, LE, RE, level, count
- dims, LE, RE, levels, counts = [], [], [], [], []
- DLE = self.pf.domain_left_edge
- DRE = self.pf.domain_right_edge
- DW = DRE - DLE
- gds = DW / self.ngdims
- rd = [self.pf.root_size[i]-self.pf.max_grid_size[i] for i in range(3)]
- glx, gly, glz = np.mgrid[DLE[0]:DRE[0]-gds[0]:self.ngdims[0]*1j,
- DLE[1]:DRE[1]-gds[1]:self.ngdims[1]*1j,
- DLE[2]:DRE[2]-gds[2]:self.ngdims[2]*1j]
- gdx, gdy, gdz = np.mgrid[0:rd[0]:self.ngdims[0]*1j,
- 0:rd[1]:self.ngdims[1]*1j,
- 0:rd[2]:self.ngdims[2]*1j]
- LE, RE, levels, counts = [], [], [], []
- i = 0
- for glei, gldi in izip(izip(glx.flat, gly.flat, glz.flat),
- izip(gdx.flat, gdy.flat, gdz.flat)):
- gld = np.array(gldi)
- gle = np.array(glei)
- gre = gle + gds
- g = self.grid(i, self, gle, gre, gld, gld+self.pf.max_grid_size)
- grids.append(g)
- dims.append(self.pf.max_grid_size)
- LE.append(g.LeftEdge)
- RE.append(g.RightEdge)
- levels.append(g.Level)
- counts.append(g.NumberOfParticles)
- i += 1
- self.grids = np.empty(len(grids), dtype='object')
- for gi, g in enumerate(grids): self.grids[gi] = g
- self.grid_dimensions[:] = np.array(dims, dtype='int64')
- self.grid_left_edge[:] = np.array(LE, dtype='float64')
- self.grid_right_edge[:] = np.array(RE, dtype='float64')
- self.grid_levels.flat[:] = np.array(levels, dtype='int32')
- self.grid_particle_count.flat[:] = np.array(counts, dtype='int32')
-
- def _populate_grid_objects(self):
- # We don't need to do anything here
- for g in self.grids: g._setup_dx()
-
- def _detect_fields(self):
- self.file_mapping = {"Density" : "rhob",
- "Temperature" : "temp"}
-
- @property
- def field_list(self):
- return self.file_mapping.keys()
-
- def _setup_derived_fields(self):
- self.derived_field_list = []
-
-class TigerStaticOutput(StaticOutput):
- _hierarchy_class = TigerHierarchy
- _fieldinfo_fallback = TigerFieldInfo
- _fieldinfo_known = KnownTigerFields
-
- def __init__(self, rhobname, root_size, max_grid_size=128,
- data_style='tiger', storage_filename = None):
- StaticOutput.__init__(self, rhobname, data_style)
- self.storage_filename = storage_filename
- self.basename = rhobname[:-4]
- if not os.path.exists(self.basename + "rhob"):
- print "%s doesn't exist, don't know how to handle this!" % (
- self.basename + "rhob")
- raise IOError
- if not iterable(root_size): root_size = (root_size,) * 3
- self.root_size = root_size
- if not iterable(max_grid_size): max_grid_size = (max_grid_size,) * 3
- self.max_grid_size = max_grid_size
-
- self.field_info = FieldInfoContainer.create_with_fallback(
- self._fieldinfo_fallback)
-
- # We assume that we have basename + "rhob" and basename + "temp"
- # to get at our various parameters.
-
- # First we get our our header:
-
- header = [
- ('i', 'dummy0'),
- ('f', 'ZR'),
- ('f', 'OMEGA0'),
- ('f', 'FLAM0'),
- ('f', 'OMEGAB'),
- ('f', 'H0'),
- ('f', 'BOXL0'),
- ('i', 'dummy1'),
- ]
-
- h_fmt, h_key = zip(*header)
- header_string = "".join(h_fmt)
-
- fs = open(self.basename + "rhob")
- header_raw = read_struct(fs, header_string)
- self.parameters.update(dict(zip(h_key, header_raw)))
-
- if "InitialTime" not in self.parameters:
- self.current_time = 0.0
- self.unique_identifier = \
- int(os.stat(self.parameter_filename)[ST_CTIME])
- self.parameters['TopGridDimensions'] = root_size
- self.parameters['TopGridRank'] = 3
- self.units["Density"] = 1.0
- self.parameters['RefineBy'] = 2
-
- def _set_units(self):
- self.domain_left_edge = np.zeros(3, dtype='float64')
- self.domain_right_edge = np.ones(3, dtype='float64')
- self.units = {}
- self.time_units = {}
- self.time_units['1'] = 1
- self.units['1'] = 1.0
- self.units['cm'] = 1.0 # This is just plain false
- self.units['unitary'] = 1.0 / (self["DomainRightEdge"] - self["DomainLeftEdge"]).max()
-
- def _parse_parameter_file(self):
- pass
-
- @classmethod
- def _is_valid(self, *args, **kwargs):
- return os.path.exists(args[0] + "rhob")
-
-
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/fields.py
--- a/yt/frontends/tiger/fields.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""
-Tiger-specific fields
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-from yt.data_objects.field_info_container import \
- FieldInfoContainer, \
- FieldInfo, \
- ValidateParameter, \
- ValidateDataField, \
- ValidateProperty, \
- ValidateSpatial, \
- ValidateGridType
-import yt.fields.universal_fields
-
-KnownTigerFields = FieldInfoContainer()
-add_tiger_field = KnownTigerFields.add_field
-
-TigerFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo)
-add_field = TigerFieldInfo.add_field
-
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/io.py
--- a/yt/frontends/tiger/io.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""
-TIGER-specific IO functions
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-from yt.utilities.io_handler import \
- BaseIOHandler
-
-class IOHandlerTiger(BaseIOHandler):
- _data_style = "tiger"
- _offset = 36
-
- def __init__(self, *args, **kwargs):
- BaseIOHandler.__init__(self, *args, **kwargs)
- self._memmaps = {}
-
- def _read_data(self, grid, field):
- fn = grid.pf.basename + grid.hierarchy.file_mapping[field]
- LD = np.array(grid.left_dims, dtype='int64')
- SS = np.array(grid.ActiveDimensions, dtype='int64')
- RS = np.array(grid.pf.root_size, dtype='int64')
- data = au.read_tiger_section(fn, LD, SS, RS).astype("float64")
- return data
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/frontends/tiger/setup.py
--- a/yt/frontends/tiger/setup.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env python
-import setuptools
-import os
-import sys
-import os.path
-
-
-def configuration(parent_package='', top_path=None):
- from numpy.distutils.misc_util import Configuration
- config = Configuration('tiger', parent_package, top_path)
- config.make_config_py() # installs __config__.py
- #config.make_svn_version_py()
- return config
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -14,7 +14,7 @@
#-----------------------------------------------------------------------------
import __builtin__
-import time, types, signal, inspect, traceback, sys, pdb, os
+import time, types, signal, inspect, traceback, sys, pdb, os, re
import contextlib
import warnings, struct, subprocess
import numpy as np
@@ -626,6 +626,10 @@
if not os.path.exists(my_dir):
only_on_root(os.makedirs, my_dir)
+def camelcase_to_underscore(name):
+ s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
+ return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
+
def set_intersection(some_list):
if len(some_list) == 0: return set([])
# This accepts a list of iterables, which we get the intersection of.
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -83,6 +83,9 @@
mylog.debug("Setting up particle fields")
self._setup_particle_types()
+ mylog.debug("Checking derived fields again")
+ self._derived_fields_add(self._check_later)
+
def __del__(self):
if self._data_file is not None:
self._data_file.close()
@@ -110,6 +113,7 @@
self._data_mode = None
self._max_locations = {}
self.num_grids = None
+ self._check_later = []
def _setup_classes(self, dd):
# Called by subclass
@@ -248,7 +252,7 @@
fi = self.parameter_file.field_info
# First we construct our list of fields to check
fields_to_check = []
- for field in fi.keys():
+ for field in fi:
finfo = fi[field]
# Explicitly defined
if isinstance(field, tuple):
@@ -273,10 +277,12 @@
if fields_to_check is None:
fields_to_check = []
fi = self.parameter_file.field_info
+ self._check_later = []
for field in fields_to_check:
try:
fd = fi[field].get_dependencies(pf = self.parameter_file)
except Exception as e:
+ self._check_later.append(field)
if type(e) != YTFieldNotFound:
mylog.debug("Raises %s during field %s detection.",
str(type(e)), field)
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -120,15 +120,20 @@
cdef np.ndarray[np.uint8_t, ndim=1] ref_mask
ref_mask = header['octree']
cdef OctreeContainer obj = cls(header['dims'], header['left_edge'],
- header['right_edge'], over_refine = header['over_refine'])
+ header['right_edge'], over_refine = header['over_refine'],
+ partial_coverage = header['partial_coverage'])
# NOTE: We do not allow domain/file indices to be specified.
cdef SelectorObject selector = selection_routines.AlwaysSelector(None)
cdef OctVisitorData data
obj.setup_data(&data, -1)
- obj.allocate_domains([ref_mask.shape[0]])
+ assert(ref_mask.shape[0] / 8.0 == <int>(ref_mask.shape[0]/8.0))
+ obj.allocate_domains([ref_mask.shape[0] / 8.0])
cdef int i, j, k, n
data.global_index = -1
data.level = 0
+ # This is not something I terribly like, but it needs to be done.
+ data.oref = 1
+ data.nz = 8
cdef np.float64_t pos[3], dds[3]
# This dds is the oct-width
for i in range(3):
@@ -159,6 +164,7 @@
data.pos[0] = i
data.pos[1] = j
data.pos[2] = k
+ # Always visit covered
selector.recursively_visit_octs(
obj.root_mesh[i][j][k],
pos, dds, 0, oct_visitors.load_octree,
@@ -167,9 +173,10 @@
pos[1] += dds[1]
pos[0] += dds[0]
obj.nocts = cur.n_assigned
- if obj.nocts != ref_mask.size:
+ if obj.nocts * 8 != ref_mask.size:
print "SOMETHING WRONG", ref_mask.size, obj.nocts, obj.oref
- raise RuntimeError
+ raise KeyError(ref_mask.size, obj.nocts, obj.oref,
+ obj.partial_coverage)
return obj
cdef void setup_data(self, OctVisitorData *data, int domain_id = -1):
@@ -301,8 +308,9 @@
else:
next = NULL
if oinfo == NULL: return cur
+ cdef int ncells = (1 << self.oref)
cdef np.float64_t factor = 1.0 / (1 << (self.oref-1))
- if self.oref == 0: factor = 1.0
+ if self.oref == 0: factor = 2.0
for i in range(3):
# This will happen *after* we quit out, so we need to back out the
# last change to cp
@@ -312,13 +320,11 @@
cp[i] += dds[i]/2.0
# We don't normally need to change dds[i] as it has been halved
# from the oct width, thus making it already the cell width.
- # But, for some cases where the oref != 1, this needs to be
- # changed.
+ # But, since not everything has the cell width equal to have the
+ # width of the oct, we need to apply "factor".
oinfo.dds[i] = dds[i] * factor # Cell width
- oinfo.left_edge[i] = cp[i] - dds[i] # Center minus dds
oinfo.ipos[i] = ipos[i]
- if self.oref == 0:
- oinfo.dds[i] = dds[i] # Same here as elsewhere
+ oinfo.left_edge[i] = oinfo.ipos[i] * (oinfo.dds[i] * ncells) + self.DLE[i]
oinfo.level = level
return cur
@@ -499,16 +505,18 @@
header = dict(dims = (self.nn[0], self.nn[1], self.nn[2]),
left_edge = (self.DLE[0], self.DLE[1], self.DLE[2]),
right_edge = (self.DRE[0], self.DRE[1], self.DRE[2]),
- over_refine = self.oref)
- if self.partial_coverage == 1:
- raise NotImplementedError
+ over_refine = self.oref,
+ partial_coverage = self.partial_coverage)
cdef SelectorObject selector = selection_routines.AlwaysSelector(None)
# domain_id = -1 here, because we want *every* oct
cdef OctVisitorData data
self.setup_data(&data, -1)
+ data.oref = 1
+ data.nz = 8
cdef np.ndarray[np.uint8_t, ndim=1] ref_mask
- ref_mask = np.zeros(self.nocts, dtype="uint8") - 1
+ ref_mask = np.zeros(self.nocts * 8, dtype="uint8") - 1
data.array = <void *> ref_mask.data
+ # Enforce partial_coverage here
self.visit_all_octs(selector, oct_visitors.store_octree, &data, 1)
header['octree'] = ref_mask
return header
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/geometry/oct_visitors.pyx
--- a/yt/geometry/oct_visitors.pyx
+++ b/yt/geometry/oct_visitors.pyx
@@ -176,15 +176,15 @@
arr[o.domain - 1] += 1
cdef void store_octree(Oct *o, OctVisitorData *data, np.uint8_t selected):
- cdef np.uint8_t *arr
- if data.last != o.domain_ind:
- data.last = o.domain_ind
- arr = <np.uint8_t *> data.array
- if o.children == NULL:
- arr[data.index] = 0
- if o.children != NULL:
- arr[data.index] = 1
- data.index += 1
+ cdef np.uint8_t *arr, res, ii
+ ii = cind(data.ind[0], data.ind[1], data.ind[2])
+ arr = <np.uint8_t *> data.array
+ if o.children == NULL or o.children[ii] == NULL:
+ res = 0
+ else:
+ res = 1
+ arr[data.index] = res
+ data.index += 1
cdef void load_octree(Oct *o, OctVisitorData *data, np.uint8_t selected):
cdef void **p = <void **> data.array
@@ -192,21 +192,25 @@
cdef Oct* octs = <Oct*> p[1]
cdef np.int64_t *nocts = <np.int64_t*> p[2]
cdef np.int64_t *nfinest = <np.int64_t*> p[3]
- cdef int i
-
- if data.last != o.domain_ind:
- data.last = o.domain_ind
- if arr[data.index] == 0:
+ cdef int i, ii
+ ii = cind(data.ind[0], data.ind[1], data.ind[2])
+ if arr[data.index] == 0:
+ # We only want to do this once. Otherwise we end up with way too many
+ # nfinest for our tastes.
+ if o.file_ind == -1:
o.children = NULL
o.file_ind = nfinest[0]
o.domain = 1
nfinest[0] += 1
- if arr[data.index] == 1:
+ elif arr[data.index] == 1:
+ if o.children == NULL:
o.children = <Oct **> malloc(sizeof(Oct *) * 8)
for i in range(8):
- o.children[i] = &octs[nocts[0]]
- o.children[i].domain_ind = nocts[0]
- o.children[i].file_ind = -1
- o.children[i].domain = -1
- nocts[0] += 1
- data.index += 1
+ o.children[i] = NULL
+ o.children[ii] = &octs[nocts[0]]
+ o.children[ii].domain_ind = nocts[0]
+ o.children[ii].file_ind = -1
+ o.children[ii].domain = -1
+ o.children[ii].children = NULL
+ nocts[0] += 1
+ data.index += 1
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -84,15 +84,9 @@
from yt.frontends.flash.api import \
FLASHStaticOutput, FLASHFieldInfo, add_flash_field
-from yt.frontends.tiger.api import \
- TigerStaticOutput, TigerFieldInfo, add_tiger_field
-
from yt.frontends.artio.api import \
ARTIOStaticOutput, ARTIOFieldInfo, add_artio_field
-#from yt.frontends.artio2.api import \
-# Artio2StaticOutput
-
from yt.frontends.ramses.api import \
RAMSESStaticOutput, RAMSESFieldInfo, add_ramses_field
@@ -143,7 +137,8 @@
get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
callback_registry, write_bitmap, write_image, \
apply_colormap, scale_image, write_projection, write_fits, \
- SlicePlot, OffAxisSlicePlot, ProjectionPlot, OffAxisProjectionPlot, \
+ SlicePlot, AxisAlignedSlicePlot, OffAxisSlicePlot, \
+ ProjectionPlot, OffAxisProjectionPlot, \
show_colormaps
from yt.visualization.volume_rendering.api import \
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/utilities/amr_kdtree/amr_kdtree.py
--- a/yt/utilities/amr_kdtree/amr_kdtree.py
+++ b/yt/utilities/amr_kdtree/amr_kdtree.py
@@ -83,6 +83,7 @@
grids = np.array([b for b, mask in self.data_source.blocks if b.Level == lvl])
gids = np.array([g.id for g in grids if g.Level == lvl],
dtype="int64")
+ if len(grids) == 0: continue
self.add_grids(grids)
def check_tree(self):
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/utilities/io_handler.py
--- a/yt/utilities/io_handler.py
+++ b/yt/utilities/io_handler.py
@@ -114,7 +114,7 @@
return None
def _read_chunk_data(self, chunk, fields):
- return None
+ return {}
def _read_particle_selection(self, chunks, selector, fields):
rv = {}
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/utilities/lib/fortran_reader.pyx
--- a/yt/utilities/lib/fortran_reader.pyx
+++ b/yt/utilities/lib/fortran_reader.pyx
@@ -55,41 +55,9 @@
fread(buf, 1, bytes, f)
fclose(f)
- at cython.boundscheck(False)
- at cython.wraparound(False)
-def read_tiger_section(
- char *fn,
- np.ndarray[np.int64_t, ndim=1] slab_start,
- np.ndarray[np.int64_t, ndim=1] slab_size,
- np.ndarray[np.int64_t, ndim=1] root_size,
- int offset = 36):
- cdef int strides[3]
- strides[0] = 1
- strides[1] = root_size[0] * strides[0]
- strides[2] = strides[1] * root_size[1] + 2
- cdef np.int64_t i, j, k
- cdef np.ndarray buffer = np.zeros(slab_size, dtype='float32', order='F')
- cdef FILE *f = fopen(fn, "rb")
- #for i in range(3): offset += strides[i] * slab_start[i]
- cdef np.int64_t pos = 0
- cdef np.int64_t moff = 0
- cdef float *data = <float *> buffer.data
- fseek(f, offset, 0)
- # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
- for i in range(slab_size[2]):
- for j in range(slab_size[1]):
- moff = (slab_start[0] ) * strides[0] \
- + (slab_start[1] + j) * strides[1] \
- + (slab_start[2] + i) * strides[2]
- #print offset + 4 * moff, pos
- fseek(f, offset + 4 * moff, SEEK_SET)
- fread(<void *> (data + pos), 4, slab_size[0], f)
- pos += slab_size[0]
- return buffer
-
def count_art_octs(char *fn, long offset,
int min_level, int max_level,
- int nhydro_vars,
+ int nhydro_vars,
level_info):
cdef int nchild = 8
cdef int i, Lev, next_record, nLevel
@@ -108,12 +76,12 @@
# Offset for one record header we just read
next_record = (nLevel * (next_record + 2*sizeof(int))) - sizeof(int)
fseek(f, next_record, SEEK_CUR)
- # Now we skip the second section
+ # Now we skip the second section
fread(&readin, sizeof(int), 1, f); FIX_LONG(readin)
nhydro_vars = next_record/4-2-3 #nhvar in daniel's code
#record length is normally 2 pad bytes, 8 + 2 hvars (the 2 is nchem)
# and then 3 vars, but we can find nhvars only here and not in other
- # file headers
+ # file headers
next_record = (2*sizeof(int) + readin) * (nLevel * nchild)
next_record -= sizeof(int)
fseek(f, next_record, SEEK_CUR)
@@ -121,13 +89,13 @@
fclose(f)
def read_art_tree(char *fn, long offset,
- int min_level, int max_level,
+ int min_level, int max_level,
np.ndarray[np.int64_t, ndim=2] oct_indices,
np.ndarray[np.int64_t, ndim=1] oct_levels,
np.ndarray[np.int64_t, ndim=2] oct_info):
# np.ndarray[np.int64_t, ndim=1] oct_mask,
# np.ndarray[np.int64_t, ndim=1] oct_parents,
-
+
# This accepts the filename of the ART header and an integer offset that
# points to the start of the record *following* the reading of iOctFree and
# nOct. For those following along at home, we only need to read:
@@ -162,7 +130,7 @@
#print ftell(f)
for ic1 in range(nLevel):
iOctMax = max(iOctMax, iOct)
- #print readin, iOct, nLevel, sizeof(int)
+ #print readin, iOct, nLevel, sizeof(int)
next_record = ftell(f)
fread(&readin, sizeof(int), 1, f); FIX_LONG(readin)
assert readin==52
@@ -185,30 +153,30 @@
fseek(f, next_record, SEEK_SET)
fread(&readin, sizeof(int), 1, f); FIX_LONG(readin)
assert readin==52
-
+
total_masked = 0
level_offsets.append(ftell(f))
-
+
#skip over the hydro variables
#find the length of one child section
#print 'measuring child record ',
- fread(&next_record, sizeof(int), 1, f);
+ fread(&next_record, sizeof(int), 1, f);
#print next_record,
FIX_LONG(next_record)
#print next_record
fseek(f,ftell(f)-sizeof(int),SEEK_SET) #rewind
#This is a sloppy fix; next_record is 64bit
- #and I don't think FIX_LONG(next_record) is working
+ #and I don't think FIX_LONG(next_record) is working
#correctly for 64bits
if next_record > 4294967296L:
next_record -= 4294967296L
assert next_record == 56
-
+
#find the length of all of the children section
child_record = ftell(f) + (next_record+2*sizeof(int))*nLevel*nchild
#print 'Skipping over hydro vars', ftell(f), child_record
fseek(f, child_record, SEEK_SET)
-
+
# for ic1 in range(nLevel * nchild):
# fread(&next_record, sizeof(int), 1, f); FIX_LONG(next_record)
# fread(&idc, sizeof(int), 1, f); FIX_LONG(idc); idc -= 1 + (128**3)
@@ -220,7 +188,7 @@
fclose(f)
return level_offsets
-def read_art_root_vars(char *fn, long root_grid_offset,
+def read_art_root_vars(char *fn, long root_grid_offset,
int nhydro_vars, int nx, int ny, int nz,
int ix, int iy, int iz, fields, var):
@@ -235,7 +203,7 @@
fseek(f, cell_record_size * my_offset, SEEK_CUR)
#(((C)*GridDimension[1]+(B))*GridDimension[0]+A)
for j in range(nhydro_vars):
- fread(&temp, sizeof(float), 1, f);
+ fread(&temp, sizeof(float), 1, f);
if j in fields:
FIX_FLOAT(temp)
var[l]=temp
@@ -243,7 +211,7 @@
fclose(f)
cdef void read_art_vars(FILE *f,
- int min_level, int max_level, int nhydro_vars,
+ int min_level, int max_level, int nhydro_vars,
int grid_level,long grid_id,long child_offset,
fields,
np.ndarray[np.int64_t, ndim=1] level_offsets,
@@ -273,7 +241,7 @@
@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
-def read_art_grid(int varindex,
+def read_art_grid(int varindex,
np.ndarray[np.int64_t, ndim=1] start_index,
np.ndarray[np.int32_t, ndim=1] grid_dims,
np.ndarray[np.float32_t, ndim=3] data,
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/utilities/lib/marching_cubes.pyx
--- a/yt/utilities/lib/marching_cubes.pyx
+++ b/yt/utilities/lib/marching_cubes.pyx
@@ -535,6 +535,7 @@
vertices = np.zeros((triangles.count*3,3), dtype='float64')
if do_sample == 0:
FillAndWipeTriangles(vertices, triangles.first)
+ return vertices
cdef int nskip
if do_sample == 1:
nskip = 1
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -49,6 +49,7 @@
from plot_window import \
SlicePlot, \
+ AxisAlignedSlicePlot, \
OffAxisSlicePlot, \
ProjectionPlot, \
OffAxisProjectionPlot
diff -r 40c2a3b55d6ae9439124e4cbe1feecf3308c46f6 -r 0a7877db9e9d0dc82032ec336ed067f610caa353 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1208,7 +1208,7 @@
ret += '<img src="data:image/png;base64,%s"><br>' % img
return ret
-class SlicePlot(PWViewerMPL):
+class AxisAlignedSlicePlot(PWViewerMPL):
r"""Creates a slice plot from a parameter file
Given a pf object, an axis to slice along, and a field name
@@ -1989,3 +1989,160 @@
yfrac
)
return axrect, caxrect
+
+def SlicePlot(pf, normal=None, fields=None, axis=None, *args, **kwargs):
+ r"""
+ A factory function for
+ :class:`yt.visualization.plot_window.AxisAlignedSlicePlot`
+ and :class:`yt.visualization.plot_window.OffAxisSlicePlot` objects. This
+ essentially allows for a single entry point to both types of slice plots,
+ the distinction being determined by the specified normal vector to the
+ slice.
+
+ The returned plot object can be updated using one of the many helper
+ functions defined in PlotWindow.
+
+ Parameters
+ ----------
+ pf : :class:`yt.data_objects.api.StaticOutput`
+ This is the parameter file object corresponding to the
+ simulation output to be plotted.
+ normal : int or one of 'x', 'y', 'z', or sequence of floats
+ This specifies the normal vector to the slice. If given as an integer
+ or a coordinate string (0=x, 1=y, 2=z), this function will return an
+ :class:`AxisAlignedSlicePlot` object. If given as a sequence of floats,
+ this is interpretted as an off-axis vector and an
+ :class:`OffAxisSlicePlot` object is returned.
+ fields : string
+ The name of the field(s) to be plotted.
+ axis : int or one of 'x', 'y', 'z'
+ An int corresponding to the axis to slice along (0=x, 1=y, 2=z)
+ or the axis name itself. If specified, this will replace normal.
+
+ The following are nominally keyword arguments passed onto the respective
+ slice plot objects generated by this function.
+
+ center : two or three-element vector of sequence floats, 'c', or 'center',
+ or 'max'
+ If set to 'c', 'center' or left blank, the plot is centered on the
+ middle of the domain. If set to 'max' or 'm', the center will be at
+ the point of highest density.
+ width : tuple or a float.
+ Width can have four different formats to support windows with variable
+ x and y widths. They are:
+
+ ================================== =======================
+ format example
+ ================================== =======================
+ (float, string) (10,'kpc')
+ ((float, string), (float, string)) ((10,'kpc'),(15,'kpc'))
+ float 0.2
+ (float, float) (0.2, 0.3)
+ ================================== =======================
+
+ For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+ wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a
+ window that is 10 kiloparsecs wide along the x axis and 15
+ kiloparsecs wide along the y axis. In the other two examples, code
+ units are assumed, for example (0.2, 0.3) requests a plot that has an
+ x width of 0.2 and a y width of 0.3 in code units. If units are
+ provided the resulting plot axis labels will use the supplied units.
+ axes_unit : A string
+ The name of the unit for the tick labels on the x and y axes.
+ Defaults to None, which automatically picks an appropriate unit.
+ If axes_unit is '1', 'u', or 'unitary', it will not display the
+ units, and only show the axes name.
+ origin : string or length 1, 2, or 3 sequence of strings
+ The location of the origin of the plot coordinate system for
+ `AxisAlignedSlicePlot` objects; for `OffAxisSlicePlot` objects,
+ this parameter is discarded. This is represented by '-' separated
+ string or a tuple of strings. In the first index the y-location is
+ given by 'lower', 'upper', or 'center'. The second index is the
+ x-location, given as 'left', 'right', or 'center'. Finally, the
+ whether the origin is applied in 'domain' space, plot 'window' space
+ or 'native' simulation coordinate system is given. For example, both
+ 'upper-right-domain' and ['upper', 'right', 'domain'] both place the
+ origin in the upper right hand corner of domain space. If x or y are
+ not given, a value is inffered. For instance, 'left-domain'
+ corresponds to the lower-left hand corner of the simulation domain,
+ 'center-domain' corresponds to the center of the simulation domain,
+ or 'center-window' for the center of the plot window. Further
+ examples:
+
+ ================================== ============================
+ format example
+ ================================== ============================
+ '{space}' 'domain'
+ '{xloc}-{space}' 'left-window'
+ '{yloc}-{space}' 'upper-domain'
+ '{yloc}-{xloc}-{space}' 'lower-right-window'
+ ('{space}',) ('window',)
+ ('{xloc}', '{space}') ('right', 'domain')
+ ('{yloc}', '{space}') ('lower', 'window')
+ ('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
+ ================================== ============================
+ north-vector : a sequence of floats
+ A vector defining the 'up' direction in the `OffAxisSlicePlot`; not
+ used in `AxisAlignedSlicePlot`. This option sets the orientation of the
+ slicing plane. If not set, an arbitrary grid-aligned north-vector is
+ chosen.
+ fontsize : integer
+ The size of the fonts for the axis, colorbar, and tick labels.
+ field_parameters : dictionary
+ A dictionary of field parameters than can be accessed by derived
+ fields.
+
+ Raises
+ ------
+ AssertionError
+ If a proper normal axis is not specified via the normal or axis
+ keywords, and/or if a field to plot is not specified.
+
+ Examples
+ --------
+
+ >>> slc = SlicePlot(pf, "x", "Density", center=[0.2,0.3,0.4])
+ >>> slc = SlicePlot(pf, 2, "Temperature")
+ >>> slc = SlicePlot(pf, [0.4,0.2,-0.1], "Pressure",
+ north_vector=[0.2,-0.3,0.1])
+
+ """
+ # Make sure we are passed a normal
+ # we check the axis keyword for backwards compatability
+ if normal is None: normal = axis
+ if normal is None:
+ raise AssertionError("Must pass a normal vector to the slice!")
+
+ # to keep positional ordering we had to make fields a keyword; make sure
+ # it is present
+ if fields is None:
+ raise AssertionError("Must pass field(s) to plot!")
+
+ # use an AxisAlignedSlicePlot where possible, e.g.:
+ # maybe someone passed normal=[0,0,0.2] when they should have just used "z"
+ if iterable(normal) and not isinstance(normal,str):
+ if np.count_nonzero(normal) == 1:
+ normal = ("x","y","z")[np.nonzero(normal)[0][0]]
+ else:
+ normal = np.array(normal)
+ np.divide(normal, np.dot(normal,normal), normal)
+
+ # by now the normal should be properly set to get either a On/Off Axis plot
+ if iterable(normal) and not isinstance(normal,str):
+ # OffAxisSlicePlot has hardcoded origin; remove it if in kwargs
+ if 'origin' in kwargs:
+ msg = "Ignoring 'origin' keyword as it is ill-defined for " \
+ "an OffAxisSlicePlot object."
+ mylog.warn(msg)
+ del kwargs['origin']
+
+ return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
+ else:
+ # north_vector not used in AxisAlignedSlicePlots; remove it if in kwargs
+ if 'north_vector' in kwargs:
+ msg = "Ignoring 'north_vector' keyword as it is ill-defined for " \
+ "an AxisAlignedSlicePlot object."
+ mylog.warn(msg)
+ del kwargs['north_vector']
+
+ return AxisAlignedSlicePlot(pf, normal, fields, *args, **kwargs)
https://bitbucket.org/yt_analysis/yt/commits/acee0c10d242/
Changeset: acee0c10d242
Branch: yt-3.0
User: jsoishi
Date: 2014-01-20 22:15:36
Summary: corrected a few field_info --> _get_field_info() in thetransfer function helper and camera
Affected #: 2 files
diff -r 135d9107b38ea58063d8558f20bdc07a3d9e2aa2 -r acee0c10d242b2b5db723a32695d527949770a13 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -259,9 +259,8 @@
>>> write_bitmap(im, 'render_with_grids.png')
"""
- if self.region is None:
- self.region = self.pf.h.region((self.re + self.le) / 2.0,
- self.le, self.re)
+ self.region = self.pf.h.region((self.re + self.le) / 2.0,
+ self.le, self.re)
corners = self.region.grid_corners
levels = self.region.grid_levels[:,0]
@@ -603,7 +602,7 @@
ax.get_yaxis().set_visible(False)
ax.get_yaxis().set_ticks([])
cb = self._pylab.colorbar(ax.images[0], pad=0.0, fraction=0.05, drawedges=True, shrink=0.9)
- label = self.pf.field_info[self.fields[0]].get_label()
+ label = self.pf._get_field_info(self.fields[0]).get_label()
if self.log_fields[0]:
label = '$\\rm{log}\\/ $' + label
self.transfer_function.vert_cbar(ax=cb.ax, label=label)
diff -r 135d9107b38ea58063d8558f20bdc07a3d9e2aa2 -r acee0c10d242b2b5db723a32695d527949770a13 yt/visualization/volume_rendering/transfer_function_helper.py
--- a/yt/visualization/volume_rendering/transfer_function_helper.py
+++ b/yt/visualization/volume_rendering/transfer_function_helper.py
@@ -99,7 +99,7 @@
"""
self.log = log
self.pf.h
- self.pf.field_info[self.field].take_log = log
+ self.pf._get_field_info(self.field).take_log = log
def build_transfer_function(self):
"""
@@ -185,7 +185,7 @@
ax.set_xscale({True: 'log', False: 'linear'}[self.log])
ax.set_xlim(x.min(), x.max())
- ax.set_xlabel(self.pf.field_info[self.field].get_label())
+ ax.set_xlabel(self.pf._get_field_info(self.field).get_label())
ax.set_ylabel(r'$\mathrm{alpha}$')
ax.set_ylim(y.max()*1.0e-3, y.max()*2)
@@ -204,7 +204,7 @@
prof = BinnedProfile1D(self.pf.h.all_data(), 128, self.field,
self.bounds[0], self.bounds[1],
log_space=self.log,
- lazy_reader=False, end_collect=False)
+ end_collect=False)
prof.add_fields([profile_field], fractional=False,
weight=profile_weight)
self.profiles[self.field] = prof
https://bitbucket.org/yt_analysis/yt/commits/8f660c5ba564/
Changeset: 8f660c5ba564
Branch: yt-3.0
User: jsoishi
Date: 2014-01-20 22:28:55
Summary: merged.
Affected #: 0 files
https://bitbucket.org/yt_analysis/yt/commits/e9b8590087c5/
Changeset: e9b8590087c5
Branch: yt-3.0
User: jsoishi
Date: 2014-01-20 23:00:45
Summary: fixed region to not attach to the object and instead allow it to be passed in.
Affected #: 1 file
diff -r 8f660c5ba564c1ab9fd03e5adf2221778dd5e628 -r e9b8590087c5073c41c2b53ef9ece9a0f289ac80 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -227,7 +227,7 @@
return px, py, dz
def draw_grids(self, im, alpha=0.3, cmap='algae', min_level=None,
- max_level=None):
+ max_level=None, region=None):
r"""Draws Grids on an existing volume rendering.
By mapping grid level to a color, draws edges of grids on
@@ -247,6 +247,8 @@
min_level, max_level : int, optional
Optional parameters to specify the min and max level grid boxes
to overplot on the image.
+ region: YTRegion, optional
+ Optional region over which to draw the grids.
Returns
-------
@@ -259,10 +261,11 @@
>>> write_bitmap(im, 'render_with_grids.png')
"""
- self.region = self.pf.h.region((self.re + self.le) / 2.0,
- self.le, self.re)
- corners = self.region.grid_corners
- levels = self.region.grid_levels[:,0]
+ if region is None:
+ region = self.pf.h.region((self.re + self.le) / 2.0,
+ self.le, self.re)
+ corners = region.grid_corners
+ levels = region.grid_levels[:,0]
if max_level is not None:
subset = levels <= max_level
https://bitbucket.org/yt_analysis/yt/commits/526e04f6fa94/
Changeset: 526e04f6fa94
Branch: yt-3.0
User: jsoishi
Date: 2014-01-20 23:07:12
Summary: removed additional kwarg
Affected #: 1 file
diff -r e9b8590087c5073c41c2b53ef9ece9a0f289ac80 -r 526e04f6fa9426737dde3b837462677b297b21ca yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -227,7 +227,7 @@
return px, py, dz
def draw_grids(self, im, alpha=0.3, cmap='algae', min_level=None,
- max_level=None, region=None):
+ max_level=None):
r"""Draws Grids on an existing volume rendering.
By mapping grid level to a color, draws edges of grids on
@@ -247,8 +247,6 @@
min_level, max_level : int, optional
Optional parameters to specify the min and max level grid boxes
to overplot on the image.
- region: YTRegion, optional
- Optional region over which to draw the grids.
Returns
-------
https://bitbucket.org/yt_analysis/yt/commits/5edcb35f3191/
Changeset: 5edcb35f3191
Branch: yt-3.0
User: jsoishi
Date: 2014-01-20 23:10:14
Summary: minor fix to above.
Affected #: 1 file
diff -r 526e04f6fa9426737dde3b837462677b297b21ca -r 5edcb35f319179e22925db71ef7adf5122595282 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -259,9 +259,8 @@
>>> write_bitmap(im, 'render_with_grids.png')
"""
- if region is None:
- region = self.pf.h.region((self.re + self.le) / 2.0,
- self.le, self.re)
+ region = self.pf.h.region((self.re + self.le) / 2.0,
+ self.le, self.re)
corners = region.grid_corners
levels = region.grid_levels[:,0]
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