[Yt-svn] yt-commit r1163 - in trunk/yt: extensions raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Thu Feb 5 22:34:43 PST 2009
Author: mturk
Date: Thu Feb 5 22:34:42 2009
New Revision: 1163
URL: http://yt.spacepope.org/changeset/1163
Log:
VTK interface now has a button called "import hierarchy" rather than
"recalculate" and this will become a specialized view soon. Additionally, the
calculation of ghost zones inside VTK was *extremely* slow and so if we feed
that info (whcih we already have) it speeds up importing my large dataset by a
factor of *two*. Hierarchy subset changes are not as well tested, but we now
have child masks for constructed root grids, and the left/right edge offsets
are more reliable. Also a casting issue was caught and fixed.
Modified:
trunk/yt/extensions/HierarchySubset.py
trunk/yt/raven/VTKInterface.py
Modified: trunk/yt/extensions/HierarchySubset.py
==============================================================================
--- trunk/yt/extensions/HierarchySubset.py (original)
+++ trunk/yt/extensions/HierarchySubset.py Thu Feb 5 22:34:42 2009
@@ -46,8 +46,22 @@
self.dds = pf.h.select_grids(level)[0].dds.copy()
dims = (self.RightEdge-self.LeftEdge)/self.dds
self.ActiveDimensions = dims
+ print "Constructing base grid of size %s" % (self.ActiveDimensions)
self.cg = pf.h.smoothed_covering_grid(level, self.LeftEdge,
self.RightEdge, dims=dims)
+ self._calculate_child_masks()
+
+ def _calculate_child_masks(self):
+ # This might be slow
+ grids, grid_ind = self.pf.hierarchy.get_box_grids(
+ self.LeftEdge, self.RightEdge)
+ self.Children = [g for g in grids if g.Level == self.Level + 1]
+ self.child_mask = na.ones(self.ActiveDimensions, dtype='int32')
+ for c in self.Children:
+ si = na.maximum(0, na.rint((c.LeftEdge - self.LeftEdge)/self.dds))
+ ei = na.minimum(self.ActiveDimensions,
+ na.rint((c.RightEdge - self.LeftEdge)/self.dds))
+ self.child_mask[si[0]:ei[0], si[1]:ei[1], si[2]:ei[2]] = 0
def __getitem__(self, field):
return self.cg[field]
@@ -82,17 +96,19 @@
pf.h.select_grids(min_level)], axis=0).astype('float64')
min_left = na.min([grid.LeftEdge for grid in
pf.h.select_grids(min_level)], axis=0).astype('float64')
- self.right_edge_offset = na.max([grid.RightEdge for grid in
+ max_right = na.max([grid.RightEdge for grid in
pf.h.select_grids(min_level)], axis=0).astype('float64')
- if offset is None: offset = (self.right_edge_offset + min_left)/2.0
+ if offset is None: offset = (max_right + min_left)/2.0
self.left_edge_offset = offset
self.mult_factor = 2**min_level
+ self.min_left_edge = self._convert_coords(min_left)
+ self.max_right_edge = self._convert_coords(max_right)
if max_level == -1: max_level = pf.h.max_level
self.max_level = min(max_level, pf.h.max_level)
self.final_level = self.max_level - self.min_level
if len(self.pf.h.select_grids(self.min_level)) > 0:
self._base_grid = ConstructedRootGrid(self.pf, self.min_level,
- min_left, self.right_edge_offset)
+ min_left, max_right)
else: self._base_grid = None
def select_level(self, level):
@@ -162,7 +178,8 @@
"/Grid%08i/%s" % (grid.id, field)
else:
# Export our array
- afile.createArray(grid_node, "grid-data", grid[field].swapaxes(0,2))
+ afile.createArray(grid_node, "grid-data",
+ grid[field].astype('float32').swapaxes(0,2))
def _convert_coords(self, val):
return (val - self.left_edge_offset)*self.mult_factor
Modified: trunk/yt/raven/VTKInterface.py
==============================================================================
--- trunk/yt/raven/VTKInterface.py (original)
+++ trunk/yt/raven/VTKInterface.py Thu Feb 5 22:34:42 2009
@@ -298,7 +298,7 @@
scene = Delegate('window')
# UI elements
- recalculate = Button()
+ import_hierarchy = Button()
# State variables
_grid_boundaries_actor = None
@@ -309,7 +309,7 @@
Item('parameter_fn'),
Item('field'),
Item('center'),
- Item('recalculate', show_label=False))
+ Item('import_hierarchy', show_label=False))
def _center_default(self):
return [0.5,0.5,0.5]
@@ -325,7 +325,7 @@
self.window.open()
self.scene = self.window.scene
- def _recalculate_fired(self):
+ def _import_hierarchy_fired(self):
self.pf = lagos.EnzoStaticOutput(self.parameter_fn[:-10])
self.extracted_hierarchy = ExtractedHierarchy(
self.pf, self.min_grid_level, self.max_grid_level,
@@ -341,7 +341,7 @@
gid = 0
for l, grid_set in enumerate(self.extracted_hierarchy.get_levels()):
gid = self._add_level(grid_set, l, gid)
- self._hdata_set.generate_visibility_arrays()
+ #self._hdata_set.generate_visibility_arrays()
self.toggle_grid_boundaries()
self.camera_path.edit_traits()
self.scene.camera.focal_point = self.center
@@ -371,6 +371,8 @@
scalars = na.log10(scalars)
ug.point_data.scalars = scalars.transpose().ravel()
ug.point_data.scalars.name = self.field
+ if grid.Level != self.max_grid_level:
+ ug.cell_visibility_array = grid.child_mask.transpose().ravel()
self._ugs.append(ug)
self._hdata_set.set_data_set(level, gid, left_index, right_index, ug)
@@ -425,10 +427,8 @@
normal = [0,0,0]
normal[axis] = 1
np, lookup_table = self._add_plane(self.center, normal=normal)
- LE = self.extracted_hierarchy._convert_coords(
- self.extracted_hierarchy.left_edge_offset)
- RE = self.extracted_hierarchy._convert_coords(
- self.extracted_hierarchy.right_edge_offset)
+ LE = self.extracted_hierarchy.min_left_edge
+ RE = self.extracted_hierarchy.max_right_edge
self.operators.append(MappingPlane(
vmin=LE[axis], vmax=RE[axis],
vdefault = self.center[axis],
@@ -477,6 +477,15 @@
for parent in grid.Parents: parents.append(get_all_parents(parent))
return list(set(parents))
+def run_vtk():
+ import yt.lagos as lagos
+
+ global gui, ehds
+ gui = pyface.GUI()
+ ehds = YTScene()
+ ehds.edit_traits()
+ gui.start_event_loop()
+
if __name__=="__main__":
print "This code probably won't work. But if you want to give it a try,"
print "you need:"
@@ -486,10 +495,8 @@
print
print "If you have 'em, give it a try!"
print
- #sys.exit()
- import yt.lagos as lagos
-
gui = pyface.GUI()
ehds = YTScene()
ehds.edit_traits()
gui.start_event_loop()
+
More information about the yt-svn
mailing list