[yt-svn] commit/yt: 14 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Jan 19 21:52:22 PST 2017
14 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/790865f3756d/
Changeset: 790865f3756d
Branch: yt
User: al007
Date: 2017-01-10 02:34:58+00:00
Summary: Initial hacky solution to visualize on multiple mesh blocks
- Currently only working with SlicePlot
- Much more refinement o come
Affected #: 9 files
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -495,16 +495,16 @@
def save_as_dataset(self, filename=None, fields=None):
r"""Export a data object to a reloadable yt dataset.
- This function will take a data object and output a dataset
- containing either the fields presently existing or fields
+ This function will take a data object and output a dataset
+ containing either the fields presently existing or fields
given in the ``fields`` list. The resulting dataset can be
reloaded as a yt dataset.
Parameters
----------
filename : str, optional
- The name of the file to be written. If None, the name
- will be a combination of the original dataset and the type
+ The name of the file to be written. If None, the name
+ will be a combination of the original dataset and the type
of data container.
fields : list of string or tuple field names, optional
If this is supplied, it is the list of fields to be saved to
@@ -1258,6 +1258,7 @@
return fields_to_get
def get_data(self, fields=None):
+ # import pdb; pdb.set_trace()
if self._current_chunk is None:
self.index._identify_base_chunk(self)
if fields is None: return
@@ -1319,6 +1320,7 @@
# need to be generated.
read_fluids, gen_fluids = self.index._read_fluid_fields(
fluids, self, self._current_chunk)
+ # import pdb; pdb.set_trace()
for f, v in read_fluids.items():
self.field_data[f] = self.ds.arr(v, input_units = finfos[f].units)
self.field_data[f].convert_to_units(finfos[f].output_units)
@@ -1857,7 +1859,7 @@
def _calculate_flux_in_grid(self, grid, mask, field, value,
field_x, field_y, field_z, fluxing_field = None):
-
+
vc_fields = [field, field_x, field_y, field_z]
if fluxing_field is not None:
vc_fields.append(fluxing_field)
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/data_objects/unstructured_mesh.py
--- a/yt/data_objects/unstructured_mesh.py
+++ b/yt/data_objects/unstructured_mesh.py
@@ -140,6 +140,7 @@
mask = self._get_selector_mask(selector)
count = self.count(selector)
if count == 0: return 0
+ # import pdb; pdb.set_trace()
dest[offset:offset+count] = source[mask, ...]
return count
@@ -158,15 +159,16 @@
return mask
def _get_selector_mask(self, selector):
- if hash(selector) == self._last_selector_id:
- mask = self._last_mask
+ # if hash(selector) == self._last_selector_id:
+ # mask = self._last_mask
+ # else:
+ # import pdb; pdb.set_trace()
+ self._last_mask = mask = selector.fill_mesh_cell_mask(self)
+ self._last_selector_id = hash(selector)
+ if mask is None:
+ self._last_count = 0
else:
- self._last_mask = mask = selector.fill_mesh_cell_mask(self)
- self._last_selector_id = hash(selector)
- if mask is None:
- self._last_count = 0
- else:
- self._last_count = mask.sum()
+ self._last_count = mask.sum()
return mask
def select_fcoords_vertex(self, dobj = None):
@@ -234,4 +236,3 @@
# Note: this likely will not work with vector fields.
dest[offset:offset+count] = source.flat[mask]
return count
-
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -50,10 +50,10 @@
self.meshes = []
for mesh_id, conn_ind in enumerate(connectivity):
displaced_coords = self.ds._apply_displacement(coords, mesh_id)
- mesh = ExodusIIUnstructuredMesh(mesh_id,
+ mesh = ExodusIIUnstructuredMesh(mesh_id,
self.index_filename,
- conn_ind,
- displaced_coords,
+ conn_ind,
+ displaced_coords,
self)
self.meshes.append(mesh)
@@ -61,9 +61,11 @@
elem_names = self.dataset.parameters['elem_names']
node_names = self.dataset.parameters['nod_names']
fnames = elem_names + node_names
+ # import pdb; pdb.set_trace()
self.field_list = []
for i in range(1, len(self.meshes)+1):
self.field_list += [('connect%d' % i, fname) for fname in fnames]
+ self.field_list += [('all', fname) for fname in fnames]
class ExodusIIDataset(Dataset):
@@ -79,7 +81,7 @@
units_override=None):
"""
- A class used to represent an on-disk ExodusII dataset. The initializer takes
+ A class used to represent an on-disk ExodusII dataset. The initializer takes
two extra optional parameters, "step" and "displacements."
Parameters
@@ -88,25 +90,25 @@
step : integer
The step tells which time index to slice at. It throws an Error if
the index is larger than the number of time outputs in the ExodusII
- file. Passing step=-1 picks out the last dataframe.
+ file. Passing step=-1 picks out the last dataframe.
Default is 0.
displacements : dictionary of tuples
This is a dictionary that controls whether or not displacement fields
will be used with the meshes in this dataset. The keys of the
- displacements dictionary should the names of meshes in the file
- (e.g., "connect1", "connect2", etc... ), while the values should be
+ displacements dictionary should the names of meshes in the file
+ (e.g., "connect1", "connect2", etc... ), while the values should be
tuples of the form (scale, offset), where "scale" is a floating point
value and "offset" is an array-like with one component for each spatial
dimension in the dataset. When the displacements for a given mesh are
turned on, the coordinates of the vertices in that mesh get transformed
- as:
+ as:
vertex_x = vertex_x + disp_x*scale + offset_x
vertex_y = vertex_y + disp_y*scale + offset_y
vertex_z = vertex_z + disp_z*scale + offset_z
- If no displacement
+ If no displacement
fields (assumed to be named 'disp_x', 'disp_y', etc... ) are detected in
the output file, then this dictionary is ignored.
@@ -123,7 +125,7 @@
>>> import yt
>>> ds = yt.load("MOOSE_sample_data/mps_out.e", step=-1)
- This will load the Dataset at index 10, turning on displacement fields for
+ This will load the Dataset at index 10, turning on displacement fields for
the 2nd mesh without applying any scale or offset:
>>> import yt
@@ -136,9 +138,9 @@
>>> import yt
>>> ds = yt.load("MOOSE_sample_data/mps_out.e", step=10,
displacements={'connect2': (1.0, [0.0, 0.0, 0.0])})
-
+
This will load the Dataset at index 10, scaling the displacements for
- the 2nd mesh by a factor of 5.0 and shifting all the vertices in
+ the 2nd mesh by a factor of 5.0 and shifting all the vertices in
the first mesh by 1.0 unit in the z direction.
>>> import yt
@@ -158,7 +160,7 @@
units_override=units_override)
self.index_filename = filename
self.storage_filename = storage_filename
- self.default_field = [f for f in self.field_list
+ self.default_field = [f for f in self.field_list
if f[0] == 'connect1'][-1]
for mesh in self.index.meshes:
@@ -224,6 +226,7 @@
i += 1
else:
break
+ fluid_types += ('all',)
return fluid_types
def _read_glo_var(self):
@@ -256,7 +259,7 @@
return self._vars['time_whole'][self.step]
except IndexError:
raise RuntimeError("Invalid step number, max is %d" \
- % (self.num_steps - 1))
+ % (self.num_steps - 1))
except (KeyError, TypeError):
return 0.0
@@ -273,7 +276,7 @@
else:
return [sanitize_string(v.tostring()) for v in
self._vars["name_glo_var"]]
-
+
def _get_elem_names(self):
"""
@@ -308,7 +311,7 @@
Loads the coordinates for the mesh
"""
-
+
coord_axes = 'xyz'[:self.dimensionality]
mylog.info("Loading coordinates")
@@ -321,7 +324,7 @@
return coords
def _apply_displacement(self, coords, mesh_id):
-
+
mesh_name = "connect%d" % (mesh_id + 1)
if mesh_name not in self.displacements:
new_coords = coords.copy()
@@ -339,7 +342,7 @@
new_coords[:, i] = coords[:, i] + fac*disp + offset[i]
return new_coords
-
+
def _read_connectivity(self):
"""
Loads the connectivity data for the mesh
@@ -355,7 +358,7 @@
Loads the boundaries for the domain edge
"""
-
+
coords = self._read_coordinates()
connectivity = self._read_connectivity()
@@ -370,6 +373,18 @@
width = ma - mi
mi -= 0.1 * width
ma += 0.1 * width
+
+ # set up pseudo-3D for lodim datasets here
+ for _ in range(self.dimensionality, 3):
+ mi = np.append(mi, 0.0)
+ ma = np.append(ma, 1.0)
+
+ num_pseudo_dims = get_num_pseudo_dims(coords)
+ self.dimensionality -= num_pseudo_dims
+ for i in range(self.dimensionality, 3):
+ mi[i] = 0.0
+ ma[i] = 1.0
+
return mi, ma
@classmethod
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -46,29 +46,40 @@
# dict gets returned at the end and it should be flat, with selected
# data. Note that if you're reading grid data, you might need to
# special-case a grid selector object.
- chunks = list(chunks)
+ # chunks = list(chunks)
+ chunks = list(chunks)[0]
rv = {}
for field in fields:
ftype, fname = field
- ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ # ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
+ ci = np.concatenate((ci, self.handler.variables['connect2'][:] - self._INDEX_OFFSET))
num_elem = ci.shape[0]
if fname in self.node_fields:
nodes_per_element = ci.shape[1]
- rv[field] = np.empty((num_elem, nodes_per_element), dtype="float64")
+ rv[field] = np.zeros((num_elem, nodes_per_element), dtype="float64")
elif fname in self.elem_fields:
- rv[field] = np.empty(num_elem, dtype="float64")
+ rv[field] = np.zeros(num_elem, dtype="float64")
for field in fields:
ind = 0
ftype, fname = field
mesh_id = int(ftype[-1])
- chunk = chunks[mesh_id - 1]
- ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ # import pdb; pdb.set_trace()
+ # chunk = chunks[mesh_id - 1]
+ # ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ chunk = chunks
+ ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
+ ci = np.concatenate((ci, self.handler.variables['connect2'][:] - self._INDEX_OFFSET))
if fname in self.node_fields:
field_ind = self.node_fields.index(fname)
fdata = self.handler.variables['vals_nod_var%d' % (field_ind + 1)]
data = fdata[self.ds.step][ci]
- for g in chunk.objs:
- ind += g.select(selector, data, rv[field], ind) # caches
+ # for g in chunk.objs:
+ # ind += g.select(selector, data, rv[field], ind) # caches
+ ind += chunk.objs[0].select(selector, data[:50, ...], rv[field], ind) # caches
+ ind += chunk.objs[1].select(selector, data[50:, ...], rv[field], ind)
+ # ind += chunk.objs[0].select(selector, data[:50, ...], rv[field][:50, ...], ind) # caches
+ # ind += chunk.objs[1].select(selector, data[50:, ...], rv[field][50:, ...], ind)
if fname in self.elem_fields:
field_ind = self.elem_fields.index(fname)
fdata = self.handler.variables['vals_elem_var%deb%s' %
@@ -76,6 +87,7 @@
data = fdata[self.ds.step, :]
for g in chunk.objs:
ind += g.select(selector, data, rv[field], ind) # caches
+ # import pdb; pdb.set_trace()
return rv
def _read_chunk_data(self, chunk, fields):
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -70,11 +70,13 @@
ftype, fname = field
mesh_id = int(ftype[-1]) - 1
mesh = index.meshes[mesh_id]
- coords = mesh.connectivity_coords
- indices = mesh.connectivity_indices
+ coords = index.meshes[0].connectivity_coords
+ indices = index.meshes[0].connectivity_indices
+ indices = np.concatenate((indices, index.meshes[1].connectivity_indices))
offset = mesh._index_offset
ad = data_source.ds.all_data()
field_data = ad[field]
+ import pdb; pdb.set_trace()
buff_size = size[0:dimension] + (1,) + size[dimension:]
ax = data_source.axis
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -239,7 +239,8 @@
else:
chunk_size = chunk.data_size
fields_to_return = self.io._read_fluid_selection(
- self._chunk_io(dobj),
+ # self._chunk_io(dobj),
+ self._chunk_all(dobj),
selector,
fields_to_read,
chunk_size)
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/geometry/unstructured_mesh_handler.py
--- a/yt/geometry/unstructured_mesh_handler.py
+++ b/yt/geometry/unstructured_mesh_handler.py
@@ -60,6 +60,7 @@
dobj._chunk_info = self.meshes
if getattr(dobj, "size", None) is None:
dobj.size = self._count_selection(dobj)
+ # import pdb; pdb.set_trace()
dobj._current_chunk = list(self._chunk_all(dobj))[0]
def _count_selection(self, dobj, meshes = None):
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1037,7 +1037,7 @@
@invalidate_plot
def annotate_clear(self, index=None):
"""
- Clear callbacks from the plot. If index is not set, clear all
+ Clear callbacks from the plot. If index is not set, clear all
callbacks. If index is set, clear that index (ie 0 is the first one
created, 1 is the 2nd one created, -1 is the last one created, etc.)
"""
@@ -1052,7 +1052,7 @@
for f in self.fields:
keys = self.frb.keys()
for name, (args, kwargs) in self._callbacks:
- cbw = CallbackWrapper(self, self.plots[f], self.frb, f,
+ cbw = CallbackWrapper(self, self.plots[f], self.frb, f,
self._font_properties, self._font_color)
CallbackMaker = callback_registry[name]
callback = CallbackMaker(*args[1:], **kwargs)
@@ -1070,8 +1070,8 @@
def hide_colorbar(self, field=None):
"""
- Hides the colorbar for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Hides the colorbar for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object.
Parameters
@@ -1111,8 +1111,8 @@
def show_colorbar(self, field=None):
"""
- Shows the colorbar for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Shows the colorbar for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object. See hide_colorbar().
Parameters
@@ -1130,8 +1130,8 @@
def hide_axes(self, field=None):
"""
- Hides the axes for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Hides the axes for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object.
Parameters
@@ -1169,8 +1169,8 @@
def show_axes(self, field=None):
"""
- Shows the axes for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Shows the axes for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object. See hide_axes().
Parameters
@@ -1435,7 +1435,7 @@
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
method : string
- The method of projection. Valid methods are:
+ The method of projection. Valid methods are:
"integrate" with no weight_field specified : integrate the requested
field along the line of sight.
@@ -1484,7 +1484,7 @@
self.ts = ts
ds = self.ds = ts[0]
axis = fix_axis(axis, ds)
- # proj_style is deprecated, but if someone specifies then it trumps
+ # proj_style is deprecated, but if someone specifies then it trumps
# method.
if proj_style is not None:
method = proj_style
@@ -1513,7 +1513,7 @@
field_parameters=field_parameters, method=method,
max_level=max_level)
PWViewerMPL.__init__(self, proj, bounds, fields=fields, origin=origin,
- right_handed=right_handed, fontsize=fontsize, window_size=window_size,
+ right_handed=right_handed, fontsize=fontsize, window_size=window_size,
aspect=aspect)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
diff -r 462126c6d9aefcbb363814d3a406df4fa5ebe959 -r 790865f3756dc5ef84371c77167da024230d0401 yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -109,6 +109,18 @@
def set_zbuffer(self, zbuffer):
self.zbuffer = zbuffer
+ def set_field(self, field):
+ """Set the source's field to render
+
+ Parameters
+ ----------
+
+ field: field name
+ The field to render
+ """
+ self.field = field
+ return self
+
class VolumeSource(RenderSource):
"""A class for rendering data from a volumetric data source
@@ -852,7 +864,7 @@
radii = np.zeros(positions.shape[0], dtype='int64')
else:
assert(radii.ndim == 1)
- assert(radii.shape[0] == positions.shape[0])
+ assert(radii.shape[0] == positions.shape[0])
self.positions = positions
# If colors aren't individually set, make black with full opacity
if colors is None:
@@ -894,7 +906,7 @@
# DRAW SOME POINTS
camera.lens.setup_box_properties(camera)
px, py, dz = camera.lens.project_to_plane(camera, vertices)
-
+
zpoints(empty, z, px, py, dz, self.colors, self.radii, self.color_stride)
self.zbuffer = zbuffer
https://bitbucket.org/yt_analysis/yt/commits/9fa144c179c1/
Changeset: 9fa144c179c1
Branch: yt
User: al007
Date: 2017-01-10 17:12:23+00:00
Summary: Handle chunking in exodus_ii/io
Affected #: 3 files
diff -r 790865f3756dc5ef84371c77167da024230d0401 -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -46,14 +46,16 @@
# dict gets returned at the end and it should be flat, with selected
# data. Note that if you're reading grid data, you might need to
# special-case a grid selector object.
- # chunks = list(chunks)
- chunks = list(chunks)[0]
+ chunks = list(chunks)
rv = {}
for field in fields:
ftype, fname = field
- # ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
- ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
- ci = np.concatenate((ci, self.handler.variables['connect2'][:] - self._INDEX_OFFSET))
+ if ftype == "all":
+ ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
+ for i in range(1, len(self.ds.index.meshes)):
+ ci = np.concatenate((ci, self.handler.variables['connect%d' % (i + 1)][:] - self._INDEX_OFFSET))
+ else:
+ ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
num_elem = ci.shape[0]
if fname in self.node_fields:
nodes_per_element = ci.shape[1]
@@ -63,23 +65,19 @@
for field in fields:
ind = 0
ftype, fname = field
- mesh_id = int(ftype[-1])
- # import pdb; pdb.set_trace()
- # chunk = chunks[mesh_id - 1]
- # ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
- chunk = chunks
- ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
- ci = np.concatenate((ci, self.handler.variables['connect2'][:] - self._INDEX_OFFSET))
+ if ftype == "all":
+ objs = [chunk.objs[0] for chunk in chunks]
+ else:
+ mesh_id = int(ftype[-1])
+ chunk = chunks[mesh_id - 1]
+ objs = chunk.objs
if fname in self.node_fields:
field_ind = self.node_fields.index(fname)
fdata = self.handler.variables['vals_nod_var%d' % (field_ind + 1)]
- data = fdata[self.ds.step][ci]
- # for g in chunk.objs:
- # ind += g.select(selector, data, rv[field], ind) # caches
- ind += chunk.objs[0].select(selector, data[:50, ...], rv[field], ind) # caches
- ind += chunk.objs[1].select(selector, data[50:, ...], rv[field], ind)
- # ind += chunk.objs[0].select(selector, data[:50, ...], rv[field][:50, ...], ind) # caches
- # ind += chunk.objs[1].select(selector, data[50:, ...], rv[field][50:, ...], ind)
+ for g in objs:
+ ci = g.connectivity_indices - self._INDEX_OFFSET
+ data = fdata[self.ds.step][ci]
+ ind += g.select(selector, data, rv[field], ind) # caches
if fname in self.elem_fields:
field_ind = self.elem_fields.index(fname)
fdata = self.handler.variables['vals_elem_var%deb%s' %
diff -r 790865f3756dc5ef84371c77167da024230d0401 -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -68,12 +68,17 @@
if (hasattr(index, 'meshes') and
not isinstance(index.meshes[0], SemiStructuredMesh)):
ftype, fname = field
- mesh_id = int(ftype[-1]) - 1
- mesh = index.meshes[mesh_id]
- coords = index.meshes[0].connectivity_coords
- indices = index.meshes[0].connectivity_indices
- indices = np.concatenate((indices, index.meshes[1].connectivity_indices))
- offset = mesh._index_offset
+ if ftype == "all":
+ mesh_id = 0
+ indices = index.meshes[0].connectivity_indices
+ for i in range(1, len(index.meshes)):
+ indices = np.concatenate((indices, index.meshes[i].connectivity_indices))
+ else:
+ mesh_id = int(ftype[-1]) - 1
+ indices = index.meshes[mesh_id].connectivity_indices
+
+ coords = index.meshes[mesh_id].connectivity_coords
+ offset = index.meshes[mesh_id]._index_offset
ad = data_source.ds.all_data()
field_data = ad[field]
import pdb; pdb.set_trace()
diff -r 790865f3756dc5ef84371c77167da024230d0401 -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -239,8 +239,7 @@
else:
chunk_size = chunk.data_size
fields_to_return = self.io._read_fluid_selection(
- # self._chunk_io(dobj),
- self._chunk_all(dobj),
+ self._chunk_io(dobj),
selector,
fields_to_read,
chunk_size)
https://bitbucket.org/yt_analysis/yt/commits/ab5463b38b51/
Changeset: ab5463b38b51
Branch: yt
User: al007
Date: 2017-01-10 17:27:57+00:00
Summary: Remove pdb traces and other extraneous modifications.
Affected #: 7 files
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -495,16 +495,16 @@
def save_as_dataset(self, filename=None, fields=None):
r"""Export a data object to a reloadable yt dataset.
- This function will take a data object and output a dataset
- containing either the fields presently existing or fields
+ This function will take a data object and output a dataset
+ containing either the fields presently existing or fields
given in the ``fields`` list. The resulting dataset can be
reloaded as a yt dataset.
Parameters
----------
filename : str, optional
- The name of the file to be written. If None, the name
- will be a combination of the original dataset and the type
+ The name of the file to be written. If None, the name
+ will be a combination of the original dataset and the type
of data container.
fields : list of string or tuple field names, optional
If this is supplied, it is the list of fields to be saved to
@@ -1258,7 +1258,6 @@
return fields_to_get
def get_data(self, fields=None):
- # import pdb; pdb.set_trace()
if self._current_chunk is None:
self.index._identify_base_chunk(self)
if fields is None: return
@@ -1320,7 +1319,6 @@
# need to be generated.
read_fluids, gen_fluids = self.index._read_fluid_fields(
fluids, self, self._current_chunk)
- # import pdb; pdb.set_trace()
for f, v in read_fluids.items():
self.field_data[f] = self.ds.arr(v, input_units = finfos[f].units)
self.field_data[f].convert_to_units(finfos[f].output_units)
@@ -1859,7 +1857,7 @@
def _calculate_flux_in_grid(self, grid, mask, field, value,
field_x, field_y, field_z, fluxing_field = None):
-
+
vc_fields = [field, field_x, field_y, field_z]
if fluxing_field is not None:
vc_fields.append(fluxing_field)
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/data_objects/unstructured_mesh.py
--- a/yt/data_objects/unstructured_mesh.py
+++ b/yt/data_objects/unstructured_mesh.py
@@ -140,7 +140,6 @@
mask = self._get_selector_mask(selector)
count = self.count(selector)
if count == 0: return 0
- # import pdb; pdb.set_trace()
dest[offset:offset+count] = source[mask, ...]
return count
@@ -159,16 +158,15 @@
return mask
def _get_selector_mask(self, selector):
- # if hash(selector) == self._last_selector_id:
- # mask = self._last_mask
- # else:
- # import pdb; pdb.set_trace()
- self._last_mask = mask = selector.fill_mesh_cell_mask(self)
- self._last_selector_id = hash(selector)
- if mask is None:
- self._last_count = 0
+ if hash(selector) == self._last_selector_id:
+ mask = self._last_mask
else:
- self._last_count = mask.sum()
+ self._last_mask = mask = selector.fill_mesh_cell_mask(self)
+ self._last_selector_id = hash(selector)
+ if mask is None:
+ self._last_count = 0
+ else:
+ self._last_count = mask.sum()
return mask
def select_fcoords_vertex(self, dobj = None):
@@ -236,3 +234,4 @@
# Note: this likely will not work with vector fields.
dest[offset:offset+count] = source.flat[mask]
return count
+
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -61,7 +61,6 @@
elem_names = self.dataset.parameters['elem_names']
node_names = self.dataset.parameters['nod_names']
fnames = elem_names + node_names
- # import pdb; pdb.set_trace()
self.field_list = []
for i in range(1, len(self.meshes)+1):
self.field_list += [('connect%d' % i, fname) for fname in fnames]
@@ -373,18 +372,6 @@
width = ma - mi
mi -= 0.1 * width
ma += 0.1 * width
-
- # set up pseudo-3D for lodim datasets here
- for _ in range(self.dimensionality, 3):
- mi = np.append(mi, 0.0)
- ma = np.append(ma, 1.0)
-
- num_pseudo_dims = get_num_pseudo_dims(coords)
- self.dimensionality -= num_pseudo_dims
- for i in range(self.dimensionality, 3):
- mi[i] = 0.0
- ma[i] = 1.0
-
return mi, ma
@classmethod
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -85,7 +85,6 @@
data = fdata[self.ds.step, :]
for g in chunk.objs:
ind += g.select(selector, data, rv[field], ind) # caches
- # import pdb; pdb.set_trace()
return rv
def _read_chunk_data(self, chunk, fields):
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -81,7 +81,6 @@
offset = index.meshes[mesh_id]._index_offset
ad = data_source.ds.all_data()
field_data = ad[field]
- import pdb; pdb.set_trace()
buff_size = size[0:dimension] + (1,) + size[dimension:]
ax = data_source.axis
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/geometry/unstructured_mesh_handler.py
--- a/yt/geometry/unstructured_mesh_handler.py
+++ b/yt/geometry/unstructured_mesh_handler.py
@@ -60,7 +60,6 @@
dobj._chunk_info = self.meshes
if getattr(dobj, "size", None) is None:
dobj.size = self._count_selection(dobj)
- # import pdb; pdb.set_trace()
dobj._current_chunk = list(self._chunk_all(dobj))[0]
def _count_selection(self, dobj, meshes = None):
diff -r 9fa144c179c1ea4d3b582f57d93f3bfb9d07d747 -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -109,18 +109,6 @@
def set_zbuffer(self, zbuffer):
self.zbuffer = zbuffer
- def set_field(self, field):
- """Set the source's field to render
-
- Parameters
- ----------
-
- field: field name
- The field to render
- """
- self.field = field
- return self
-
class VolumeSource(RenderSource):
"""A class for rendering data from a volumetric data source
@@ -864,7 +852,7 @@
radii = np.zeros(positions.shape[0], dtype='int64')
else:
assert(radii.ndim == 1)
- assert(radii.shape[0] == positions.shape[0])
+ assert(radii.shape[0] == positions.shape[0])
self.positions = positions
# If colors aren't individually set, make black with full opacity
if colors is None:
@@ -906,7 +894,7 @@
# DRAW SOME POINTS
camera.lens.setup_box_properties(camera)
px, py, dz = camera.lens.project_to_plane(camera, vertices)
-
+
zpoints(empty, z, px, py, dz, self.colors, self.radii, self.color_stride)
self.zbuffer = zbuffer
https://bitbucket.org/yt_analysis/yt/commits/1b17fcd70a31/
Changeset: 1b17fcd70a31
Branch: yt
User: al007
Date: 2017-01-10 17:32:48+00:00
Summary: Undo whitespace changes to plot_window
Affected #: 1 file
diff -r ab5463b38b511246f3eb6322936ad0dc6f0eb65b -r 1b17fcd70a31959844d91becce631a0cfcd51f41 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1037,7 +1037,7 @@
@invalidate_plot
def annotate_clear(self, index=None):
"""
- Clear callbacks from the plot. If index is not set, clear all
+ Clear callbacks from the plot. If index is not set, clear all
callbacks. If index is set, clear that index (ie 0 is the first one
created, 1 is the 2nd one created, -1 is the last one created, etc.)
"""
@@ -1052,7 +1052,7 @@
for f in self.fields:
keys = self.frb.keys()
for name, (args, kwargs) in self._callbacks:
- cbw = CallbackWrapper(self, self.plots[f], self.frb, f,
+ cbw = CallbackWrapper(self, self.plots[f], self.frb, f,
self._font_properties, self._font_color)
CallbackMaker = callback_registry[name]
callback = CallbackMaker(*args[1:], **kwargs)
@@ -1070,8 +1070,8 @@
def hide_colorbar(self, field=None):
"""
- Hides the colorbar for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Hides the colorbar for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object.
Parameters
@@ -1111,8 +1111,8 @@
def show_colorbar(self, field=None):
"""
- Shows the colorbar for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Shows the colorbar for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object. See hide_colorbar().
Parameters
@@ -1130,8 +1130,8 @@
def hide_axes(self, field=None):
"""
- Hides the axes for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Hides the axes for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object.
Parameters
@@ -1169,8 +1169,8 @@
def show_axes(self, field=None):
"""
- Shows the axes for a plot and updates the size of the
- plot accordingly. Defaults to operating on all fields for a
+ Shows the axes for a plot and updates the size of the
+ plot accordingly. Defaults to operating on all fields for a
PlotWindow object. See hide_axes().
Parameters
@@ -1435,7 +1435,7 @@
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
method : string
- The method of projection. Valid methods are:
+ The method of projection. Valid methods are:
"integrate" with no weight_field specified : integrate the requested
field along the line of sight.
@@ -1484,7 +1484,7 @@
self.ts = ts
ds = self.ds = ts[0]
axis = fix_axis(axis, ds)
- # proj_style is deprecated, but if someone specifies then it trumps
+ # proj_style is deprecated, but if someone specifies then it trumps
# method.
if proj_style is not None:
method = proj_style
@@ -1513,7 +1513,7 @@
field_parameters=field_parameters, method=method,
max_level=max_level)
PWViewerMPL.__init__(self, proj, bounds, fields=fields, origin=origin,
- right_handed=right_handed, fontsize=fontsize, window_size=window_size,
+ right_handed=right_handed, fontsize=fontsize, window_size=window_size,
aspect=aspect)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
https://bitbucket.org/yt_analysis/yt/commits/54c79e656e31/
Changeset: 54c79e656e31
Branch: yt
User: al007
Date: 2017-01-10 22:11:42+00:00
Summary: Make elemental variables work.
- Also add answer test that tests both nodal and elemental variables
Affected #: 3 files
diff -r 1b17fcd70a31959844d91becce631a0cfcd51f41 -r 54c79e656e312fe7dcefd7a41b78ad6297569642 yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -66,10 +66,11 @@
ind = 0
ftype, fname = field
if ftype == "all":
+ mesh_ids = [i + 1 for i in range(len(chunks))]
objs = [chunk.objs[0] for chunk in chunks]
else:
- mesh_id = int(ftype[-1])
- chunk = chunks[mesh_id - 1]
+ mesh_ids = [int(ftype[-1])]
+ chunk = chunks[mesh_ids[0] - 1]
objs = chunk.objs
if fname in self.node_fields:
field_ind = self.node_fields.index(fname)
@@ -80,10 +81,10 @@
ind += g.select(selector, data, rv[field], ind) # caches
if fname in self.elem_fields:
field_ind = self.elem_fields.index(fname)
- fdata = self.handler.variables['vals_elem_var%deb%s' %
- (field_ind + 1, mesh_id)][:]
- data = fdata[self.ds.step, :]
- for g in chunk.objs:
+ for g, mesh_id in zip(objs, mesh_ids):
+ fdata = self.handler.variables['vals_elem_var%deb%s' %
+ (field_ind + 1, mesh_id)][:]
+ data = fdata[self.ds.step, :]
ind += g.select(selector, data, rv[field], ind) # caches
return rv
diff -r 1b17fcd70a31959844d91becce631a0cfcd51f41 -r 54c79e656e312fe7dcefd7a41b78ad6297569642 yt/frontends/exodus_ii/tests/test_outputs.py
--- a/yt/frontends/exodus_ii/tests/test_outputs.py
+++ b/yt/frontends/exodus_ii/tests/test_outputs.py
@@ -29,7 +29,11 @@
@requires_file(out)
def test_out():
ds = data_dir_load(out)
- field_list = [('connect1', 'conv_indicator'),
+ field_list = [('all', 'conv_indicator'),
+ ('all', 'conv_marker'),
+ ('all', 'convected'),
+ ('all', 'diffused'),
+ ('connect1', 'conv_indicator'),
('connect1', 'conv_marker'),
('connect1', 'convected'),
('connect1', 'diffused'),
@@ -42,7 +46,7 @@
yield assert_equal, ds.current_time, 0.0
yield assert_array_equal, ds.parameters['nod_names'], ['convected', 'diffused']
yield assert_equal, ds.parameters['num_meshes'], 2
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
out_s002 = "ExodusII/out.e-s002"
@@ -50,7 +54,11 @@
@requires_file(out_s002)
def test_out002():
ds = data_dir_load(out_s002)
- field_list = [('connect1', 'conv_indicator'),
+ field_list = [('all', 'conv_indicator'),
+ ('all', 'conv_marker'),
+ ('all', 'convected'),
+ ('all', 'diffused'),
+ ('connect1', 'conv_indicator'),
('connect1', 'conv_marker'),
('connect1', 'convected'),
('connect1', 'diffused'),
@@ -61,7 +69,7 @@
yield assert_equal, str(ds), "out.e-s002"
yield assert_equal, ds.dimensionality, 3
yield assert_equal, ds.current_time, 2.0
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
gold = "ExodusII/gold.e"
@@ -69,9 +77,9 @@
@requires_file(gold)
def test_gold():
ds = data_dir_load(gold)
- field_list = [('connect1', 'forced')]
+ field_list = [('all', 'forced'), ('connect1', 'forced')]
yield assert_equal, str(ds), "gold.e"
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
big_data = "MOOSE_sample_data/mps_out.e"
@@ -79,7 +87,7 @@
@requires_ds(big_data)
def test_displacement_fields():
displacement_dicts =[{'connect2': (5.0, [0.0, 0.0, 0.0])},
- {'connect1': (1.0, [1.0, 2.0, 3.0]),
+ {'connect1': (1.0, [1.0, 2.0, 3.0]),
'connect2': (0.0, [0.0, 0.0, 0.0])}]
for disp in displacement_dicts:
ds = data_dir_load(big_data, displacements=disp)
diff -r 1b17fcd70a31959844d91becce631a0cfcd51f41 -r 54c79e656e312fe7dcefd7a41b78ad6297569642 yt/visualization/tests/test_mesh_slices.py
--- a/yt/visualization/tests/test_mesh_slices.py
+++ b/yt/visualization/tests/test_mesh_slices.py
@@ -49,6 +49,14 @@
for field in ds.field_list:
yield compare(ds, field, "answers_tri2_%s_%s" % (field[0], field[1]))
+multi_region = "MultiRegion/two_region_example_out.e"
+
+ at requires_ds(multi_region)
+def test_multi_region():
+ ds = data_dir_load(multi_region, kwargs={'step':-1})
+ for field in ds.field_list:
+ yield compare(ds, field, "answers_multi_region_%s_%s" % (field[0], field[1]))
+
def test_mesh_slices():
# Perform I/O in safe place instead of yt main dir
tmpdir = tempfile.mkdtemp()
https://bitbucket.org/yt_analysis/yt/commits/d5c8875f9b1a/
Changeset: d5c8875f9b1a
Branch: yt
User: al007
Date: 2017-01-10 22:18:26+00:00
Summary: Increment answer tests.
Affected #: 1 file
diff -r 54c79e656e312fe7dcefd7a41b78ad6297569642 -r d5c8875f9b1af718482abf5a5c169f48f393ab0b tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -50,7 +50,7 @@
local_tipsy_002:
- yt/frontends/tipsy/tests/test_outputs.py
- local_varia_007:
+ local_varia_008:
- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
- yt/analysis_modules/photon_simulator/tests/test_spectra.py
@@ -58,6 +58,7 @@
- yt/visualization/volume_rendering/tests/test_vr_orientation.py
- yt/visualization/volume_rendering/tests/test_mesh_render.py
- yt/visualization/tests/test_mesh_slices.py:test_tri2
+ - yt/visualization/tests/test_mesh_slices.py:test_multi_region
local_orion_001:
- yt/frontends/boxlib/tests/test_orion.py
https://bitbucket.org/yt_analysis/yt/commits/ff3e6a8ab507/
Changeset: ff3e6a8ab507
Branch: yt
User: al007
Date: 2017-01-10 23:14:53+00:00
Summary: A very trivial use of a mesh Union
Affected #: 3 files
diff -r d5c8875f9b1af718482abf5a5c169f48f393ab0b -r ff3e6a8ab5072ca113cf79387c3f123ff211afc4 yt/data_objects/unions.py
--- /dev/null
+++ b/yt/data_objects/unions.py
@@ -0,0 +1,10 @@
+from yt.funcs import ensure_list
+
+class Union(object):
+ def __init__(self, name, sub_types):
+ self.name = name
+ self.sub_types = ensure_list(sub_types)
+
+ def __iter__(self):
+ for st in self.sub_types:
+ yield st
diff -r d5c8875f9b1af718482abf5a5c169f48f393ab0b -r ff3e6a8ab5072ca113cf79387c3f123ff211afc4 yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -22,6 +22,7 @@
UnstructuredMesh
from yt.data_objects.static_output import \
Dataset
+from yt.data_objects.unions import Union
from .io import \
NetCDF4FileHandler
from yt.utilities.logger import ytLogger as mylog
@@ -56,6 +57,7 @@
displaced_coords,
self)
self.meshes.append(mesh)
+ self.mesh_union = Union("mesh_union", self.meshes)
def _detect_output_fields(self):
elem_names = self.dataset.parameters['elem_names']
diff -r d5c8875f9b1af718482abf5a5c169f48f393ab0b -r ff3e6a8ab5072ca113cf79387c3f123ff211afc4 yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -66,8 +66,8 @@
ind = 0
ftype, fname = field
if ftype == "all":
- mesh_ids = [i + 1 for i in range(len(chunks))]
- objs = [chunk.objs[0] for chunk in chunks]
+ mesh_ids = [mesh.mesh_id + 1 for mesh in self.ds.index.mesh_union]
+ objs = [mesh for mesh in self.ds.index.mesh_union]
else:
mesh_ids = [int(ftype[-1])]
chunk = chunks[mesh_ids[0] - 1]
https://bitbucket.org/yt_analysis/yt/commits/5f70b1e7cae4/
Changeset: 5f70b1e7cae4
Branch: yt
User: al007
Date: 2017-01-11 15:06:48+00:00
Summary: Convert connectivity indices code into single line
Affected #: 2 files
diff -r ff3e6a8ab5072ca113cf79387c3f123ff211afc4 -r 5f70b1e7cae4a21c418ad4a52197cd2b84e86c7f yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -51,9 +51,8 @@
for field in fields:
ftype, fname = field
if ftype == "all":
- ci = self.handler.variables['connect1'][:] - self._INDEX_OFFSET
- for i in range(1, len(self.ds.index.meshes)):
- ci = np.concatenate((ci, self.handler.variables['connect%d' % (i + 1)][:] - self._INDEX_OFFSET))
+ ci = np.concatenate([mesh.connectivity_indices - self._INDEX_OFFSET \
+ for mesh in self.ds.index.mesh_union])
else:
ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
num_elem = ci.shape[0]
diff -r ff3e6a8ab5072ca113cf79387c3f123ff211afc4 -r 5f70b1e7cae4a21c418ad4a52197cd2b84e86c7f yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -70,9 +70,7 @@
ftype, fname = field
if ftype == "all":
mesh_id = 0
- indices = index.meshes[0].connectivity_indices
- for i in range(1, len(index.meshes)):
- indices = np.concatenate((indices, index.meshes[i].connectivity_indices))
+ indices = np.concatenate([mesh.connectivity_indices for mesh in index.mesh_union])
else:
mesh_id = int(ftype[-1]) - 1
indices = index.meshes[mesh_id].connectivity_indices
https://bitbucket.org/yt_analysis/yt/commits/d620ea41564b/
Changeset: d620ea41564b
Branch: yt
User: al007
Date: 2017-01-12 15:36:28+00:00
Summary: Remove Union code duplication and create MeshUnion class.
Affected #: 3 files
diff -r 5f70b1e7cae4a21c418ad4a52197cd2b84e86c7f -r d620ea41564bc940512a06795bcd5d42aa571cbf yt/data_objects/particle_unions.py
--- a/yt/data_objects/particle_unions.py
+++ b/yt/data_objects/particle_unions.py
@@ -16,12 +16,8 @@
#-----------------------------------------------------------------------------
from yt.funcs import ensure_list
+from .unions import Union
-class ParticleUnion(object):
+class ParticleUnion(Union):
def __init__(self, name, sub_types):
- self.name = name
- self.sub_types = ensure_list(sub_types)
-
- def __iter__(self):
- for st in self.sub_types:
- yield st
+ super(ParticleUnion, self).__init__(name, sub_types)
diff -r 5f70b1e7cae4a21c418ad4a52197cd2b84e86c7f -r d620ea41564bc940512a06795bcd5d42aa571cbf yt/data_objects/unions.py
--- a/yt/data_objects/unions.py
+++ b/yt/data_objects/unions.py
@@ -1,3 +1,20 @@
+"""
+Union structures which can be used to form unions of particles, meshes,
+etc. Union is the base class from which trivial named union classes
+can be derived
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2016, 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 ensure_list
class Union(object):
@@ -8,3 +25,7 @@
def __iter__(self):
for st in self.sub_types:
yield st
+
+class MeshUnion(Union):
+ def __init__(self, name, sub_types):
+ super(ParticleUnion, self).__init__(name, sub_types)
diff -r 5f70b1e7cae4a21c418ad4a52197cd2b84e86c7f -r d620ea41564bc940512a06795bcd5d42aa571cbf yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -22,7 +22,7 @@
UnstructuredMesh
from yt.data_objects.static_output import \
Dataset
-from yt.data_objects.unions import Union
+from yt.data_objects.unions import MeshUnion
from .io import \
NetCDF4FileHandler
from yt.utilities.logger import ytLogger as mylog
@@ -57,7 +57,7 @@
displaced_coords,
self)
self.meshes.append(mesh)
- self.mesh_union = Union("mesh_union", self.meshes)
+ self.mesh_union = MeshUnion("mesh_union", self.meshes)
def _detect_output_fields(self):
elem_names = self.dataset.parameters['elem_names']
https://bitbucket.org/yt_analysis/yt/commits/cd738cdad30d/
Changeset: cd738cdad30d
Branch: yt
User: al007
Date: 2017-01-12 16:47:04+00:00
Summary: Fix ParticleUnion not found and needless import.
Affected #: 2 files
diff -r d620ea41564bc940512a06795bcd5d42aa571cbf -r cd738cdad30d9c26c36f93cab154f241a06e20cc yt/data_objects/particle_unions.py
--- a/yt/data_objects/particle_unions.py
+++ b/yt/data_objects/particle_unions.py
@@ -15,7 +15,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.funcs import ensure_list
from .unions import Union
class ParticleUnion(Union):
diff -r d620ea41564bc940512a06795bcd5d42aa571cbf -r cd738cdad30d9c26c36f93cab154f241a06e20cc yt/data_objects/unions.py
--- a/yt/data_objects/unions.py
+++ b/yt/data_objects/unions.py
@@ -28,4 +28,4 @@
class MeshUnion(Union):
def __init__(self, name, sub_types):
- super(ParticleUnion, self).__init__(name, sub_types)
+ super(MeshUnion, self).__init__(name, sub_types)
https://bitbucket.org/yt_analysis/yt/commits/45a3fbcb9131/
Changeset: 45a3fbcb9131
Branch: yt
User: al007
Date: 2017-01-17 16:02:21+00:00
Summary: Add documentation.
Affected #: 1 file
diff -r cd738cdad30d9c26c36f93cab154f241a06e20cc -r 45a3fbcb9131691284c777725a265d46199a528d doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -441,7 +441,7 @@
sl = yt.SlicePlot(ds, 2, ('connect2', 'diffused'))
sl.save()
-Finally, slices can also be used to examine 2D unstructured mesh datasets, but the
+Slices can also be used to examine 2D unstructured mesh datasets, but the
slices must be taken to be normal to the ``'z'`` axis, or you'll get an error. Here is
an example using another MOOSE dataset that uses triangular mesh elements:
@@ -452,6 +452,17 @@
sl = yt.SlicePlot(ds, 2, ('connect1', 'nodal_aux'))
sl.save()
+You may run into situations where you have a variable you want to visualize that
+exists on multiple mesh blocks. To view the variable on ``all`` mesh blocks,
+simply pass ``all`` as the first argument of the field tuple:
+
+.. python-script::
+
+ import yt
+ ds = yt.load("MultiRegion/two_region_example_out.e", step=-1)
+ sl = yt.SlicePlot(ds, 'z', ('all', 'diffused'))
+ sl.save()
+
Plot Customization: Recentering, Resizing, Colormaps, and More
--------------------------------------------------------------
https://bitbucket.org/yt_analysis/yt/commits/51b6bfe119a5/
Changeset: 51b6bfe119a5
Branch: yt
User: al007
Date: 2017-01-17 18:00:50+00:00
Summary: Split up local_varia into more sensical, descriptive names. Makes test competition less likely.
Affected #: 1 file
diff -r 45a3fbcb9131691284c777725a265d46199a528d -r 51b6bfe119a59c538c7217fbdb024b28f13bb258 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -53,9 +53,13 @@
local_varia_008:
- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
+ - yt/visualization/volume_rendering/tests/test_vr_orientation.py
+
+ local_photon_001:
- yt/analysis_modules/photon_simulator/tests/test_spectra.py
- yt/analysis_modules/photon_simulator/tests/test_sloshing.py
- - yt/visualization/volume_rendering/tests/test_vr_orientation.py
+
+ local_unstructured_001:
- yt/visualization/volume_rendering/tests/test_mesh_render.py
- yt/visualization/tests/test_mesh_slices.py:test_tri2
- yt/visualization/tests/test_mesh_slices.py:test_multi_region
https://bitbucket.org/yt_analysis/yt/commits/ec40fec890cf/
Changeset: ec40fec890cf
Branch: yt
User: al007
Date: 2017-01-20 00:35:45+00:00
Summary: Merge in multiple_region bookmark. Resolve conflict in tests.yaml
Affected #: 15 files
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -441,7 +441,7 @@
sl = yt.SlicePlot(ds, 2, ('connect2', 'diffused'))
sl.save()
-Finally, slices can also be used to examine 2D unstructured mesh datasets, but the
+Slices can also be used to examine 2D unstructured mesh datasets, but the
slices must be taken to be normal to the ``'z'`` axis, or you'll get an error. Here is
an example using another MOOSE dataset that uses triangular mesh elements:
@@ -452,6 +452,17 @@
sl = yt.SlicePlot(ds, 2, ('connect1', 'nodal_aux'))
sl.save()
+You may run into situations where you have a variable you want to visualize that
+exists on multiple mesh blocks. To view the variable on ``all`` mesh blocks,
+simply pass ``all`` as the first argument of the field tuple:
+
+.. python-script::
+
+ import yt
+ ds = yt.load("MultiRegion/two_region_example_out.e", step=-1)
+ sl = yt.SlicePlot(ds, 'z', ('all', 'diffused'))
+ sl.save()
+
Plot Customization: Recentering, Resizing, Colormaps, and More
--------------------------------------------------------------
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -56,12 +56,17 @@
local_varia_008:
- yt/analysis_modules/radmc3d_export
- yt/frontends/moab/tests/test_c5.py
+ - yt/visualization/volume_rendering/tests/test_vr_orientation.py
+ - yt/fields/tests/test_xray_fields.py
+
+ local_photon_001:
- yt/analysis_modules/photon_simulator/tests/test_spectra.py
- yt/analysis_modules/photon_simulator/tests/test_sloshing.py
- - yt/visualization/volume_rendering/tests/test_vr_orientation.py
+
+ local_unstructured_001:
- yt/visualization/volume_rendering/tests/test_mesh_render.py
- yt/visualization/tests/test_mesh_slices.py:test_tri2
- - yt/fields/tests/test_xray_fields.py
+ - yt/visualization/tests/test_mesh_slices.py:test_multi_region
local_orion_001:
- yt/frontends/boxlib/tests/test_orion.py
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/data_objects/particle_unions.py
--- a/yt/data_objects/particle_unions.py
+++ b/yt/data_objects/particle_unions.py
@@ -15,13 +15,8 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.funcs import ensure_list
+from .unions import Union
-class ParticleUnion(object):
+class ParticleUnion(Union):
def __init__(self, name, sub_types):
- self.name = name
- self.sub_types = ensure_list(sub_types)
-
- def __iter__(self):
- for st in self.sub_types:
- yield st
+ super(ParticleUnion, self).__init__(name, sub_types)
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/data_objects/unions.py
--- /dev/null
+++ b/yt/data_objects/unions.py
@@ -0,0 +1,31 @@
+"""
+Union structures which can be used to form unions of particles, meshes,
+etc. Union is the base class from which trivial named union classes
+can be derived
+
+
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2016, 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 ensure_list
+
+class Union(object):
+ def __init__(self, name, sub_types):
+ self.name = name
+ self.sub_types = ensure_list(sub_types)
+
+ def __iter__(self):
+ for st in self.sub_types:
+ yield st
+
+class MeshUnion(Union):
+ def __init__(self, name, sub_types):
+ super(MeshUnion, self).__init__(name, sub_types)
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/frontends/exodus_ii/data_structures.py
--- a/yt/frontends/exodus_ii/data_structures.py
+++ b/yt/frontends/exodus_ii/data_structures.py
@@ -22,6 +22,7 @@
UnstructuredMesh
from yt.data_objects.static_output import \
Dataset
+from yt.data_objects.unions import MeshUnion
from .io import \
NetCDF4FileHandler
from yt.utilities.logger import ytLogger as mylog
@@ -50,12 +51,13 @@
self.meshes = []
for mesh_id, conn_ind in enumerate(connectivity):
displaced_coords = self.ds._apply_displacement(coords, mesh_id)
- mesh = ExodusIIUnstructuredMesh(mesh_id,
+ mesh = ExodusIIUnstructuredMesh(mesh_id,
self.index_filename,
- conn_ind,
- displaced_coords,
+ conn_ind,
+ displaced_coords,
self)
self.meshes.append(mesh)
+ self.mesh_union = MeshUnion("mesh_union", self.meshes)
def _detect_output_fields(self):
elem_names = self.dataset.parameters['elem_names']
@@ -64,6 +66,7 @@
self.field_list = []
for i in range(1, len(self.meshes)+1):
self.field_list += [('connect%d' % i, fname) for fname in fnames]
+ self.field_list += [('all', fname) for fname in fnames]
class ExodusIIDataset(Dataset):
@@ -79,7 +82,7 @@
units_override=None):
"""
- A class used to represent an on-disk ExodusII dataset. The initializer takes
+ A class used to represent an on-disk ExodusII dataset. The initializer takes
two extra optional parameters, "step" and "displacements."
Parameters
@@ -88,25 +91,25 @@
step : integer
The step tells which time index to slice at. It throws an Error if
the index is larger than the number of time outputs in the ExodusII
- file. Passing step=-1 picks out the last dataframe.
+ file. Passing step=-1 picks out the last dataframe.
Default is 0.
displacements : dictionary of tuples
This is a dictionary that controls whether or not displacement fields
will be used with the meshes in this dataset. The keys of the
- displacements dictionary should the names of meshes in the file
- (e.g., "connect1", "connect2", etc... ), while the values should be
+ displacements dictionary should the names of meshes in the file
+ (e.g., "connect1", "connect2", etc... ), while the values should be
tuples of the form (scale, offset), where "scale" is a floating point
value and "offset" is an array-like with one component for each spatial
dimension in the dataset. When the displacements for a given mesh are
turned on, the coordinates of the vertices in that mesh get transformed
- as:
+ as:
vertex_x = vertex_x + disp_x*scale + offset_x
vertex_y = vertex_y + disp_y*scale + offset_y
vertex_z = vertex_z + disp_z*scale + offset_z
- If no displacement
+ If no displacement
fields (assumed to be named 'disp_x', 'disp_y', etc... ) are detected in
the output file, then this dictionary is ignored.
@@ -123,7 +126,7 @@
>>> import yt
>>> ds = yt.load("MOOSE_sample_data/mps_out.e", step=-1)
- This will load the Dataset at index 10, turning on displacement fields for
+ This will load the Dataset at index 10, turning on displacement fields for
the 2nd mesh without applying any scale or offset:
>>> import yt
@@ -136,9 +139,9 @@
>>> import yt
>>> ds = yt.load("MOOSE_sample_data/mps_out.e", step=10,
displacements={'connect2': (1.0, [0.0, 0.0, 0.0])})
-
+
This will load the Dataset at index 10, scaling the displacements for
- the 2nd mesh by a factor of 5.0 and shifting all the vertices in
+ the 2nd mesh by a factor of 5.0 and shifting all the vertices in
the first mesh by 1.0 unit in the z direction.
>>> import yt
@@ -158,7 +161,7 @@
units_override=units_override)
self.index_filename = filename
self.storage_filename = storage_filename
- self.default_field = [f for f in self.field_list
+ self.default_field = [f for f in self.field_list
if f[0] == 'connect1'][-1]
def _set_code_unit_attributes(self):
@@ -212,6 +215,7 @@
i += 1
else:
break
+ fluid_types += ('all',)
return fluid_types
def _read_glo_var(self):
@@ -244,7 +248,7 @@
return self._vars['time_whole'][self.step]
except IndexError:
raise RuntimeError("Invalid step number, max is %d" \
- % (self.num_steps - 1))
+ % (self.num_steps - 1))
except (KeyError, TypeError):
return 0.0
@@ -261,7 +265,7 @@
else:
return [sanitize_string(v.tostring()) for v in
self._vars["name_glo_var"]]
-
+
def _get_elem_names(self):
"""
@@ -296,7 +300,7 @@
Loads the coordinates for the mesh
"""
-
+
coord_axes = 'xyz'[:self.dimensionality]
mylog.info("Loading coordinates")
@@ -309,7 +313,7 @@
return coords
def _apply_displacement(self, coords, mesh_id):
-
+
mesh_name = "connect%d" % (mesh_id + 1)
if mesh_name not in self.displacements:
new_coords = coords.copy()
@@ -327,7 +331,7 @@
new_coords[:, i] = coords[:, i] + fac*disp + offset[i]
return new_coords
-
+
def _read_connectivity(self):
"""
Loads the connectivity data for the mesh
@@ -343,7 +347,7 @@
Loads the boundaries for the domain edge
"""
-
+
coords = self._read_coordinates()
connectivity = self._read_connectivity()
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/frontends/exodus_ii/io.py
--- a/yt/frontends/exodus_ii/io.py
+++ b/yt/frontends/exodus_ii/io.py
@@ -50,31 +50,40 @@
rv = {}
for field in fields:
ftype, fname = field
- ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ if ftype == "all":
+ ci = np.concatenate([mesh.connectivity_indices - self._INDEX_OFFSET \
+ for mesh in self.ds.index.mesh_union])
+ else:
+ ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
num_elem = ci.shape[0]
if fname in self.node_fields:
nodes_per_element = ci.shape[1]
- rv[field] = np.empty((num_elem, nodes_per_element), dtype="float64")
+ rv[field] = np.zeros((num_elem, nodes_per_element), dtype="float64")
elif fname in self.elem_fields:
- rv[field] = np.empty(num_elem, dtype="float64")
+ rv[field] = np.zeros(num_elem, dtype="float64")
for field in fields:
ind = 0
ftype, fname = field
- mesh_id = int(ftype[-1])
- chunk = chunks[mesh_id - 1]
- ci = self.handler.variables[ftype][:] - self._INDEX_OFFSET
+ if ftype == "all":
+ mesh_ids = [mesh.mesh_id + 1 for mesh in self.ds.index.mesh_union]
+ objs = [mesh for mesh in self.ds.index.mesh_union]
+ else:
+ mesh_ids = [int(ftype[-1])]
+ chunk = chunks[mesh_ids[0] - 1]
+ objs = chunk.objs
if fname in self.node_fields:
field_ind = self.node_fields.index(fname)
fdata = self.handler.variables['vals_nod_var%d' % (field_ind + 1)]
- data = fdata[self.ds.step][ci]
- for g in chunk.objs:
+ for g in objs:
+ ci = g.connectivity_indices - self._INDEX_OFFSET
+ data = fdata[self.ds.step][ci]
ind += g.select(selector, data, rv[field], ind) # caches
if fname in self.elem_fields:
field_ind = self.elem_fields.index(fname)
- fdata = self.handler.variables['vals_elem_var%deb%s' %
- (field_ind + 1, mesh_id)][:]
- data = fdata[self.ds.step, :]
- for g in chunk.objs:
+ for g, mesh_id in zip(objs, mesh_ids):
+ fdata = self.handler.variables['vals_elem_var%deb%s' %
+ (field_ind + 1, mesh_id)][:]
+ data = fdata[self.ds.step, :]
ind += g.select(selector, data, rv[field], ind) # caches
return rv
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/frontends/exodus_ii/tests/test_outputs.py
--- a/yt/frontends/exodus_ii/tests/test_outputs.py
+++ b/yt/frontends/exodus_ii/tests/test_outputs.py
@@ -29,7 +29,11 @@
@requires_file(out)
def test_out():
ds = data_dir_load(out)
- field_list = [('connect1', 'conv_indicator'),
+ field_list = [('all', 'conv_indicator'),
+ ('all', 'conv_marker'),
+ ('all', 'convected'),
+ ('all', 'diffused'),
+ ('connect1', 'conv_indicator'),
('connect1', 'conv_marker'),
('connect1', 'convected'),
('connect1', 'diffused'),
@@ -42,7 +46,7 @@
yield assert_equal, ds.current_time, 0.0
yield assert_array_equal, ds.parameters['nod_names'], ['convected', 'diffused']
yield assert_equal, ds.parameters['num_meshes'], 2
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
out_s002 = "ExodusII/out.e-s002"
@@ -50,7 +54,11 @@
@requires_file(out_s002)
def test_out002():
ds = data_dir_load(out_s002)
- field_list = [('connect1', 'conv_indicator'),
+ field_list = [('all', 'conv_indicator'),
+ ('all', 'conv_marker'),
+ ('all', 'convected'),
+ ('all', 'diffused'),
+ ('connect1', 'conv_indicator'),
('connect1', 'conv_marker'),
('connect1', 'convected'),
('connect1', 'diffused'),
@@ -61,7 +69,7 @@
yield assert_equal, str(ds), "out.e-s002"
yield assert_equal, ds.dimensionality, 3
yield assert_equal, ds.current_time, 2.0
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
gold = "ExodusII/gold.e"
@@ -69,9 +77,9 @@
@requires_file(gold)
def test_gold():
ds = data_dir_load(gold)
- field_list = [('connect1', 'forced')]
+ field_list = [('all', 'forced'), ('connect1', 'forced')]
yield assert_equal, str(ds), "gold.e"
- yield assert_array_equal, ds.field_list, field_list
+ yield assert_array_equal, ds.field_list, field_list
big_data = "MOOSE_sample_data/mps_out.e"
@@ -79,7 +87,7 @@
@requires_ds(big_data)
def test_displacement_fields():
displacement_dicts =[{'connect2': (5.0, [0.0, 0.0, 0.0])},
- {'connect1': (1.0, [1.0, 2.0, 3.0]),
+ {'connect1': (1.0, [1.0, 2.0, 3.0]),
'connect2': (0.0, [0.0, 0.0, 0.0])}]
for disp in displacement_dicts:
ds = data_dir_load(big_data, displacements=disp)
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -68,11 +68,15 @@
if (hasattr(index, 'meshes') and
not isinstance(index.meshes[0], SemiStructuredMesh)):
ftype, fname = field
- mesh_id = int(ftype[-1]) - 1
- mesh = index.meshes[mesh_id]
- coords = mesh.connectivity_coords
- indices = mesh.connectivity_indices
- offset = mesh._index_offset
+ if ftype == "all":
+ mesh_id = 0
+ indices = np.concatenate([mesh.connectivity_indices for mesh in index.mesh_union])
+ else:
+ mesh_id = int(ftype[-1]) - 1
+ indices = index.meshes[mesh_id].connectivity_indices
+
+ coords = index.meshes[mesh_id].connectivity_coords
+ offset = index.meshes[mesh_id]._index_offset
ad = data_source.ds.all_data()
field_data = ad[field]
buff_size = size[0:dimension] + (1,) + size[dimension:]
diff -r f0fa273ba464df9040cf988857236495897424bb -r ec40fec890cfb081adfe932c34895e4d4355667b yt/visualization/tests/test_mesh_slices.py
--- a/yt/visualization/tests/test_mesh_slices.py
+++ b/yt/visualization/tests/test_mesh_slices.py
@@ -49,6 +49,14 @@
for field in ds.field_list:
yield compare(ds, field, "answers_tri2_%s_%s" % (field[0], field[1]))
+multi_region = "MultiRegion/two_region_example_out.e"
+
+ at requires_ds(multi_region)
+def test_multi_region():
+ ds = data_dir_load(multi_region, kwargs={'step':-1})
+ for field in ds.field_list:
+ yield compare(ds, field, "answers_multi_region_%s_%s" % (field[0], field[1]))
+
def test_mesh_slices():
# Perform I/O in safe place instead of yt main dir
tmpdir = tempfile.mkdtemp()
https://bitbucket.org/yt_analysis/yt/commits/aff15ee0df31/
Changeset: aff15ee0df31
Branch: yt
User: al007
Date: 2017-01-20 04:01:36+00:00
Summary: Increment unstructured_mesh tests counter.
Affected #: 1 file
diff -r ec40fec890cfb081adfe932c34895e4d4355667b -r aff15ee0df315855e0afe6b8f8cfecbc8ce8a0a0 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -63,7 +63,7 @@
- yt/analysis_modules/photon_simulator/tests/test_spectra.py
- yt/analysis_modules/photon_simulator/tests/test_sloshing.py
- local_unstructured_001:
+ local_unstructured_002:
- yt/visualization/volume_rendering/tests/test_mesh_render.py
- yt/visualization/tests/test_mesh_slices.py:test_tri2
- yt/visualization/tests/test_mesh_slices.py:test_multi_region
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