[yt-svn] commit/yt-3.0: 9 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Oct 22 05:31:05 PDT 2013


9 new commits in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/d7852f590c02/
Changeset:   d7852f590c02
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-18 21:22:06
Summary:     provide factory function for slice plots
Affected #:  1 file

diff -r 29e24eb0f722d4e4d907b58ed1398eee652a8bdf -r d7852f590c025a626bb530466b16f332d7c80a6a yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1208,7 +1208,7 @@
             ret += '<img src="data:image/png;base64,%s"><br>' % img
         return ret
 
-class SlicePlot(PWViewerMPL):
+class OnAxisSlicePlot(PWViewerMPL):
     r"""Creates a slice plot from a parameter file
 
     Given a pf object, an axis to slice along, and a field name
@@ -1989,3 +1989,32 @@
             yfrac
         )
         return axrect, caxrect
+
+def SlicePlot(pf, normal, fields, *args, **kwargs):
+    r"""
+    A factory function for
+    :class:`yt.visualization.plot_window.OnAxisSlicePlot`
+    and :class:`yt.visualization.plot_window.OffAxisSlicePlot` objects.  This
+    essentially allows for a single entry point to both types of slice plots.
+
+    Parameters
+    ----------
+    pf : :class:`yt.data_objects.api.StaticOutput`
+        This is the parameter file object corresponding to the
+        simulation output to be plotted.
+
+    normal : int or one of 'x', 'y', 'z', or sequence of floats
+        This specifies the normal vector to the slice.  If given as an integer
+        or a coordinate string (0=x, 1=y, 2=z), this function will return an
+        :class:`OnAxisSlicePlot` object.  If given as a sequence of floats,
+        this is interpretted as an off-axis vector and an
+        :class:`OffAxisSlicePlot` object is returned.
+    fields : string
+        The name of the field(s) to be plotted.
+
+    """
+    
+    if iterable(normal) and not isinstance(normal,str):
+        return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
+    else:
+        return OnAxisSlicePlot(pf, normal, fields, *args, **kwargs)


https://bitbucket.org/yt_analysis/yt-3.0/commits/fb3cf0cdece6/
Changeset:   fb3cf0cdece6
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 04:07:55
Summary:     add docstring for ipython query and make backwards-compatible
Affected #:  1 file

diff -r d7852f590c025a626bb530466b16f332d7c80a6a -r fb3cf0cdece6778670669091d7569c0797033c8d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1990,19 +1990,23 @@
         )
         return axrect, caxrect
 
-def SlicePlot(pf, normal, fields, *args, **kwargs):
+def SlicePlot(pf, normal=None, fields=None, axis=None, *args, **kwargs):
     r"""
     A factory function for
     :class:`yt.visualization.plot_window.OnAxisSlicePlot`
     and :class:`yt.visualization.plot_window.OffAxisSlicePlot` objects.  This
-    essentially allows for a single entry point to both types of slice plots.
+    essentially allows for a single entry point to both types of slice plots,
+    the distinction being determined by the specified normal vector to the
+    slice.
+
+        The returned plot object can be updated using one of the many helper
+    functions defined in PlotWindow.
 
     Parameters
     ----------
     pf : :class:`yt.data_objects.api.StaticOutput`
         This is the parameter file object corresponding to the
         simulation output to be plotted.
-
     normal : int or one of 'x', 'y', 'z', or sequence of floats
         This specifies the normal vector to the slice.  If given as an integer
         or a coordinate string (0=x, 1=y, 2=z), this function will return an
@@ -2010,11 +2014,125 @@
         this is interpretted as an off-axis vector and an
         :class:`OffAxisSlicePlot` object is returned.
     fields : string
-        The name of the field(s) to be plotted.
+         The name of the field(s) to be plotted.
+    axis : int or one of 'x', 'y', 'z'
+         An int corresponding to the axis to slice along (0=x, 1=y, 2=z)
+         or the axis name itself.  If specified, this will replace normal.
+         
+    The following are nominally keyword arguments passed onto the respective
+    slice plot objects generated by this function.
+
+    center : two or three-element vector of sequence floats, 'c', or 'center',
+             or 'max'
+         If set to 'c', 'center' or left blank, the plot is centered on the
+         middle of the domain. If set to 'max' or 'm', the center will be at 
+         the point of highest density.
+    width : tuple or a float.
+         Width can have four different formats to support windows with variable
+         x and y widths.  They are:
+
+         ==================================     =======================
+         format                                 example
+         ==================================     =======================
+         (float, string)                        (10,'kpc')
+         ((float, string), (float, string))     ((10,'kpc'),(15,'kpc'))
+         float                                  0.2
+         (float, float)                         (0.2, 0.3)
+         ==================================     =======================
+
+         For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+         wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a
+         window that is 10 kiloparsecs wide along the x axis and 15
+         kiloparsecs wide along the y axis.  In the other two examples, code
+         units are assumed, for example (0.2, 0.3) requests a plot that has an
+         x width of 0.2 and a y width of 0.3 in code units.  If units are
+         provided the resulting plot axis labels will use the supplied units.
+    axes_unit : A string
+         The name of the unit for the tick labels on the x and y axes.
+         Defaults to None, which automatically picks an appropriate unit.
+         If axes_unit is '1', 'u', or 'unitary', it will not display the
+         units, and only show the axes name.
+    origin : string or length 1, 2, or 3 sequence of strings
+         The location of the origin of the plot coordinate system for
+         `OnAxisSlicePlot` objects; for `OffAxisSlicePlot` objects,
+         this parameter is discarded.  This is represented by '-' separated
+         string or a tuple of strings.  In the first index the y-location is
+         given by 'lower', 'upper', or 'center'.  The second index is the
+         x-location, given as 'left', 'right', or 'center'.  Finally, the
+         whether the origin is applied in 'domain' space, plot 'window' space
+         or 'native' simulation coordinate system is given. For example, both
+         'upper-right-domain' and ['upper', 'right', 'domain'] both place the
+         origin in the upper right hand corner of domain space. If x or y are
+         not given, a value is inffered.  For instance, 'left-domain'
+         corresponds to the lower-left hand corner of the simulation domain,
+         'center-domain' corresponds to the center of the simulation domain,
+         or 'center-window' for the center of the plot window. Further
+         examples:
+
+         ==================================     ============================
+         format                                 example
+         ==================================     ============================
+         '{space}'                              'domain'
+         '{xloc}-{space}'                       'left-window'
+         '{yloc}-{space}'                       'upper-domain'
+         '{yloc}-{xloc}-{space}'                'lower-right-window'
+         ('{space}',)                           ('window',)
+         ('{xloc}', '{space}')                  ('right', 'domain')
+         ('{yloc}', '{space}')                  ('lower', 'window')
+         ('{yloc}', '{xloc}', '{space}')        ('lower', 'right', 'window')
+         ==================================     ============================
+    north-vector : a sequence of floats
+        A vector defining the 'up' direction in the `OffAxisSlicePlot`; not
+        used in OnAxisSlicePlots.  This option sets the orientation of the
+        slicing plane.  If not set, an arbitrary grid-aligned north-vector is
+        chosen.
+    fontsize : integer
+         The size of the fonts for the axis, colorbar, and tick labels.
+    field_parameters : dictionary
+         A dictionary of field parameters than can be accessed by derived
+         fields.
+
+    Raises
+    ------
+    AssertionError
+        If a proper normal axis is not specified via the normal or axis
+        keywords, and/or if a field to plot is not specified.
+
+    Examples
+    --------
+
+    >>> slc = SlicePlot(pf, "x", "Density", center=[0.2,0.3,0.4])
+    >>> slc = SlicePlot(pf, 2, "Temperature")
+    >>> slc = SlicePlot(pf, [0.4,0.2,-0.1], "Pressure",
+                        north_vector=[0.2,-0.3,0.1])
 
     """
+    # Make sure we are passed a normal
+    # we check the axis keyword for backwards compatability
+    if normal is None: normal = axis
+    if normal is None:
+        raise AssertionError("Must pass a normal vector to the slice!")
+
+    # to keep positional ordering we had to make fields a keyword; make sure
+    # it is present
+    if fields is None:
+        raise AssertionError("Must pass field(s) to plot!")
+
+    # use an OnAxisSlicePlot where possible, e.g.:
+    # maybe someone passed normal=[0,0,1] when they should have just used "z"
+    if iterable(normal):
+        normal = np.array(normal)
+        np.divide(normal, np.dot(normal,normal), normal)
+    if np.count_nonzero(normal) == 1:
+        normal = ("x","y","z")[np.nonzero(normal)[0][0]]
     
     if iterable(normal) and not isinstance(normal,str):
+        # OffAxisSlicePlot has hardcoded origin; remove it if in kwargs
+        if 'origin' in kwargs: del kwargs['origin']
+        
         return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
     else:
+        # north_vector not used in OnAxisSlicePlots; remove it if in kwargs
+        if 'north_vector' in kwargs: del kwargs['north_vector']
+        
         return OnAxisSlicePlot(pf, normal, fields, *args, **kwargs)


https://bitbucket.org/yt_analysis/yt-3.0/commits/81bb09b3c388/
Changeset:   81bb09b3c388
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 04:08:57
Summary:     Merged yt_analysis/yt-3.0 into yt-3.0
Affected #:  2 files

diff -r fb3cf0cdece6778670669091d7569c0797033c8d -r 81bb09b3c388b425bb0bad93711ad2065cc4ebe5 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -459,8 +459,9 @@
                 for j in range(2):
                     for k in range(2):
                         ii = ((k*2)+j)*2+i
+                        # Note: C order because our index converts C to F.
                         source[field][:,ii] = \
-                            dt[i::2,j::2,k::2].ravel(order="F")
+                            dt[i::2,j::2,k::2].ravel(order="C")
         oct_handler.fill_level(0, levels, cell_inds, file_inds, tr, source)
         del source
         # Now we continue with the additional levels.

diff -r fb3cf0cdece6778670669091d7569c0797033c8d -r 81bb09b3c388b425bb0bad93711ad2065cc4ebe5 yt/frontends/art/io.py
--- a/yt/frontends/art/io.py
+++ b/yt/frontends/art/io.py
@@ -36,10 +36,10 @@
     masks = None
     caching = True
 
-    def __init__(self):
+    def __init__(self, *args, **kwargs):
         self.cache = {}
         self.masks = {}
-        super(IOHandlerART, self).__init__()
+        super(IOHandlerART, self).__init__(*args, **kwargs)
 
     def _read_fluid_selection(self, chunks, selector, fields, size):
         # Chunks in this case will have affiliated domain subset objects


https://bitbucket.org/yt_analysis/yt-3.0/commits/1cceb8a34168/
Changeset:   1cceb8a34168
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 04:28:50
Summary:     axis string will show up in iterable(); check this
Affected #:  1 file

diff -r 81bb09b3c388b425bb0bad93711ad2065cc4ebe5 -r 1cceb8a341680b282534df190239fddcb2b89baa yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2119,13 +2119,14 @@
         raise AssertionError("Must pass field(s) to plot!")
 
     # use an OnAxisSlicePlot where possible, e.g.:
-    # maybe someone passed normal=[0,0,1] when they should have just used "z"
-    if iterable(normal):
+    # maybe someone passed normal=[0,0,0.2] when they should have just used "z"
+    if iterable(normal) and not isinstance(normal,str):
         normal = np.array(normal)
         np.divide(normal, np.dot(normal,normal), normal)
     if np.count_nonzero(normal) == 1:
         normal = ("x","y","z")[np.nonzero(normal)[0][0]]
-    
+
+    # by now the normal should be properly set to get either a On/Off Axis plot
     if iterable(normal) and not isinstance(normal,str):
         # OffAxisSlicePlot has hardcoded origin; remove it if in kwargs
         if 'origin' in kwargs: del kwargs['origin']


https://bitbucket.org/yt_analysis/yt-3.0/commits/5098e0baa93f/
Changeset:   5098e0baa93f
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 06:46:43
Summary:     doc markup
Affected #:  1 file

diff -r 1cceb8a341680b282534df190239fddcb2b89baa -r 5098e0baa93f781965547cc74d37559dc7b30290 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2083,7 +2083,7 @@
          ==================================     ============================
     north-vector : a sequence of floats
         A vector defining the 'up' direction in the `OffAxisSlicePlot`; not
-        used in OnAxisSlicePlots.  This option sets the orientation of the
+        used in `OnAxisSlicePlot`.  This option sets the orientation of the
         slicing plane.  If not set, an arbitrary grid-aligned north-vector is
         chosen.
     fontsize : integer


https://bitbucket.org/yt_analysis/yt-3.0/commits/1cd6c25a4723/
Changeset:   1cd6c25a4723
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 06:48:20
Summary:     update API
Affected #:  2 files

diff -r 5098e0baa93f781965547cc74d37559dc7b30290 -r 1cd6c25a4723f9437a8f49be093d0ffae46f7233 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -143,7 +143,8 @@
     get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
     callback_registry, write_bitmap, write_image, \
     apply_colormap, scale_image, write_projection, write_fits, \
-    SlicePlot, OffAxisSlicePlot, ProjectionPlot, OffAxisProjectionPlot, \
+    SlicePlot, OnAxisSlicePlot, OffAxisSlicePlot, \
+    ProjectionPlot, OffAxisProjectionPlot, \
     show_colormaps
 
 from yt.visualization.volume_rendering.api import \

diff -r 5098e0baa93f781965547cc74d37559dc7b30290 -r 1cd6c25a4723f9437a8f49be093d0ffae46f7233 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -49,6 +49,7 @@
 
 from plot_window import \
     SlicePlot, \
+    OnAxisSlicePlot, \
     OffAxisSlicePlot, \
     ProjectionPlot, \
     OffAxisProjectionPlot


https://bitbucket.org/yt_analysis/yt-3.0/commits/f02c4fb9ea30/
Changeset:   f02c4fb9ea30
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 06:54:06
Summary:     warn the user if we are neglecting parameters
Affected #:  1 file

diff -r 1cd6c25a4723f9437a8f49be093d0ffae46f7233 -r f02c4fb9ea305a38a2d736a69465a0306c71fce2 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2129,11 +2129,19 @@
     # by now the normal should be properly set to get either a On/Off Axis plot
     if iterable(normal) and not isinstance(normal,str):
         # OffAxisSlicePlot has hardcoded origin; remove it if in kwargs
-        if 'origin' in kwargs: del kwargs['origin']
+        if 'origin' in kwargs: 
+            msg = "Ignoring 'origin' keyword as it is ill-defined for " \
+                  "an OffAxisSlicePlot object."
+            mylog.warn(msg)
+            del kwargs['origin']
         
         return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
     else:
         # north_vector not used in OnAxisSlicePlots; remove it if in kwargs
-        if 'north_vector' in kwargs: del kwargs['north_vector']
+        if 'north_vector' in kwargs: 
+            msg = "Ignoring 'north_vector' keyword as it is ill-defined for " \
+                  "an OnAxisSlicePlot object."
+            mylog.warn(msg)
+            del kwargs['north_vector']
         
         return OnAxisSlicePlot(pf, normal, fields, *args, **kwargs)


https://bitbucket.org/yt_analysis/yt-3.0/commits/c32db22f3650/
Changeset:   c32db22f3650
Branch:      yt-3.0
User:        ChrisMalone
Date:        2013-10-19 06:55:32
Summary:     rename to AxisAlignedSlicePlot
Affected #:  3 files

diff -r f02c4fb9ea305a38a2d736a69465a0306c71fce2 -r c32db22f3650b0a6926270d4b14ebaf1bfe14dc9 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -143,7 +143,7 @@
     get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
     callback_registry, write_bitmap, write_image, \
     apply_colormap, scale_image, write_projection, write_fits, \
-    SlicePlot, OnAxisSlicePlot, OffAxisSlicePlot, \
+    SlicePlot, AxisAlignedSlicePlot, OffAxisSlicePlot, \
     ProjectionPlot, OffAxisProjectionPlot, \
     show_colormaps
 

diff -r f02c4fb9ea305a38a2d736a69465a0306c71fce2 -r c32db22f3650b0a6926270d4b14ebaf1bfe14dc9 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -49,7 +49,7 @@
 
 from plot_window import \
     SlicePlot, \
-    OnAxisSlicePlot, \
+    AxisAlignedSlicePlot, \
     OffAxisSlicePlot, \
     ProjectionPlot, \
     OffAxisProjectionPlot

diff -r f02c4fb9ea305a38a2d736a69465a0306c71fce2 -r c32db22f3650b0a6926270d4b14ebaf1bfe14dc9 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1208,7 +1208,7 @@
             ret += '<img src="data:image/png;base64,%s"><br>' % img
         return ret
 
-class OnAxisSlicePlot(PWViewerMPL):
+class AxisAlignedSlicePlot(PWViewerMPL):
     r"""Creates a slice plot from a parameter file
 
     Given a pf object, an axis to slice along, and a field name
@@ -1993,7 +1993,7 @@
 def SlicePlot(pf, normal=None, fields=None, axis=None, *args, **kwargs):
     r"""
     A factory function for
-    :class:`yt.visualization.plot_window.OnAxisSlicePlot`
+    :class:`yt.visualization.plot_window.AxisAlignedSlicePlot`
     and :class:`yt.visualization.plot_window.OffAxisSlicePlot` objects.  This
     essentially allows for a single entry point to both types of slice plots,
     the distinction being determined by the specified normal vector to the
@@ -2010,7 +2010,7 @@
     normal : int or one of 'x', 'y', 'z', or sequence of floats
         This specifies the normal vector to the slice.  If given as an integer
         or a coordinate string (0=x, 1=y, 2=z), this function will return an
-        :class:`OnAxisSlicePlot` object.  If given as a sequence of floats,
+        :class:`AxisAlignedSlicePlot` object.  If given as a sequence of floats,
         this is interpretted as an off-axis vector and an
         :class:`OffAxisSlicePlot` object is returned.
     fields : string
@@ -2054,7 +2054,7 @@
          units, and only show the axes name.
     origin : string or length 1, 2, or 3 sequence of strings
          The location of the origin of the plot coordinate system for
-         `OnAxisSlicePlot` objects; for `OffAxisSlicePlot` objects,
+         `AxisAlignedSlicePlot` objects; for `OffAxisSlicePlot` objects,
          this parameter is discarded.  This is represented by '-' separated
          string or a tuple of strings.  In the first index the y-location is
          given by 'lower', 'upper', or 'center'.  The second index is the
@@ -2083,7 +2083,7 @@
          ==================================     ============================
     north-vector : a sequence of floats
         A vector defining the 'up' direction in the `OffAxisSlicePlot`; not
-        used in `OnAxisSlicePlot`.  This option sets the orientation of the
+        used in `AxisAlignedSlicePlot`.  This option sets the orientation of the
         slicing plane.  If not set, an arbitrary grid-aligned north-vector is
         chosen.
     fontsize : integer
@@ -2118,7 +2118,7 @@
     if fields is None:
         raise AssertionError("Must pass field(s) to plot!")
 
-    # use an OnAxisSlicePlot where possible, e.g.:
+    # use an AxisAlignedSlicePlot where possible, e.g.:
     # maybe someone passed normal=[0,0,0.2] when they should have just used "z"
     if iterable(normal) and not isinstance(normal,str):
         normal = np.array(normal)
@@ -2137,11 +2137,11 @@
         
         return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
     else:
-        # north_vector not used in OnAxisSlicePlots; remove it if in kwargs
+        # north_vector not used in AxisAlignedSlicePlots; remove it if in kwargs
         if 'north_vector' in kwargs: 
             msg = "Ignoring 'north_vector' keyword as it is ill-defined for " \
-                  "an OnAxisSlicePlot object."
+                  "an AxisAlignedSlicePlot object."
             mylog.warn(msg)
             del kwargs['north_vector']
         
-        return OnAxisSlicePlot(pf, normal, fields, *args, **kwargs)
+        return AxisAlignedSlicePlot(pf, normal, fields, *args, **kwargs)


https://bitbucket.org/yt_analysis/yt-3.0/commits/34f821e4b5f2/
Changeset:   34f821e4b5f2
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-10-22 14:30:56
Summary:     Merged in ChrisMalone/yt-3.0 (pull request #118)

Create a single entry-point to SlicePlot and OffAxisSlicePlot
Affected #:  3 files

diff -r ea58f090673982ed065dfcca187fad1535cf84ac -r 34f821e4b5f24d61dd946f19716dc65db01cf11a yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -143,7 +143,8 @@
     get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
     callback_registry, write_bitmap, write_image, \
     apply_colormap, scale_image, write_projection, write_fits, \
-    SlicePlot, OffAxisSlicePlot, ProjectionPlot, OffAxisProjectionPlot, \
+    SlicePlot, AxisAlignedSlicePlot, OffAxisSlicePlot, \
+    ProjectionPlot, OffAxisProjectionPlot, \
     show_colormaps
 
 from yt.visualization.volume_rendering.api import \

diff -r ea58f090673982ed065dfcca187fad1535cf84ac -r 34f821e4b5f24d61dd946f19716dc65db01cf11a yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -49,6 +49,7 @@
 
 from plot_window import \
     SlicePlot, \
+    AxisAlignedSlicePlot, \
     OffAxisSlicePlot, \
     ProjectionPlot, \
     OffAxisProjectionPlot

diff -r ea58f090673982ed065dfcca187fad1535cf84ac -r 34f821e4b5f24d61dd946f19716dc65db01cf11a yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1208,7 +1208,7 @@
             ret += '<img src="data:image/png;base64,%s"><br>' % img
         return ret
 
-class SlicePlot(PWViewerMPL):
+class AxisAlignedSlicePlot(PWViewerMPL):
     r"""Creates a slice plot from a parameter file
 
     Given a pf object, an axis to slice along, and a field name
@@ -1989,3 +1989,159 @@
             yfrac
         )
         return axrect, caxrect
+
+def SlicePlot(pf, normal=None, fields=None, axis=None, *args, **kwargs):
+    r"""
+    A factory function for
+    :class:`yt.visualization.plot_window.AxisAlignedSlicePlot`
+    and :class:`yt.visualization.plot_window.OffAxisSlicePlot` objects.  This
+    essentially allows for a single entry point to both types of slice plots,
+    the distinction being determined by the specified normal vector to the
+    slice.
+
+        The returned plot object can be updated using one of the many helper
+    functions defined in PlotWindow.
+
+    Parameters
+    ----------
+    pf : :class:`yt.data_objects.api.StaticOutput`
+        This is the parameter file object corresponding to the
+        simulation output to be plotted.
+    normal : int or one of 'x', 'y', 'z', or sequence of floats
+        This specifies the normal vector to the slice.  If given as an integer
+        or a coordinate string (0=x, 1=y, 2=z), this function will return an
+        :class:`AxisAlignedSlicePlot` object.  If given as a sequence of floats,
+        this is interpretted as an off-axis vector and an
+        :class:`OffAxisSlicePlot` object is returned.
+    fields : string
+         The name of the field(s) to be plotted.
+    axis : int or one of 'x', 'y', 'z'
+         An int corresponding to the axis to slice along (0=x, 1=y, 2=z)
+         or the axis name itself.  If specified, this will replace normal.
+         
+    The following are nominally keyword arguments passed onto the respective
+    slice plot objects generated by this function.
+
+    center : two or three-element vector of sequence floats, 'c', or 'center',
+             or 'max'
+         If set to 'c', 'center' or left blank, the plot is centered on the
+         middle of the domain. If set to 'max' or 'm', the center will be at 
+         the point of highest density.
+    width : tuple or a float.
+         Width can have four different formats to support windows with variable
+         x and y widths.  They are:
+
+         ==================================     =======================
+         format                                 example
+         ==================================     =======================
+         (float, string)                        (10,'kpc')
+         ((float, string), (float, string))     ((10,'kpc'),(15,'kpc'))
+         float                                  0.2
+         (float, float)                         (0.2, 0.3)
+         ==================================     =======================
+
+         For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+         wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a
+         window that is 10 kiloparsecs wide along the x axis and 15
+         kiloparsecs wide along the y axis.  In the other two examples, code
+         units are assumed, for example (0.2, 0.3) requests a plot that has an
+         x width of 0.2 and a y width of 0.3 in code units.  If units are
+         provided the resulting plot axis labels will use the supplied units.
+    axes_unit : A string
+         The name of the unit for the tick labels on the x and y axes.
+         Defaults to None, which automatically picks an appropriate unit.
+         If axes_unit is '1', 'u', or 'unitary', it will not display the
+         units, and only show the axes name.
+    origin : string or length 1, 2, or 3 sequence of strings
+         The location of the origin of the plot coordinate system for
+         `AxisAlignedSlicePlot` objects; for `OffAxisSlicePlot` objects,
+         this parameter is discarded.  This is represented by '-' separated
+         string or a tuple of strings.  In the first index the y-location is
+         given by 'lower', 'upper', or 'center'.  The second index is the
+         x-location, given as 'left', 'right', or 'center'.  Finally, the
+         whether the origin is applied in 'domain' space, plot 'window' space
+         or 'native' simulation coordinate system is given. For example, both
+         'upper-right-domain' and ['upper', 'right', 'domain'] both place the
+         origin in the upper right hand corner of domain space. If x or y are
+         not given, a value is inffered.  For instance, 'left-domain'
+         corresponds to the lower-left hand corner of the simulation domain,
+         'center-domain' corresponds to the center of the simulation domain,
+         or 'center-window' for the center of the plot window. Further
+         examples:
+
+         ==================================     ============================
+         format                                 example
+         ==================================     ============================
+         '{space}'                              'domain'
+         '{xloc}-{space}'                       'left-window'
+         '{yloc}-{space}'                       'upper-domain'
+         '{yloc}-{xloc}-{space}'                'lower-right-window'
+         ('{space}',)                           ('window',)
+         ('{xloc}', '{space}')                  ('right', 'domain')
+         ('{yloc}', '{space}')                  ('lower', 'window')
+         ('{yloc}', '{xloc}', '{space}')        ('lower', 'right', 'window')
+         ==================================     ============================
+    north-vector : a sequence of floats
+        A vector defining the 'up' direction in the `OffAxisSlicePlot`; not
+        used in `AxisAlignedSlicePlot`.  This option sets the orientation of the
+        slicing plane.  If not set, an arbitrary grid-aligned north-vector is
+        chosen.
+    fontsize : integer
+         The size of the fonts for the axis, colorbar, and tick labels.
+    field_parameters : dictionary
+         A dictionary of field parameters than can be accessed by derived
+         fields.
+
+    Raises
+    ------
+    AssertionError
+        If a proper normal axis is not specified via the normal or axis
+        keywords, and/or if a field to plot is not specified.
+
+    Examples
+    --------
+
+    >>> slc = SlicePlot(pf, "x", "Density", center=[0.2,0.3,0.4])
+    >>> slc = SlicePlot(pf, 2, "Temperature")
+    >>> slc = SlicePlot(pf, [0.4,0.2,-0.1], "Pressure",
+                        north_vector=[0.2,-0.3,0.1])
+
+    """
+    # Make sure we are passed a normal
+    # we check the axis keyword for backwards compatability
+    if normal is None: normal = axis
+    if normal is None:
+        raise AssertionError("Must pass a normal vector to the slice!")
+
+    # to keep positional ordering we had to make fields a keyword; make sure
+    # it is present
+    if fields is None:
+        raise AssertionError("Must pass field(s) to plot!")
+
+    # use an AxisAlignedSlicePlot where possible, e.g.:
+    # maybe someone passed normal=[0,0,0.2] when they should have just used "z"
+    if iterable(normal) and not isinstance(normal,str):
+        normal = np.array(normal)
+        np.divide(normal, np.dot(normal,normal), normal)
+    if np.count_nonzero(normal) == 1:
+        normal = ("x","y","z")[np.nonzero(normal)[0][0]]
+
+    # by now the normal should be properly set to get either a On/Off Axis plot
+    if iterable(normal) and not isinstance(normal,str):
+        # OffAxisSlicePlot has hardcoded origin; remove it if in kwargs
+        if 'origin' in kwargs: 
+            msg = "Ignoring 'origin' keyword as it is ill-defined for " \
+                  "an OffAxisSlicePlot object."
+            mylog.warn(msg)
+            del kwargs['origin']
+        
+        return OffAxisSlicePlot(pf, normal, fields, *args, **kwargs)
+    else:
+        # north_vector not used in AxisAlignedSlicePlots; remove it if in kwargs
+        if 'north_vector' in kwargs: 
+            msg = "Ignoring 'north_vector' keyword as it is ill-defined for " \
+                  "an AxisAlignedSlicePlot object."
+            mylog.warn(msg)
+            del kwargs['north_vector']
+        
+        return AxisAlignedSlicePlot(pf, normal, fields, *args, **kwargs)

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

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