[yt-svn] commit/yt: 4 new changesets

Bitbucket commits-noreply at bitbucket.org
Mon Nov 26 14:30:47 PST 2012


4 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/89c703f10af1/
changeset:   89c703f10af1
branch:      yt
user:        ngoldbaum
date:        2012-11-26 22:54:19
summary:     Adding a level keyword to the grid callback which allows a user to only
draw grids that live at or above a given level.
affected #:  1 file

diff -r 87237e244a95b890c143ade79b97284739bf148a -r 89c703f10af1c701a46db2b98e50b0d0b63b013c yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -307,14 +307,15 @@
 
 class GridBoundaryCallback(PlotCallback):
     _type_name = "grids"
-    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True):
+    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, level=None):
         """
         annotate_grids(alpha=1.0, min_pix=1, draw_ids=False, periodic=True)
 
         Adds grid boundaries to a plot, optionally with *alpha*-blending.
         Cuttoff for display is at *min_pix* wide.
         *draw_ids* puts the grid id in the corner of the grid.  (Not so great in projections...)
-        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.
+        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.  If *level* is
+        specified, only draw grids at or above the given refinement level.
         """
         PlotCallback.__init__(self)
         self.alpha = alpha
@@ -322,6 +323,7 @@
         self.min_pix_ids = min_pix_ids
         self.draw_ids = draw_ids # put grid numbers in the corner.
         self.periodic = periodic
+        self.level = level
 
     def __call__(self, plot):
         x0, x1 = plot.xlim
@@ -341,6 +343,7 @@
             pxs, pys = np.mgrid[0:0:1j,0:0:1j]
         GLE = plot.data.grid_left_edge
         GRE = plot.data.grid_right_edge
+        grid_levels = plot.data.grid_levels
         for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
             pxo = px_off * dom[px_index]
             pyo = py_off * dom[py_index]
@@ -349,7 +352,8 @@
             right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
             right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
             visible =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
-                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
+                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix ) & \
+                       ( grid_levels >= self.level)
             if visible.nonzero()[0].size == 0: continue
             verts = np.array(
                 [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),



https://bitbucket.org/yt_analysis/yt/changeset/6132c2f9c4ba/
changeset:   6132c2f9c4ba
branch:      yt
user:        ngoldbaum
date:        2012-11-26 22:55:40
summary:     Merging.
affected #:  1 file

diff -r b1ba33518f0b7512086a211827a32da6f608e0e9 -r 6132c2f9c4ba4f8e7cc372a91772d842dfab6270 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -307,14 +307,15 @@
 
 class GridBoundaryCallback(PlotCallback):
     _type_name = "grids"
-    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True):
+    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, level=None):
         """
         annotate_grids(alpha=1.0, min_pix=1, draw_ids=False, periodic=True)
 
         Adds grid boundaries to a plot, optionally with *alpha*-blending.
         Cuttoff for display is at *min_pix* wide.
         *draw_ids* puts the grid id in the corner of the grid.  (Not so great in projections...)
-        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.
+        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.  If *level* is
+        specified, only draw grids at or above the given refinement level.
         """
         PlotCallback.__init__(self)
         self.alpha = alpha
@@ -322,6 +323,7 @@
         self.min_pix_ids = min_pix_ids
         self.draw_ids = draw_ids # put grid numbers in the corner.
         self.periodic = periodic
+        self.level = level
 
     def __call__(self, plot):
         x0, x1 = plot.xlim
@@ -341,6 +343,7 @@
             pxs, pys = np.mgrid[0:0:1j,0:0:1j]
         GLE = plot.data.grid_left_edge
         GRE = plot.data.grid_right_edge
+        grid_levels = plot.data.grid_levels
         for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
             pxo = px_off * dom[px_index]
             pyo = py_off * dom[py_index]
@@ -349,7 +352,8 @@
             right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
             right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
             visible =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
-                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
+                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix ) & \
+                       ( grid_levels >= self.level)
             if visible.nonzero()[0].size == 0: continue
             verts = np.array(
                 [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),



https://bitbucket.org/yt_analysis/yt/changeset/8667d061b22e/
changeset:   8667d061b22e
branch:      yt
user:        ngoldbaum
date:        2012-11-26 23:07:45
summary:     Adding a min_level and max_level keyowrd to the grid callback.
affected #:  1 file

diff -r 6132c2f9c4ba4f8e7cc372a91772d842dfab6270 -r 8667d061b22e9a8d47c13b63fefe08b098e65f7f yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -307,15 +307,17 @@
 
 class GridBoundaryCallback(PlotCallback):
     _type_name = "grids"
-    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, level=None):
+    def __init__(self, alpha=1.0, min_pix=1, min_pix_ids=20, draw_ids=False, periodic=True, 
+                 min_level=None, max_level=None):
         """
         annotate_grids(alpha=1.0, min_pix=1, draw_ids=False, periodic=True)
 
         Adds grid boundaries to a plot, optionally with *alpha*-blending.
         Cuttoff for display is at *min_pix* wide.
         *draw_ids* puts the grid id in the corner of the grid.  (Not so great in projections...)
-        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.  If *level* is
-        specified, only draw grids at or above the given refinement level.
+        Grids must be wider than *min_pix_ids* otherwise the ID will not be drawn.  If *min_level* 
+        is specified, only draw grids at or above min_level.  If *max_level* is specified, only 
+        draw grids at or below max_level.
         """
         PlotCallback.__init__(self)
         self.alpha = alpha
@@ -323,7 +325,8 @@
         self.min_pix_ids = min_pix_ids
         self.draw_ids = draw_ids # put grid numbers in the corner.
         self.periodic = periodic
-        self.level = level
+        self.min_level = min_level
+        self.max_level = max_level
 
     def __call__(self, plot):
         x0, x1 = plot.xlim
@@ -352,8 +355,14 @@
             right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
             right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
             visible =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
-                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix ) & \
-                       ( grid_levels >= self.level)
+                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
+            if self.min_level is not None and self.max_level is None:
+                visible = np.logical_and(visible, grid_levels >= self.min_level)
+            elif self.max_level is not None and self.min_level is None:
+                visible = np.logical_and(visible, grid_levels <= self.max_level)
+            elif self.max_level is not None and self.min_level is not None:
+                visible = np.logical_and(visible, grid_levels <= self.max_level)
+                visible = np.logical_and(visible, grid_levels >= self.min_level)
             if visible.nonzero()[0].size == 0: continue
             verts = np.array(
                 [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),



https://bitbucket.org/yt_analysis/yt/changeset/3939099bf5f3/
changeset:   3939099bf5f3
branch:      yt
user:        ngoldbaum
date:        2012-11-26 23:28:38
summary:     Simplifying the logic in the grid callback.
affected #:  1 file

diff -r 8667d061b22e9a8d47c13b63fefe08b098e65f7f -r 3939099bf5f3e4ea283674be84e58447e52c9c4a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -347,6 +347,13 @@
         GLE = plot.data.grid_left_edge
         GRE = plot.data.grid_right_edge
         grid_levels = plot.data.grid_levels
+        min_level = self.min_level
+        max_level = self.max_level
+        if min_level is None:
+            min_level = 0
+        if max_level is None:
+            max_level = plot.data.max_level
+
         for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
             pxo = px_off * dom[px_index]
             pyo = py_off * dom[py_index]
@@ -355,14 +362,9 @@
             right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
             right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
             visible =  ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
-                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
-            if self.min_level is not None and self.max_level is None:
-                visible = np.logical_and(visible, grid_levels >= self.min_level)
-            elif self.max_level is not None and self.min_level is None:
-                visible = np.logical_and(visible, grid_levels <= self.max_level)
-            elif self.max_level is not None and self.min_level is not None:
-                visible = np.logical_and(visible, grid_levels <= self.max_level)
-                visible = np.logical_and(visible, grid_levels >= self.min_level)
+                       ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix ) & \
+                       ( grid_levels >= min_level) & \
+                       ( grid_levels <= max_level)
             if visible.nonzero()[0].size == 0: continue
             verts = np.array(
                 [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),

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