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

Bitbucket commits-noreply at bitbucket.org
Wed Oct 10 07:41:01 PDT 2012


3 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/eea2f500219c/
changeset:   eea2f500219c
branch:      yt
user:        ngoldbaum
date:        2012-10-10 07:42:47
summary:     Fixing creating plot window plots from data objects via to_pw.
affected #:  2 files

diff -r b5b438054310909ce9395a5b359a9bc0caf7326e -r eea2f500219ce4284e74b77c7cd42d901a18a1d6 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -855,6 +855,17 @@
         for field in temp_data.keys():
             self[field] = temp_data[field]
 
+    def _get_pw_params(self, fields, center, width):
+        axis = self.axis
+        if fields == None:
+            if self.fields == None:
+                raise SyntaxError("The fields keyword argument must be set")
+        else:
+            self.fields = ensure_list(fields)
+        from yt.visualization.plot_window import GetBoundsAndCenter
+        (bounds, center) = GetBoundsAndCenter(axis, center, width, self.pf)
+        return bounds
+
     def to_frb(self, width, resolution, center=None, height=None):
         r"""This function returns a FixedResolutionBuffer generated from this
         object.
@@ -916,26 +927,6 @@
         frb = FixedResolutionBuffer(self, bounds, resolution)
         return frb
 
-    def to_pw(self):
-        r"""Create a :class:`~yt.visualization.plot_window.PlotWindow` from this
-        object.
-
-        This is a bare-bones mechanism of creating a plot window from this
-        object, which can then be moved around, zoomed, and on and on.  All
-        behavior of the plot window is relegated to that routine.
-        """
-        axis = self.axis
-        center = self.get_field_parameter("center")
-        if center is None:
-            center = (self.pf.domain_right_edge
-                    + self.pf.domain_left_edge)/2.0
-        width = (1.0, 'unitary')
-        from yt.visualization.plot_window import \
-            PWViewerMPL, GetBoundsAndCenter
-        (bounds, center) = GetBoundsAndCenter(axis, center, width, self.pf)
-        pw = PWViewerMPL(self, bounds)
-        return pw
-
     def interpolate_discretize(self, LE, RE, field, side, log_spacing=True):
         """
         This returns a uniform grid of points between *LE* and *RE*,
@@ -1193,6 +1184,23 @@
     def hub_upload(self):
         self._mrep.upload()
 
+    def to_pw(self, fields=None, center='c', width=None, axes_unit=None, 
+               origin='center-window'):
+        r"""Create a :class:`~yt.visualization.plot_window.PWViewerMPL` from this
+        object.
+
+        This is a bare-bones mechanism of creating a plot window from this
+        object, which can then be moved around, zoomed, and on and on.  All
+        behavior of the plot window is relegated to that routine.
+        """
+        bounds = self._get_pw_params(fields, center, width)
+        from yt.visualization.plot_window import PWViewerMPL
+        from yt.visualization.fixed_resolution import FixedResolutionBuffer
+        pw = PWViewerMPL(self, bounds, origin=origin, frb_generator=FixedResolutionBuffer,
+                         plot_type='Slice')
+        pw.set_axes_unit(axes_unit)
+        return pw
+
 class AMRCuttingPlaneBase(AMR2DData):
     _plane = None
     _top_node = "/CuttingPlanes"
@@ -1355,6 +1363,30 @@
         return "%s/c%s_L%s" % \
             (self._top_node, cen_name, L_name)
 
+    def to_pw(self, fields, center='c', width=None, axes_unit=None):
+        r"""Create a :class:`~yt.visualization.plot_window.PWViewerMPL` from this
+        object.
+
+        This is a bare-bones mechanism of creating a plot window from this
+        object, which can then be moved around, zoomed, and on and on.  All
+        behavior of the plot window is relegated to that routine.
+        """
+        normal = self.normal
+        center = self.center
+        if fields == None:
+            if self.fields == None:
+                raise SyntaxError("The fields keyword argument must be set")
+        else:
+            self.fields = ensure_list(fields)
+        from yt.visualization.plot_window import \
+            GetOffAxisBoundsAndCenter, PWViewerMPL
+        from yt.visualization.fixed_resolution import ObliqueFixedResolutionBuffer
+        (bounds, center_rot) = GetOffAxisBoundsAndCenter(normal, center, width, self.pf)
+        pw = PWViewerMPL(self, bounds, origin='center-window', periodic=False, oblique=True,
+                         frb_generator=ObliqueFixedResolutionBuffer, plot_type='OffAxisSlice')
+        pw.set_axes_unit(axes_unit)
+        return pw
+
     def to_frb(self, width, resolution, height=None):
         r"""This function returns an ObliqueFixedResolutionBuffer generated
         from this object.
@@ -2254,6 +2286,23 @@
     def add_fields(self, fields, weight = "CellMassMsun"):
         pass
 
+    def to_pw(self, fields=None, center='c', width=None, axes_unit=None, 
+               origin='center-window'):
+        r"""Create a :class:`~yt.visualization.plot_window.PWViewerMPL` from this
+        object.
+
+        This is a bare-bones mechanism of creating a plot window from this
+        object, which can then be moved around, zoomed, and on and on.  All
+        behavior of the plot window is relegated to that routine.
+        """
+        bounds = self._get_pw_params(fields, center, width)
+        from yt.visualization.plot_window import PWViewerMPL
+        from yt.visualization.fixed_resolution import FixedResolutionBuffer
+        pw = PWViewerMPL(self, bounds, origin=origin, frb_generator=FixedResolutionBuffer,
+                         plot_type='Projection')
+        pw.set_axes_unit(axes_unit)
+        return pw
+
     def _project_grid(self, grid, fields, zero_out):
         # We split this next bit into two sections to try to limit the IO load
         # on the system.  This way, we perserve grid state (@restore_grid_state


diff -r b5b438054310909ce9395a5b359a9bc0caf7326e -r eea2f500219ce4284e74b77c7cd42d901a18a1d6 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -695,6 +695,15 @@
 
     """
     _current_field = None
+    _frb_generator = None
+    _plot_type = None
+
+    def __init__(self, *args, **kwargs):
+        if self._frb_generator == None:
+            self._frb_generator = kwargs.pop("frb_generator")
+        if self._plot_type == None:
+            self._plot_type = kwargs.pop("plot_type")
+        PWViewer.__init__(self, *args, **kwargs)
 
     def _setup_plots(self):
         if self._current_field is not None:



https://bitbucket.org/yt_analysis/yt/changeset/136499a35ceb/
changeset:   136499a35ceb
branch:      yt
user:        ngoldbaum
date:        2012-10-10 08:12:33
summary:     fields should be an optional keyword argument.
affected #:  1 file

diff -r eea2f500219ce4284e74b77c7cd42d901a18a1d6 -r 136499a35ceb274cd135b722a9d8636d039c2bee yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -1363,7 +1363,7 @@
         return "%s/c%s_L%s" % \
             (self._top_node, cen_name, L_name)
 
-    def to_pw(self, fields, center='c', width=None, axes_unit=None):
+    def to_pw(self, fields=None, center='c', width=None, axes_unit=None):
         r"""Create a :class:`~yt.visualization.plot_window.PWViewerMPL` from this
         object.
 



https://bitbucket.org/yt_analysis/yt/changeset/f180d1f7c698/
changeset:   f180d1f7c698
branch:      yt
user:        ngoldbaum
date:        2012-10-10 08:40:05
summary:     Cleaning up, fixing a couple more errors.
affected #:  1 file

diff -r 136499a35ceb274cd135b722a9d8636d039c2bee -r f180d1f7c69863af81f5662df66da37b0e71b4ea yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -855,16 +855,21 @@
         for field in temp_data.keys():
             self[field] = temp_data[field]
 
-    def _get_pw_params(self, fields, center, width):
+    def _get_pw(self, fields, center, width, origin, axes_unit, plot_type):
         axis = self.axis
         if fields == None:
             if self.fields == None:
                 raise SyntaxError("The fields keyword argument must be set")
         else:
             self.fields = ensure_list(fields)
-        from yt.visualization.plot_window import GetBoundsAndCenter
+        from yt.visualization.plot_window import \
+            GetBoundsAndCenter, PWViewerMPL
+        from yt.visualization.fixed_resolution import FixedResolutionBuffer
         (bounds, center) = GetBoundsAndCenter(axis, center, width, self.pf)
-        return bounds
+        pw = PWViewerMPL(self, bounds, origin=origin, frb_generator=FixedResolutionBuffer, 
+                         plot_type=plot_type)
+        pw.set_axes_unit(axes_unit)
+        return pw
 
     def to_frb(self, width, resolution, center=None, height=None):
         r"""This function returns a FixedResolutionBuffer generated from this
@@ -1193,12 +1198,7 @@
         object, which can then be moved around, zoomed, and on and on.  All
         behavior of the plot window is relegated to that routine.
         """
-        bounds = self._get_pw_params(fields, center, width)
-        from yt.visualization.plot_window import PWViewerMPL
-        from yt.visualization.fixed_resolution import FixedResolutionBuffer
-        pw = PWViewerMPL(self, bounds, origin=origin, frb_generator=FixedResolutionBuffer,
-                         plot_type='Slice')
-        pw.set_axes_unit(axes_unit)
+        pw = self._get_pw(fields, center, width, origin, axes_unit, 'Slice')
         return pw
 
 class AMRCuttingPlaneBase(AMR2DData):
@@ -1794,6 +1794,18 @@
             convs[:] = 1.0
         return dls, convs
 
+    def to_pw(self, fields=None, center='c', width=None, axes_unit=None, 
+               origin='center-window'):
+        r"""Create a :class:`~yt.visualization.plot_window.PWViewerMPL` from this
+        object.
+
+        This is a bare-bones mechanism of creating a plot window from this
+        object, which can then be moved around, zoomed, and on and on.  All
+        behavior of the plot window is relegated to that routine.
+        """
+        pw = self._get_pw(fields, center, width, origin, axes_unit, 'Projection')
+        return pw
+
     def get_data(self, fields = None):
         if fields is None: fields = ensure_list(self.fields)[:]
         else: fields = ensure_list(fields)
@@ -2295,12 +2307,7 @@
         object, which can then be moved around, zoomed, and on and on.  All
         behavior of the plot window is relegated to that routine.
         """
-        bounds = self._get_pw_params(fields, center, width)
-        from yt.visualization.plot_window import PWViewerMPL
-        from yt.visualization.fixed_resolution import FixedResolutionBuffer
-        pw = PWViewerMPL(self, bounds, origin=origin, frb_generator=FixedResolutionBuffer,
-                         plot_type='Projection')
-        pw.set_axes_unit(axes_unit)
+        pw = self._get_pw(fields, center, width, origin, axes_unit, 'Projection')
         return pw
 
     def _project_grid(self, grid, fields, zero_out):

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