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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Jul 15 10:56:14 PDT 2017


15 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/41ada66e1369/
Changeset:   41ada66e1369
User:        jzuhone
Date:        2017-07-02 20:40:56+00:00
Summary:     Simple wrapper around AxisAlignedSlicePlot to plot 2D cartesian datasets
Affected #:  3 files

diff -r ac06c5d6adcf34d370202204df9a255427428514 -r 41ada66e1369e45a8944178bf35b4ef904017d94 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -109,7 +109,7 @@
     ProfilePlot, PhasePlot, ParticlePhasePlot, \
     ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
     FITSImageData, FITSSlice, FITSProjection, FITSOffAxisSlice, \
-    FITSOffAxisProjection
+    FITSOffAxisProjection, Plot2DData
 
 from yt.visualization.volume_rendering.api import \
     volume_render, create_scene, ColorTransferFunction, TransferFunction, \

diff -r ac06c5d6adcf34d370202204df9a255427428514 -r 41ada66e1369e45a8944178bf35b4ef904017d94 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -51,7 +51,8 @@
     AxisAlignedSlicePlot, \
     OffAxisSlicePlot, \
     ProjectionPlot, \
-    OffAxisProjectionPlot
+    OffAxisProjectionPlot, \
+    Plot2DData
 
 from .profile_plotter import \
     ProfilePlot, \

diff -r ac06c5d6adcf34d370202204df9a255427428514 -r 41ada66e1369e45a8944178bf35b4ef904017d94 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2014,3 +2014,110 @@
             del kwargs['north_vector']
 
         return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs)
+
+def Plot2DData(ds, fields, center='c', width=None, axes_unit=None,
+               origin='center-window', right_handed=True, fontsize=18, 
+               field_parameters=None, window_size=8.0, aspect=None, 
+               data_source=None):
+    r"""Creates a plot of a 2D dataset
+
+    Given a ds object and a field name string, this will return a
+    PWViewerMPL object containing the plot.
+
+    The plot can be updated using one of the many helper functions
+    defined in PlotWindow.
+
+    Parameters
+    ----------
+    ds : `Dataset`
+         This is the dataset object corresponding to the
+         simulation output to be plotted.
+    fields : string
+         The name of the field(s) to be plotted.
+    center : A sequence of floats, a string, or a tuple.
+         The coordinate of the center of the image. 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 located at the maximum of the
+         ('gas', 'density') field. Centering on the max or min of a specific
+         field is supported by providing a tuple such as ("min","temperature") or
+         ("max","dark_matter_density"). Units can be specified by passing in *center*
+         as a tuple containing a coordinate and string unit name or by passing
+         in a YTArray. If a list or unitless array is supplied, code units are
+         assumed.
+    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.
+    origin : string or length 1, 2, or 3 sequence.
+         The location of the origin of the plot coordinate system. This
+         is typically represented by a '-' 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'] place the
+         origin in the upper right hand corner of domain space. If x or y
+         are not given, a value is inferred. 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. In the event
+         that none of these options place the origin in a desired location,
+         a sequence of tuples and a string specifying the
+         coordinate space can be given. If plain numeric types are input,
+         units of `code_length` are assumed. 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')
+         ((yloc, '{unit}'), (xloc, '{unit}'), '{space}')    ((0.5, 'm'), (0.4, 'm'), 'window')
+         (xloc, yloc, '{space}')                            (0.23, 0.5, 'domain')
+         ===============================================    ==================================
+    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.
+    right_handed : boolean
+         Whether the implicit east vector for the image generated is set to make a right
+         handed coordinate system with a normal vector, the direction of the
+         'window' into the data.
+    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.
+    data_source: YTSelectionContainer object
+         Object to be used for data selection. Defaults to ds.all_data(), a 
+         region covering the full domain
+    """
+    return AxisAlignedSlicePlot(ds, "z", fields, center=center, width=width,
+                                axes_unit=axes_unit, origin=origin, 
+                                right_handed=right_handed, fontsize=fontsize,
+                                field_parameters=field_parameters, 
+                                window_size=window_size, aspect=aspect,
+                                data_source=data_source)
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/4e646b1c13b0/
Changeset:   4e646b1c13b0
User:        jzuhone
Date:        2017-07-02 21:51:45+00:00
Summary:     Raise an error if the dataset isn't 2d
Affected #:  1 file

diff -r 41ada66e1369e45a8944178bf35b4ef904017d94 -r 4e646b1c13b0db5452aec79c14ee46323c05bd0d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2115,6 +2115,8 @@
          Object to be used for data selection. Defaults to ds.all_data(), a 
          region covering the full domain
     """
+    if ds.dimensionality != 2:
+        raise RuntimeError("Plot2DData only plots 2D datasets!")
     return AxisAlignedSlicePlot(ds, "z", fields, center=center, width=width,
                                 axes_unit=axes_unit, origin=origin, 
                                 right_handed=right_handed, fontsize=fontsize,


https://bitbucket.org/yt_analysis/yt/commits/633522dc3574/
Changeset:   633522dc3574
User:        jzuhone
Date:        2017-07-03 02:06:44+00:00
Summary:     right_handed should always be true here
Affected #:  1 file

diff -r 4e646b1c13b0db5452aec79c14ee46323c05bd0d -r 633522dc3574279f7efab6b9984c641e87338a6d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2016,9 +2016,8 @@
         return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs)
 
 def Plot2DData(ds, fields, center='c', width=None, axes_unit=None,
-               origin='center-window', right_handed=True, fontsize=18, 
-               field_parameters=None, window_size=8.0, aspect=None, 
-               data_source=None):
+               origin='center-window', fontsize=18, field_parameters=None, 
+               window_size=8.0, aspect=None, data_source=None):
     r"""Creates a plot of a 2D dataset
 
     Given a ds object and a field name string, this will return a
@@ -2102,10 +2101,6 @@
          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.
-    right_handed : boolean
-         Whether the implicit east vector for the image generated is set to make a right
-         handed coordinate system with a normal vector, the direction of the
-         'window' into the data.
     fontsize : integer
          The size of the fonts for the axis, colorbar, and tick labels.
     field_parameters : dictionary
@@ -2119,7 +2114,7 @@
         raise RuntimeError("Plot2DData only plots 2D datasets!")
     return AxisAlignedSlicePlot(ds, "z", fields, center=center, width=width,
                                 axes_unit=axes_unit, origin=origin, 
-                                right_handed=right_handed, fontsize=fontsize,
+                                fontsize=fontsize,
                                 field_parameters=field_parameters, 
                                 window_size=window_size, aspect=aspect,
                                 data_source=data_source)
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/4cc14b64d227/
Changeset:   4cc14b64d227
User:        jzuhone
Date:        2017-07-08 03:13:15+00:00
Summary:     Fix up docstrings
Affected #:  1 file

diff -r 633522dc3574279f7efab6b9984c641e87338a6d -r 4cc14b64d2279e10fcec6107982897d37ef566f5 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -415,7 +415,7 @@
             is typically represented by a '-' 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
+            'left', 'right', or 'center'. Finally, 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'] place the
@@ -1240,7 +1240,7 @@
          is typically represented by a '-' 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
+         'left', 'right', or 'center'. Finally, 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'] place the
@@ -1268,7 +1268,7 @@
          ((yloc, '{unit}'), (xloc, '{unit}'), '{space}')    ((0.5, 'm'), (0.4, 'm'), 'window')
          (xloc, yloc, '{space}')                            (0.23, 0.5, 'domain')
          ===============================================    ==================================
-    axes_unit : A string
+    axes_unit : 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
@@ -1385,7 +1385,7 @@
          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
+    axes_unit : 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
@@ -1395,7 +1395,7 @@
          is typically represented by a '-' 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
+         'left', 'right', or 'center'. Finally, 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'] place the
@@ -1574,7 +1574,7 @@
          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
+    axes_unit : 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
@@ -1718,7 +1718,7 @@
          The name of the weighting field.  Set to None for no weight.
     max_level: int
          The maximum level to project to.
-    axes_unit : A string
+    axes_unit : 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
@@ -1904,7 +1904,7 @@
          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
+    axes_unit : 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
@@ -2068,7 +2068,7 @@
          is typically represented by a '-' 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
+         'left', 'right', or 'center'. Finally, 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'] place the
@@ -2096,7 +2096,7 @@
          ((yloc, '{unit}'), (xloc, '{unit}'), '{space}')    ((0.5, 'm'), (0.4, 'm'), 'window')
          (xloc, yloc, '{space}')                            (0.23, 0.5, 'domain')
          ===============================================    ==================================
-    axes_unit : A string
+    axes_unit : 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


https://bitbucket.org/yt_analysis/yt/commits/0d058435a227/
Changeset:   0d058435a227
User:        jzuhone
Date:        2017-07-08 03:13:31+00:00
Summary:     Rename this to plot_2d
Affected #:  3 files

diff -r 4cc14b64d2279e10fcec6107982897d37ef566f5 -r 0d058435a22729c31714bc1fd7b5443100bb8641 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -109,7 +109,7 @@
     ProfilePlot, PhasePlot, ParticlePhasePlot, \
     ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
     FITSImageData, FITSSlice, FITSProjection, FITSOffAxisSlice, \
-    FITSOffAxisProjection, Plot2DData
+    FITSOffAxisProjection, plot_2d
 
 from yt.visualization.volume_rendering.api import \
     volume_render, create_scene, ColorTransferFunction, TransferFunction, \

diff -r 4cc14b64d2279e10fcec6107982897d37ef566f5 -r 0d058435a22729c31714bc1fd7b5443100bb8641 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -52,7 +52,7 @@
     OffAxisSlicePlot, \
     ProjectionPlot, \
     OffAxisProjectionPlot, \
-    Plot2DData
+    plot_2d
 
 from .profile_plotter import \
     ProfilePlot, \

diff -r 4cc14b64d2279e10fcec6107982897d37ef566f5 -r 0d058435a22729c31714bc1fd7b5443100bb8641 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2015,9 +2015,9 @@
 
         return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs)
 
-def Plot2DData(ds, fields, center='c', width=None, axes_unit=None,
-               origin='center-window', fontsize=18, field_parameters=None, 
-               window_size=8.0, aspect=None, data_source=None):
+def plot_2d(ds, fields, center='c', width=None, axes_unit=None,
+            origin='center-window', fontsize=18, field_parameters=None, 
+            window_size=8.0, aspect=None, data_source=None):
     r"""Creates a plot of a 2D dataset
 
     Given a ds object and a field name string, this will return a


https://bitbucket.org/yt_analysis/yt/commits/2ac236e98c9b/
Changeset:   2ac236e98c9b
User:        jzuhone
Date:        2017-07-08 19:04:08+00:00
Summary:     Allow grid-based stream datasets to be in 1 and 2 dimensions
Affected #:  1 file

diff -r 0d058435a22729c31714bc1fd7b5443100bb8641 -r 2ac236e98c9b6e29fd383204b701e6b1607a5096 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -735,7 +735,13 @@
     handler.domain_left_edge = domain_left_edge
     handler.domain_right_edge = domain_right_edge
     handler.refine_by = 2
-    handler.dimensionality = 3
+    if np.all(domain_dimensions[1:] == 1):
+        dimensionality = 1
+    elif domain_dimensions[2] == 1:
+        dimensionality = 2
+    else:
+        dimensionality = 3
+    handler.dimensionality = dimensionality
     handler.domain_dimensions = domain_dimensions
     handler.simulation_time = sim_time
     handler.cosmology_simulation = 0
@@ -925,7 +931,13 @@
     handler.domain_left_edge = domain_left_edge
     handler.domain_right_edge = domain_right_edge
     handler.refine_by = refine_by
-    handler.dimensionality = 3
+    if np.all(domain_dimensions[1:] == 1):
+        dimensionality = 1
+    elif domain_dimensions[2] == 1:
+        dimensionality = 2
+    else:
+        dimensionality = 3
+    handler.dimensionality = dimensionality
     handler.domain_dimensions = domain_dimensions
     handler.simulation_time = sim_time
     handler.cosmology_simulation = 0


https://bitbucket.org/yt_analysis/yt/commits/e4faeedee9b3/
Changeset:   e4faeedee9b3
User:        jzuhone
Date:        2017-07-08 19:04:16+00:00
Summary:     Add a test for plot_2d
Affected #:  1 file

diff -r 2ac236e98c9b6e29fd383204b701e6b1607a5096 -r e4faeedee9b367ae605df64953af828681bd66b6 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -30,7 +30,8 @@
 from yt.utilities.exceptions import \
     YTInvalidFieldType
 from yt.visualization.api import \
-    SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+    SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot, \
+    plot_2d
 from yt.units.yt_array import YTArray, YTQuantity
 from yt.units import kboltz
 from yt.frontends.stream.api import load_uniform_grid
@@ -532,3 +533,10 @@
     slc.set_unit('temperature', 'keV', equivalency='thermal')
     assert str(slc.frb['gas', 'temperature'].units) == 'keV'
 
+def test_plot_2d():
+    ds = fake_random_ds((32,32,1), fields=('temperature',), units=('K',))
+    slc = SlicePlot(ds, "z", ["temperature"], width=(0.2,"unitary"),
+                    center=[0.4, 0.3, 0.5])
+    slc2 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
+                   center=[0.4, 0.3, 0.5])
+    assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/60ee89c548aa/
Changeset:   60ee89c548aa
User:        jzuhone
Date:        2017-07-14 20:50:57+00:00
Summary:     Make this work with cylindrical datasets and add a test
Affected #:  2 files

diff -r e4faeedee9b367ae605df64953af828681bd66b6 -r 60ee89c548aae366976ca9c733e853048b0ed201 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2112,7 +2112,11 @@
     """
     if ds.dimensionality != 2:
         raise RuntimeError("Plot2DData only plots 2D datasets!")
-    return AxisAlignedSlicePlot(ds, "z", fields, center=center, width=width,
+    if ds.geometry == "cartesian":
+        axis = "z"
+    elif ds.geometry == "cylindrical":
+        axis = "theta"
+    return AxisAlignedSlicePlot(ds, axis, fields, center=center, width=width,
                                 axes_unit=axes_unit, origin=origin, 
                                 fontsize=fontsize,
                                 field_parameters=field_parameters, 

diff -r e4faeedee9b367ae605df64953af828681bd66b6 -r 60ee89c548aae366976ca9c733e853048b0ed201 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -533,10 +533,19 @@
     slc.set_unit('temperature', 'keV', equivalency='thermal')
     assert str(slc.frb['gas', 'temperature'].units) == 'keV'
 
+WD = "WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5"
+
+ at requires_ds(WD)
 def test_plot_2d():
+    # Cartesian
     ds = fake_random_ds((32,32,1), fields=('temperature',), units=('K',))
     slc = SlicePlot(ds, "z", ["temperature"], width=(0.2,"unitary"),
                     center=[0.4, 0.3, 0.5])
     slc2 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
                    center=[0.4, 0.3, 0.5])
-    assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
\ No newline at end of file
+    assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
+    # Cylindrical
+    ds = data_dir_load(WD)
+    slc = SlicePlot(ds, "theta", ["density"], width=(0.2, "unitary"))
+    slc2 = plot_2d(ds, "density", width=(0.2, "unitary"))
+    assert_array_equal(slc.frb['density'], slc2.frb['density'])
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/9ae26203a6ac/
Changeset:   9ae26203a6ac
User:        jzuhone
Date:        2017-07-14 21:08:21+00:00
Summary:     Add in polar coordinates
Affected #:  1 file

diff -r 60ee89c548aae366976ca9c733e853048b0ed201 -r 9ae26203a6acc54fba909daf83b767c7d027b1fa yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2112,7 +2112,7 @@
     """
     if ds.dimensionality != 2:
         raise RuntimeError("Plot2DData only plots 2D datasets!")
-    if ds.geometry == "cartesian":
+    if ds.geometry == "cartesian" or ds.geometry == "polar":
         axis = "z"
     elif ds.geometry == "cylindrical":
         axis = "theta"


https://bitbucket.org/yt_analysis/yt/commits/dd55684d3278/
Changeset:   dd55684d3278
User:        jzuhone
Date:        2017-07-14 21:34:51+00:00
Summary:     Allow the center argument to be in 2D
Affected #:  2 files

diff -r 9ae26203a6acc54fba909daf83b767c7d027b1fa -r dd55684d3278380f0f1c1699d03bcf4050924fa7 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -45,7 +45,7 @@
     YTSpatialPlotDataset
 from yt.funcs import \
     mylog, iterable, ensure_list, \
-    fix_axis, fix_unitary
+    fix_axis, fix_unitary, obj_length
 from yt.units.unit_object import \
     Unit
 from yt.units.unit_registry import \
@@ -2042,7 +2042,7 @@
          ("max","dark_matter_density"). Units can be specified by passing in *center*
          as a tuple containing a coordinate and string unit name or by passing
          in a YTArray. If a list or unitless array is supplied, code units are
-         assumed.
+         assumed. For plot_2d, this keyword accepts a coordinate in two dimensions.
     width : tuple or a float.
          Width can have four different formats to support windows with variable
          x and y widths.  They are:
@@ -2116,6 +2116,19 @@
         axis = "z"
     elif ds.geometry == "cylindrical":
         axis = "theta"
+    # Part of the convenience of plot_2d is to eliminate the use of the
+    # superfluous coordinate, so we do that also with the center argument
+    if not isinstance(center, string_types) and obj_length(center) == 2:
+        c0_string = isinstance(center[0], string_types)
+        c1_string = isinstance(center[1], string_types)
+        if not c0_string and not c1_string:
+            if obj_length(center[0]) == 2 and c1_string:
+                center = ds.arr(center[0], center[1])
+            elif not isinstance(center, YTArray):
+                center = ds.arr(center, 'code_length')
+            center.convert_to_units("code_length")
+        center = ds.arr([center[0], center[1], 
+                         ds.domain_center[2]])
     return AxisAlignedSlicePlot(ds, axis, fields, center=center, width=width,
                                 axes_unit=axes_unit, origin=origin, 
                                 fontsize=fontsize,

diff -r 9ae26203a6acc54fba909daf83b767c7d027b1fa -r dd55684d3278380f0f1c1699d03bcf4050924fa7 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -542,10 +542,15 @@
     slc = SlicePlot(ds, "z", ["temperature"], width=(0.2,"unitary"),
                     center=[0.4, 0.3, 0.5])
     slc2 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
-                   center=[0.4, 0.3, 0.5])
+                   center=[0.4, 0.3])
     assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
     # Cylindrical
     ds = data_dir_load(WD)
-    slc = SlicePlot(ds, "theta", ["density"], width=(0.2, "unitary"))
-    slc2 = plot_2d(ds, "density", width=(0.2, "unitary"))
-    assert_array_equal(slc.frb['density'], slc2.frb['density'])
\ No newline at end of file
+    slc = SlicePlot(ds, "theta", ["density"], width=(1000.0, "km"),
+                    center=[2.0e9, 2.0e9, 3.141592655])
+    slc2 = plot_2d(ds, "density", width=(1000.0, "km"),
+                   center=[2.0e9, 2.0e9])
+    slc3 = plot_2d(ds, "density", width=(1000.0, "km"),
+                   center=ds.arr([2.0e4]*2, "km"))
+    assert_array_equal(slc.frb['density'], slc2.frb['density'])
+    assert_array_equal(slc.frb['density'], slc3.frb['density'])
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/3983bf576922/
Changeset:   3983bf576922
User:        jzuhone
Date:        2017-07-14 21:40:01+00:00
Summary:     API docs
Affected #:  1 file

diff -r dd55684d3278380f0f1c1699d03bcf4050924fa7 -r 3983bf576922fe87514d265aff743bd8349118ef doc/source/reference/api/api.rst
--- a/doc/source/reference/api/api.rst
+++ b/doc/source/reference/api/api.rst
@@ -18,6 +18,7 @@
    ~yt.visualization.plot_window.OffAxisProjectionPlot
    ~yt.visualization.plot_window.WindowPlotMPL
    ~yt.visualization.plot_window.PlotWindow
+   ~yt.visualization.plot_window.plot_2d
 
 ProfilePlot and PhasePlot
 ^^^^^^^^^^^^^^^^^^^^^^^^^


https://bitbucket.org/yt_analysis/yt/commits/fecf93d042d3/
Changeset:   fecf93d042d3
User:        jzuhone
Date:        2017-07-14 21:51:28+00:00
Summary:     Change error message
Affected #:  1 file

diff -r 3983bf576922fe87514d265aff743bd8349118ef -r fecf93d042d3209862fac34903371a50dce73069 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -2111,7 +2111,7 @@
          region covering the full domain
     """
     if ds.dimensionality != 2:
-        raise RuntimeError("Plot2DData only plots 2D datasets!")
+        raise RuntimeError("plot_2d only plots 2D datasets!")
     if ds.geometry == "cartesian" or ds.geometry == "polar":
         axis = "z"
     elif ds.geometry == "cylindrical":


https://bitbucket.org/yt_analysis/yt/commits/574f9a8eca7f/
Changeset:   574f9a8eca7f
User:        jzuhone
Date:        2017-07-14 21:59:45+00:00
Summary:     Test moving the center on a cartesian dataset instead
Affected #:  1 file

diff -r fecf93d042d3209862fac34903371a50dce73069 -r 574f9a8eca7f137ebefeb255a4c7b41094f80d58 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -543,14 +543,12 @@
                     center=[0.4, 0.3, 0.5])
     slc2 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
                    center=[0.4, 0.3])
+    slc3 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
+                   center=ds.arr([0.4, 0.3], "cm"))
     assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
+    assert_array_equal(slc.frb['temperature'], slc3.frb['temperature'])
     # Cylindrical
     ds = data_dir_load(WD)
-    slc = SlicePlot(ds, "theta", ["density"], width=(1000.0, "km"),
-                    center=[2.0e9, 2.0e9, 3.141592655])
-    slc2 = plot_2d(ds, "density", width=(1000.0, "km"),
-                   center=[2.0e9, 2.0e9])
-    slc3 = plot_2d(ds, "density", width=(1000.0, "km"),
-                   center=ds.arr([2.0e4]*2, "km"))
+    slc = SlicePlot(ds, "theta", ["density"], width=(30000.0, "km"))
+    slc2 = plot_2d(ds, "density", width=(30000.0, "km"))
     assert_array_equal(slc.frb['density'], slc2.frb['density'])
-    assert_array_equal(slc.frb['density'], slc3.frb['density'])
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/fecf778976df/
Changeset:   fecf778976df
User:        jzuhone
Date:        2017-07-14 22:01:43+00:00
Summary:     Documentation
Affected #:  1 file

diff -r 574f9a8eca7f137ebefeb255a4c7b41094f80d58 -r fecf778976dfc819d8c93a2d24f09a200cb0d61d doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -203,6 +203,30 @@
 See :class:`~yt.visualization.plot_window.AxisAlignedSlicePlot` for the
 full class description.
 
+.. _plot-2d:
+
+Plots of 2D Datasets
+~~~~~~~~~~~~~~~~~~~~
+
+If you have a two-dimensional cartesian, cylindrical, or polar dataset, 
+:func:`~yt.visualization.plot_window.plot_2d` is a way to make a plot
+within the dataset's plane without having to specify the axis, which
+in this case is redundant. Otherwise, ``plot_2d`` accepts the same
+arguments as ``SlicePlot``. The one other difference is that the
+``center`` keyword argument can be a two-dimensional coordinate instead
+of a three-dimensional one:
+
+.. python-script::
+
+    import yt
+    ds = yt.load("WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030")
+    p = yt.plot_2d(ds, "density", center=[1.0, 0.4])
+    p.set_log("density", False)
+    p.save()
+
+See :func:`~yt.visualization.plot_window.plot_2d` for the full description
+of the function and its keywords.
+
 .. _off-axis-slices:
 
 Off Axis Slices


https://bitbucket.org/yt_analysis/yt/commits/148ccb05b625/
Changeset:   148ccb05b625
User:        ngoldbaum
Date:        2017-07-15 17:55:30+00:00
Summary:     Merge pull request #1476 from jzuhone/2DPlot

plot_2d: plot 2d datasets
Affected #:  7 files

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 doc/source/reference/api/api.rst
--- a/doc/source/reference/api/api.rst
+++ b/doc/source/reference/api/api.rst
@@ -18,6 +18,7 @@
    ~yt.visualization.plot_window.OffAxisProjectionPlot
    ~yt.visualization.plot_window.WindowPlotMPL
    ~yt.visualization.plot_window.PlotWindow
+   ~yt.visualization.plot_window.plot_2d
 
 ProfilePlot and PhasePlot
 ^^^^^^^^^^^^^^^^^^^^^^^^^

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -203,6 +203,30 @@
 See :class:`~yt.visualization.plot_window.AxisAlignedSlicePlot` for the
 full class description.
 
+.. _plot-2d:
+
+Plots of 2D Datasets
+~~~~~~~~~~~~~~~~~~~~
+
+If you have a two-dimensional cartesian, cylindrical, or polar dataset, 
+:func:`~yt.visualization.plot_window.plot_2d` is a way to make a plot
+within the dataset's plane without having to specify the axis, which
+in this case is redundant. Otherwise, ``plot_2d`` accepts the same
+arguments as ``SlicePlot``. The one other difference is that the
+``center`` keyword argument can be a two-dimensional coordinate instead
+of a three-dimensional one:
+
+.. python-script::
+
+    import yt
+    ds = yt.load("WindTunnel/windtunnel_4lev_hdf5_plt_cnt_0030")
+    p = yt.plot_2d(ds, "density", center=[1.0, 0.4])
+    p.set_log("density", False)
+    p.save()
+
+See :func:`~yt.visualization.plot_window.plot_2d` for the full description
+of the function and its keywords.
+
 .. _off-axis-slices:
 
 Off Axis Slices

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -109,7 +109,7 @@
     ProfilePlot, PhasePlot, ParticlePhasePlot, \
     ParticleProjectionPlot, ParticleImageBuffer, ParticlePlot, \
     FITSImageData, FITSSlice, FITSProjection, FITSOffAxisSlice, \
-    FITSOffAxisProjection
+    FITSOffAxisProjection, plot_2d
 
 from yt.visualization.volume_rendering.api import \
     volume_render, create_scene, ColorTransferFunction, TransferFunction, \

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -735,7 +735,13 @@
     handler.domain_left_edge = domain_left_edge
     handler.domain_right_edge = domain_right_edge
     handler.refine_by = 2
-    handler.dimensionality = 3
+    if np.all(domain_dimensions[1:] == 1):
+        dimensionality = 1
+    elif domain_dimensions[2] == 1:
+        dimensionality = 2
+    else:
+        dimensionality = 3
+    handler.dimensionality = dimensionality
     handler.domain_dimensions = domain_dimensions
     handler.simulation_time = sim_time
     handler.cosmology_simulation = 0
@@ -925,7 +931,13 @@
     handler.domain_left_edge = domain_left_edge
     handler.domain_right_edge = domain_right_edge
     handler.refine_by = refine_by
-    handler.dimensionality = 3
+    if np.all(domain_dimensions[1:] == 1):
+        dimensionality = 1
+    elif domain_dimensions[2] == 1:
+        dimensionality = 2
+    else:
+        dimensionality = 3
+    handler.dimensionality = dimensionality
     handler.domain_dimensions = domain_dimensions
     handler.simulation_time = sim_time
     handler.cosmology_simulation = 0

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -51,7 +51,8 @@
     AxisAlignedSlicePlot, \
     OffAxisSlicePlot, \
     ProjectionPlot, \
-    OffAxisProjectionPlot
+    OffAxisProjectionPlot, \
+    plot_2d
 
 from .line_plot import \
     LinePlot

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -43,7 +43,7 @@
     YTSpatialPlotDataset
 from yt.funcs import \
     mylog, iterable, ensure_list, \
-    fix_axis, fix_unitary
+    fix_axis, fix_unitary, obj_length
 from yt.units.unit_object import \
     Unit
 from yt.units.unit_registry import \
@@ -399,7 +399,7 @@
             is typically represented by a '-' 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
+            'left', 'right', or 'center'. Finally, 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'] place the
@@ -1172,7 +1172,7 @@
          is typically represented by a '-' 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
+         'left', 'right', or 'center'. Finally, 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'] place the
@@ -1200,7 +1200,7 @@
          ((yloc, '{unit}'), (xloc, '{unit}'), '{space}')    ((0.5, 'm'), (0.4, 'm'), 'window')
          (xloc, yloc, '{space}')                            (0.23, 0.5, 'domain')
          ===============================================    ==================================
-    axes_unit : A string
+    axes_unit : 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
@@ -1314,7 +1314,7 @@
          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
+    axes_unit : 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
@@ -1324,7 +1324,7 @@
          is typically represented by a '-' 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
+         'left', 'right', or 'center'. Finally, 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'] place the
@@ -1500,7 +1500,7 @@
          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
+    axes_unit : 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
@@ -1644,7 +1644,7 @@
          The name of the weighting field.  Set to None for no weight.
     max_level: int
          The maximum level to project to.
-    axes_unit : A string
+    axes_unit : 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
@@ -1830,7 +1830,7 @@
          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
+    axes_unit : 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
@@ -1940,3 +1940,124 @@
             del kwargs['north_vector']
 
         return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs)
+
+def plot_2d(ds, fields, center='c', width=None, axes_unit=None,
+            origin='center-window', fontsize=18, field_parameters=None, 
+            window_size=8.0, aspect=None, data_source=None):
+    r"""Creates a plot of a 2D dataset
+
+    Given a ds object and a field name string, this will return a
+    PWViewerMPL object containing the plot.
+
+    The plot can be updated using one of the many helper functions
+    defined in PlotWindow.
+
+    Parameters
+    ----------
+    ds : `Dataset`
+         This is the dataset object corresponding to the
+         simulation output to be plotted.
+    fields : string
+         The name of the field(s) to be plotted.
+    center : A sequence of floats, a string, or a tuple.
+         The coordinate of the center of the image. 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 located at the maximum of the
+         ('gas', 'density') field. Centering on the max or min of a specific
+         field is supported by providing a tuple such as ("min","temperature") or
+         ("max","dark_matter_density"). Units can be specified by passing in *center*
+         as a tuple containing a coordinate and string unit name or by passing
+         in a YTArray. If a list or unitless array is supplied, code units are
+         assumed. For plot_2d, this keyword accepts a coordinate in two dimensions.
+    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.
+    origin : string or length 1, 2, or 3 sequence.
+         The location of the origin of the plot coordinate system. This
+         is typically represented by a '-' 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, 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'] place the
+         origin in the upper right hand corner of domain space. If x or y
+         are not given, a value is inferred. 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. In the event
+         that none of these options place the origin in a desired location,
+         a sequence of tuples and a string specifying the
+         coordinate space can be given. If plain numeric types are input,
+         units of `code_length` are assumed. 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')
+         ((yloc, '{unit}'), (xloc, '{unit}'), '{space}')    ((0.5, 'm'), (0.4, 'm'), 'window')
+         (xloc, yloc, '{space}')                            (0.23, 0.5, 'domain')
+         ===============================================    ==================================
+    axes_unit : 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.
+    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.
+    data_source: YTSelectionContainer object
+         Object to be used for data selection. Defaults to ds.all_data(), a 
+         region covering the full domain
+    """
+    if ds.dimensionality != 2:
+        raise RuntimeError("plot_2d only plots 2D datasets!")
+    if ds.geometry == "cartesian" or ds.geometry == "polar":
+        axis = "z"
+    elif ds.geometry == "cylindrical":
+        axis = "theta"
+    # Part of the convenience of plot_2d is to eliminate the use of the
+    # superfluous coordinate, so we do that also with the center argument
+    if not isinstance(center, string_types) and obj_length(center) == 2:
+        c0_string = isinstance(center[0], string_types)
+        c1_string = isinstance(center[1], string_types)
+        if not c0_string and not c1_string:
+            if obj_length(center[0]) == 2 and c1_string:
+                center = ds.arr(center[0], center[1])
+            elif not isinstance(center, YTArray):
+                center = ds.arr(center, 'code_length')
+            center.convert_to_units("code_length")
+        center = ds.arr([center[0], center[1], 
+                         ds.domain_center[2]])
+    return AxisAlignedSlicePlot(ds, axis, fields, center=center, width=width,
+                                axes_unit=axes_unit, origin=origin, 
+                                fontsize=fontsize,
+                                field_parameters=field_parameters, 
+                                window_size=window_size, aspect=aspect,
+                                data_source=data_source)
\ No newline at end of file

diff -r 345669b822c1814554b0cb6ce2131a1b1105001e -r 148ccb05b62511e0e898a508b2e6ed84984fd151 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -30,7 +30,8 @@
 from yt.utilities.exceptions import \
     YTInvalidFieldType
 from yt.visualization.api import \
-    SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+    SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot, \
+    plot_2d
 from yt.units.yt_array import YTArray, YTQuantity
 from yt.units import kboltz
 from yt.frontends.stream.api import load_uniform_grid
@@ -532,3 +533,22 @@
     slc.set_unit('temperature', 'keV', equivalency='thermal')
     assert str(slc.frb['gas', 'temperature'].units) == 'keV'
 
+WD = "WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5"
+
+ at requires_ds(WD)
+def test_plot_2d():
+    # Cartesian
+    ds = fake_random_ds((32,32,1), fields=('temperature',), units=('K',))
+    slc = SlicePlot(ds, "z", ["temperature"], width=(0.2,"unitary"),
+                    center=[0.4, 0.3, 0.5])
+    slc2 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
+                   center=[0.4, 0.3])
+    slc3 = plot_2d(ds, "temperature", width=(0.2,"unitary"),
+                   center=ds.arr([0.4, 0.3], "cm"))
+    assert_array_equal(slc.frb['temperature'], slc2.frb['temperature'])
+    assert_array_equal(slc.frb['temperature'], slc3.frb['temperature'])
+    # Cylindrical
+    ds = data_dir_load(WD)
+    slc = SlicePlot(ds, "theta", ["density"], width=(30000.0, "km"))
+    slc2 = plot_2d(ds, "density", width=(30000.0, "km"))
+    assert_array_equal(slc.frb['density'], slc2.frb['density'])

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