Matthew Turk avatar Matthew Turk committed 8bc4e5a

Adding a "blocks" attribute to data containers.

Fixing a few volume rendering and off-axis projection routines.

Comments (0)

Files changed (3)


             explicit_fields.append((ftype, fname))
         return explicit_fields
+    @property
+    def blocks(self):
+        for io_chunk in self.chunks([], "io"):
+            for i,chunk in enumerate(self.chunks([], "spatial", ngz = 0)):
+                mask = self._current_chunk.objs[0].select(self.selector)
+                if mask is None: continue
+                yield self._current_chunk.objs[0], mask
 class GenerationInProgress(Exception):
     def __init__(self, fields):
         self.fields = fields


         self.trunk = Node(None, None, None,
                 left, right, None, 1)
         if grids is None:
-            self.grids = pf.h.region((left+right)/2., left, right)._grids
+            source = pf.h.region((left+right)/2., left, right)
             self.grids = grids
+[g for g, mask in source.blocks])
     def add_grids(self, grids):
         lvl_range = range(self.min_level, self.max_level+1)


                     np.minimum(mi, this_point, mi)
                     np.maximum(ma, this_point, ma)
         # Now we have a bounding box.
-        grids = pf.h.region(, mi, ma)._grids
+        source = pf.h.region(, mi, ma)
-        pb = get_pbar("Sampling ", len(grids))
-        for i,grid in enumerate(grids):
-            data = [(grid[field] * grid.child_mask).astype("float64")
-                    for field in fields]
+        for i, (grid, mask) in enumerate(source.blocks):
+            data = [(grid[field] * mask).astype("float64") for field in fields]
             pg = PartitionedGrid(
       , data,
                 grid.LeftEdge, grid.RightEdge, grid.ActiveDimensions.astype("int64"))
             sampler(pg, num_threads = num_threads)
-            pb.update(i)
-        pb.finish()
         image = self.finalize_image(sampler.aimage)
         return image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.