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

Bitbucket commits-noreply at bitbucket.org
Thu Feb 14 12:12:51 PST 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/079b9451387e/
changeset:   079b9451387e
branch:      yt
user:        ngoldbaum
date:        2013-02-14 08:35:56
summary:     Touching up the callbacks so we only attach working callbacks to PWViewerMPL instances.
affected #:  2 files

diff -r 740ea6ff9ec4464097aa369f87b90677cd526df3 -r 079b9451387e1e825e9de4de182f7272407ad6ae yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -10,6 +10,8 @@
 Author: Anthony Scopatz <scopatz at gmail.com>
 Affiliation: The University of Chicago
 Homepage: http://yt-project.org/
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UC Santa Cruz
 License:
   Copyright (C) 2008-2011 Matthew Turk, JS Oishi, Stephen Skory.  All Rights Reserved.
 
@@ -253,43 +255,51 @@
         dx = (xx1 - xx0) / (x1-x0)
         dy = (yy1 - yy0) / (y1-y0)
 
-        #dcollins Jan 11 2009.  Improved to allow for periodic shifts in the plot.
-        #Now makes a copy of the position fields "px" and "py" and adds the
-        #appropriate shift to the coppied field.  
-
-        #set the cumulative arrays for the periodic shifting.
-        AllX = np.zeros(plot.data["px"].size, dtype='bool')
-        AllY = np.zeros(plot.data["py"].size, dtype='bool')
-        XShifted = plot.data["px"].copy()
-        YShifted = plot.data["py"].copy()
-        dom_x, dom_y = plot._period
-        for shift in np.mgrid[-1:1:3j]:
-            xlim = ((plot.data["px"] + shift*dom_x >= x0)
-                 &  (plot.data["px"] + shift*dom_x <= x1))
-            ylim = ((plot.data["py"] + shift*dom_y >= y0)
-                 &  (plot.data["py"] + shift*dom_y <= y1))
-            XShifted[xlim] += shift * dom_x
-            YShifted[ylim] += shift * dom_y
-            AllX |= xlim
-            AllY |= ylim
-        # At this point XShifted and YShifted are the shifted arrays of
-        # position data in data coordinates
-        wI = (AllX & AllY)
-
         # We want xi, yi in plot coordinates
-        xi, yi = np.mgrid[xx0:xx1:numPoints_x/(self.factor*1j),\
+        xi, yi = np.mgrid[xx0:xx1:numPoints_x/(self.factor*1j),
                           yy0:yy1:numPoints_y/(self.factor*1j)]
 
-        # This converts XShifted and YShifted into plot coordinates
-        x = (XShifted[wI]-x0)*dx + xx0
-        y = (YShifted[wI]-y0)*dy + yy0
-        z = plot.data[self.field][wI]
-        if plot.pf.field_info[self.field].take_log: z=np.log10(z)
+        if plot._type_name in ['CuttingPlane','Projection','Slice']:
+            if plot._type_name == 'CuttingPlane':
+                x = plot.data["px"]*dx
+                y = plot.data["py"]*dy
+                z = plot.data[self.field]
+            elif plot._type_name in ['Projection','Slice']:
+                #Makes a copy of the position fields "px" and "py" and adds the
+                #appropriate shift to the copied field.  
 
-        # Both the input and output from the triangulator are in plot
-        # coordinates
-        zi = self.triang(x,y).nn_interpolator(z)(xi,yi)
+                AllX = np.zeros(plot.data["px"].size, dtype='bool')
+                AllY = np.zeros(plot.data["py"].size, dtype='bool')
+                XShifted = plot.data["px"].copy()
+                YShifted = plot.data["py"].copy()
+                dom_x, dom_y = plot._period
+                for shift in np.mgrid[-1:1:3j]:
+                    xlim = ((plot.data["px"] + shift*dom_x >= x0) &
+                            (plot.data["px"] + shift*dom_x <= x1))
+                    ylim = ((plot.data["py"] + shift*dom_y >= y0) &
+                            (plot.data["py"] + shift*dom_y <= y1))
+                    XShifted[xlim] += shift * dom_x
+                    YShifted[ylim] += shift * dom_y
+                    AllX |= xlim
+                    AllY |= ylim
+            
+                # At this point XShifted and YShifted are the shifted arrays of
+                # position data in data coordinates
+                wI = (AllX & AllY)
+
+                # This converts XShifted and YShifted into plot coordinates
+                x = (XShifted[wI]-x0)*dx + xx0
+                y = (YShifted[wI]-y0)*dy + yy0
+                z = plot.data[self.field][wI]
         
+            # Both the input and output from the triangulator are in plot
+            # coordinates
+            zi = self.triang(x,y).nn_interpolator(z)(xi,yi)
+        elif plot._type_name == 'OffAxisProjection':
+            zi = plot.frb[self.field][::self.factor,::self.factor].transpose()
+        
+        if plot.pf.field_info[self.field].take_log: zi=np.log10(zi)
+
         if plot.pf.field_info[self.field].take_log and self.clim is not None: 
             self.clim = (np.log10(self.clim[0]), np.log10(self.clim[1]))
         
@@ -416,22 +426,26 @@
         plot._axes.hold(True)
         nx = plot.image._A.shape[0] / self.factor
         ny = plot.image._A.shape[1] / self.factor
-        pixX = _MPL.Pixelize(plot.data['px'],
-                             plot.data['py'],
-                             plot.data['pdx'],
-                             plot.data['pdy'],
-                             plot.data[self.field_x] - self.bv_x,
-                             int(nx), int(ny),
-                           (x0, x1, y0, y1),).transpose()
-        pixY = _MPL.Pixelize(plot.data['px'],
-                             plot.data['py'],
-                             plot.data['pdx'],
-                             plot.data['pdy'],
-                             plot.data[self.field_y] - self.bv_y,
-                             int(nx), int(ny),
-                           (x0, x1, y0, y1),).transpose()
+        if plot._type_name == 'OffAxisProjection':
+            pixX = (plot.frb[self.field_x])[::self.factor,::self.factor]
+            pixY = -1*(plot.frb[self.field_y])[::self.factor,::self.factor]
+        else:
+            pixX = _MPL.Pixelize(plot.data['px'],
+                                 plot.data['py'],
+                                 plot.data['pdx'],
+                                 plot.data['pdy'],
+                                 plot.data[self.field_x] - self.bv_x,
+                                 int(nx), int(ny),
+                                 (x0, x1, y0, y1),).transpose()
+            pixY = _MPL.Pixelize(plot.data['px'],
+                                 plot.data['py'],
+                                 plot.data['pdx'],
+                                 plot.data['pdy'],
+                                 plot.data[self.field_y] - self.bv_y,
+                                 int(nx), int(ny),
+                                 (x0, x1, y0, y1),).transpose()
         X,Y = (np.linspace(xx0,xx1,nx,endpoint=True),
-                          np.linspace(yy0,yy1,ny,endpoint=True))
+               np.linspace(yy0,yy1,ny,endpoint=True))
         plot._axes.streamplot(X,Y, pixX, pixY, density = self.dens,
                               **self.plot_args)
         plot._axes.set_xlim(xx0,xx1)
@@ -742,7 +756,7 @@
         """
         annotate_marker(pos, marker='x', plot_args=None)
 
-        Adds text *marker* at *pos* in code-arguments.  *plot_args* is a dict
+        Adds text *marker* at *pos* in code units.  *plot_args* is a dict
         that will be forwarded to the plot command.
         """
         self.pos = pos
@@ -753,10 +767,10 @@
     def __call__(self, plot):
         xx0, xx1 = plot._axes.get_xlim()
         yy0, yy1 = plot._axes.get_ylim()
-        if np.array(self.pos).shape == (3,):
+        if len(self.pos) == 3:
             pos = (self.pos[x_dict[plot.data.axis]],
                    self.pos[y_dict[plot.data.axis]])
-        elif np.array(self.pos).shape == (2,):
+        elif len(self.pos) == 2:
             pos = self.pos
         x,y = self.convert_to_plot(plot, pos)
         plot._axes.hold(True)
@@ -791,7 +805,10 @@
         
         radius = self.radius * self.pixel_scale(plot)[0]
 
-        (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+        if plot.data.axis == 4:
+            (xi, yi) = (0, 1)
+        else:
+            (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
 
         (center_x,center_y) = self.convert_to_plot(plot,(self.center[xi], self.center[yi]))
         

diff -r 740ea6ff9ec4464097aa369f87b90677cd526df3 -r 079b9451387e1e825e9de4de182f7272407ad6ae yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -111,6 +111,7 @@
 
 class CallbackWrapper(object):
     def __init__(self, viewer, window_plot, frb, field):
+        self.frb = frb
         self.data = frb.data_source
         self._axes = window_plot.axes
         self._figure = window_plot.figure
@@ -124,11 +125,11 @@
         self.pf = frb.pf
         self.xlim = viewer.xlim
         self.ylim = viewer.ylim
-        if 'Cutting' in self.data.__class__.__name__:
+        if 'OffAxisSlice' in viewer._plot_type:
             self._type_name = "CuttingPlane"
         else:
-            self._type_name = ''
-
+            self._type_name = viewer._plot_type
+ 
 class FieldTransform(object):
     def __init__(self, name, func, locator):
         self.name = name
@@ -644,6 +645,14 @@
         for key in callback_registry:
             ignored = ['PlotCallback','CoordAxesCallback','LabelCallback',
                        'UnitBoundaryCallback']
+            if self._plot_type.startswith('OffAxis'):
+                ignored += ['HopCirclesCallback','HopParticleCallback',
+                            'ParticleCallback','ClumpContourCallback',
+                            'GridBoundaryCallback']
+            if self._plot_type == 'OffAxisProjection':
+                ignored += ['VelocityCallback','MagFieldCallback',
+                            'QuiverCallback','CuttingQuiverCallback',
+                            'StreamlineCallback']
             if key in ignored: 
                 continue
             cbname = callback_registry[key]._type_name


https://bitbucket.org/yt_analysis/yt/commits/245a4c9161ea/
changeset:   245a4c9161ea
branch:      yt
user:        ngoldbaum
date:        2013-02-14 08:41:20
summary:     No need to modify the streamline callback since it is disable for OAPP.
affected #:  1 file

diff -r 079b9451387e1e825e9de4de182f7272407ad6ae -r 245a4c9161ea61bc0f9f8127329a2638efdf941c yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -426,24 +426,20 @@
         plot._axes.hold(True)
         nx = plot.image._A.shape[0] / self.factor
         ny = plot.image._A.shape[1] / self.factor
-        if plot._type_name == 'OffAxisProjection':
-            pixX = (plot.frb[self.field_x])[::self.factor,::self.factor]
-            pixY = -1*(plot.frb[self.field_y])[::self.factor,::self.factor]
-        else:
-            pixX = _MPL.Pixelize(plot.data['px'],
-                                 plot.data['py'],
-                                 plot.data['pdx'],
-                                 plot.data['pdy'],
-                                 plot.data[self.field_x] - self.bv_x,
-                                 int(nx), int(ny),
-                                 (x0, x1, y0, y1),).transpose()
-            pixY = _MPL.Pixelize(plot.data['px'],
-                                 plot.data['py'],
-                                 plot.data['pdx'],
-                                 plot.data['pdy'],
-                                 plot.data[self.field_y] - self.bv_y,
-                                 int(nx), int(ny),
-                                 (x0, x1, y0, y1),).transpose()
+        pixX = _MPL.Pixelize(plot.data['px'],
+                             plot.data['py'],
+                             plot.data['pdx'],
+                             plot.data['pdy'],
+                             plot.data[self.field_x] - self.bv_x,
+                             int(nx), int(ny),
+                             (x0, x1, y0, y1),).transpose()
+        pixY = _MPL.Pixelize(plot.data['px'],
+                             plot.data['py'],
+                             plot.data['pdx'],
+                             plot.data['pdy'],
+                             plot.data[self.field_y] - self.bv_y,
+                             int(nx), int(ny),
+                             (x0, x1, y0, y1),).transpose()
         X,Y = (np.linspace(xx0,xx1,nx,endpoint=True),
                np.linspace(yy0,yy1,ny,endpoint=True))
         plot._axes.streamplot(X,Y, pixX, pixY, density = self.dens,


https://bitbucket.org/yt_analysis/yt/commits/e2a1aa6a8312/
changeset:   e2a1aa6a8312
branch:      yt
user:        MatthewTurk
date:        2013-02-14 21:12:46
summary:     Merged in ngoldbaum/yt (pull request #426)

Only attach working callbacks to PWViewerMPL instances.
affected #:  2 files

diff -r 5027f592349e196f6c1c5784faaa4ce131694103 -r e2a1aa6a831243e736ffeba2c54f7d9b6a76d9f8 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -10,6 +10,8 @@
 Author: Anthony Scopatz <scopatz at gmail.com>
 Affiliation: The University of Chicago
 Homepage: http://yt-project.org/
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UC Santa Cruz
 License:
   Copyright (C) 2008-2011 Matthew Turk, JS Oishi, Stephen Skory.  All Rights Reserved.
 
@@ -253,43 +255,51 @@
         dx = (xx1 - xx0) / (x1-x0)
         dy = (yy1 - yy0) / (y1-y0)
 
-        #dcollins Jan 11 2009.  Improved to allow for periodic shifts in the plot.
-        #Now makes a copy of the position fields "px" and "py" and adds the
-        #appropriate shift to the coppied field.  
-
-        #set the cumulative arrays for the periodic shifting.
-        AllX = np.zeros(plot.data["px"].size, dtype='bool')
-        AllY = np.zeros(plot.data["py"].size, dtype='bool')
-        XShifted = plot.data["px"].copy()
-        YShifted = plot.data["py"].copy()
-        dom_x, dom_y = plot._period
-        for shift in np.mgrid[-1:1:3j]:
-            xlim = ((plot.data["px"] + shift*dom_x >= x0)
-                 &  (plot.data["px"] + shift*dom_x <= x1))
-            ylim = ((plot.data["py"] + shift*dom_y >= y0)
-                 &  (plot.data["py"] + shift*dom_y <= y1))
-            XShifted[xlim] += shift * dom_x
-            YShifted[ylim] += shift * dom_y
-            AllX |= xlim
-            AllY |= ylim
-        # At this point XShifted and YShifted are the shifted arrays of
-        # position data in data coordinates
-        wI = (AllX & AllY)
-
         # We want xi, yi in plot coordinates
-        xi, yi = np.mgrid[xx0:xx1:numPoints_x/(self.factor*1j),\
+        xi, yi = np.mgrid[xx0:xx1:numPoints_x/(self.factor*1j),
                           yy0:yy1:numPoints_y/(self.factor*1j)]
 
-        # This converts XShifted and YShifted into plot coordinates
-        x = (XShifted[wI]-x0)*dx + xx0
-        y = (YShifted[wI]-y0)*dy + yy0
-        z = plot.data[self.field][wI]
-        if plot.pf.field_info[self.field].take_log: z=np.log10(z)
+        if plot._type_name in ['CuttingPlane','Projection','Slice']:
+            if plot._type_name == 'CuttingPlane':
+                x = plot.data["px"]*dx
+                y = plot.data["py"]*dy
+                z = plot.data[self.field]
+            elif plot._type_name in ['Projection','Slice']:
+                #Makes a copy of the position fields "px" and "py" and adds the
+                #appropriate shift to the copied field.  
 
-        # Both the input and output from the triangulator are in plot
-        # coordinates
-        zi = self.triang(x,y).nn_interpolator(z)(xi,yi)
+                AllX = np.zeros(plot.data["px"].size, dtype='bool')
+                AllY = np.zeros(plot.data["py"].size, dtype='bool')
+                XShifted = plot.data["px"].copy()
+                YShifted = plot.data["py"].copy()
+                dom_x, dom_y = plot._period
+                for shift in np.mgrid[-1:1:3j]:
+                    xlim = ((plot.data["px"] + shift*dom_x >= x0) &
+                            (plot.data["px"] + shift*dom_x <= x1))
+                    ylim = ((plot.data["py"] + shift*dom_y >= y0) &
+                            (plot.data["py"] + shift*dom_y <= y1))
+                    XShifted[xlim] += shift * dom_x
+                    YShifted[ylim] += shift * dom_y
+                    AllX |= xlim
+                    AllY |= ylim
+            
+                # At this point XShifted and YShifted are the shifted arrays of
+                # position data in data coordinates
+                wI = (AllX & AllY)
+
+                # This converts XShifted and YShifted into plot coordinates
+                x = (XShifted[wI]-x0)*dx + xx0
+                y = (YShifted[wI]-y0)*dy + yy0
+                z = plot.data[self.field][wI]
         
+            # Both the input and output from the triangulator are in plot
+            # coordinates
+            zi = self.triang(x,y).nn_interpolator(z)(xi,yi)
+        elif plot._type_name == 'OffAxisProjection':
+            zi = plot.frb[self.field][::self.factor,::self.factor].transpose()
+        
+        if plot.pf.field_info[self.field].take_log: zi=np.log10(zi)
+
         if plot.pf.field_info[self.field].take_log and self.clim is not None: 
             self.clim = (np.log10(self.clim[0]), np.log10(self.clim[1]))
         
@@ -422,16 +432,16 @@
                              plot.data['pdy'],
                              plot.data[self.field_x] - self.bv_x,
                              int(nx), int(ny),
-                           (x0, x1, y0, y1),).transpose()
+                             (x0, x1, y0, y1),).transpose()
         pixY = _MPL.Pixelize(plot.data['px'],
                              plot.data['py'],
                              plot.data['pdx'],
                              plot.data['pdy'],
                              plot.data[self.field_y] - self.bv_y,
                              int(nx), int(ny),
-                           (x0, x1, y0, y1),).transpose()
+                             (x0, x1, y0, y1),).transpose()
         X,Y = (np.linspace(xx0,xx1,nx,endpoint=True),
-                          np.linspace(yy0,yy1,ny,endpoint=True))
+               np.linspace(yy0,yy1,ny,endpoint=True))
         plot._axes.streamplot(X,Y, pixX, pixY, density = self.dens,
                               **self.plot_args)
         plot._axes.set_xlim(xx0,xx1)
@@ -742,7 +752,7 @@
         """
         annotate_marker(pos, marker='x', plot_args=None)
 
-        Adds text *marker* at *pos* in code-arguments.  *plot_args* is a dict
+        Adds text *marker* at *pos* in code units.  *plot_args* is a dict
         that will be forwarded to the plot command.
         """
         self.pos = pos
@@ -753,10 +763,10 @@
     def __call__(self, plot):
         xx0, xx1 = plot._axes.get_xlim()
         yy0, yy1 = plot._axes.get_ylim()
-        if np.array(self.pos).shape == (3,):
+        if len(self.pos) == 3:
             pos = (self.pos[x_dict[plot.data.axis]],
                    self.pos[y_dict[plot.data.axis]])
-        elif np.array(self.pos).shape == (2,):
+        elif len(self.pos) == 2:
             pos = self.pos
         x,y = self.convert_to_plot(plot, pos)
         plot._axes.hold(True)
@@ -791,7 +801,10 @@
         
         radius = self.radius * self.pixel_scale(plot)[0]
 
-        (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
+        if plot.data.axis == 4:
+            (xi, yi) = (0, 1)
+        else:
+            (xi, yi) = (x_dict[plot.data.axis], y_dict[plot.data.axis])
 
         (center_x,center_y) = self.convert_to_plot(plot,(self.center[xi], self.center[yi]))
         

diff -r 5027f592349e196f6c1c5784faaa4ce131694103 -r e2a1aa6a831243e736ffeba2c54f7d9b6a76d9f8 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -111,6 +111,7 @@
 
 class CallbackWrapper(object):
     def __init__(self, viewer, window_plot, frb, field):
+        self.frb = frb
         self.data = frb.data_source
         self._axes = window_plot.axes
         self._figure = window_plot.figure
@@ -124,11 +125,11 @@
         self.pf = frb.pf
         self.xlim = viewer.xlim
         self.ylim = viewer.ylim
-        if 'Cutting' in self.data.__class__.__name__:
+        if 'OffAxisSlice' in viewer._plot_type:
             self._type_name = "CuttingPlane"
         else:
-            self._type_name = ''
-
+            self._type_name = viewer._plot_type
+ 
 class FieldTransform(object):
     def __init__(self, name, func, locator):
         self.name = name
@@ -644,6 +645,14 @@
         for key in callback_registry:
             ignored = ['PlotCallback','CoordAxesCallback','LabelCallback',
                        'UnitBoundaryCallback']
+            if self._plot_type.startswith('OffAxis'):
+                ignored += ['HopCirclesCallback','HopParticleCallback',
+                            'ParticleCallback','ClumpContourCallback',
+                            'GridBoundaryCallback']
+            if self._plot_type == 'OffAxisProjection':
+                ignored += ['VelocityCallback','MagFieldCallback',
+                            'QuiverCallback','CuttingQuiverCallback',
+                            'StreamlineCallback']
             if key in ignored: 
                 continue
             cbname = callback_registry[key]._type_name

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