[yt-svn] commit/yt: ngoldbaum: Merged in a_gilbert/yt (pull request #2318)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Aug 8 16:01:30 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/b1165fbb7bd2/
Changeset: b1165fbb7bd2
Branch: yt
User: ngoldbaum
Date: 2016-08-08 23:01:03+00:00
Summary: Merged in a_gilbert/yt (pull request #2318)
Enabling right-handed coordinate systems to be toggled: solving Issue #1231
Affected #: 4 files
diff -r 2ecca0373b9b24eb84bd4dbd1d5c874ad3a6d0bc -r b1165fbb7bd24dcdbf61093a685f540567a7de87 doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -537,6 +537,27 @@
slc.set_center((0.5, 0.503))
slc.save()
+Flipping the plot view axes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+By default, all :class:`~yt.visualization.plot_window.PlotWindow` objects plot
+with the assumption that the eastern direction on the plot forms a right handed
+coordinate system with the ``normal`` and ``north_vector`` for the system, whether
+explicitly or implicitly defined. This setting can be toggled or explicitly defined
+by the user at initialization:
+
+.. python-script::
+
+ import yt
+ ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ #slicing with non right-handed coordinates
+ slc = yt.SlicePlot(ds, 'x', 'velocity_x', right_handed=False)
+ slc.annotate_title('Not Right Handed')
+ slc.save("NotRightHanded.png")
+
+ #switching to right-handed coordinates
+ slc.toggle_right_handed()
+ slc.annotate_title('Right Handed')
+ slc.save("Standard.png")
.. _hiding-colorbar-and-axes:
@@ -704,6 +725,7 @@
slc.set_cbar_minorticks('all', 'off')
slc.save()
+
.. _matplotlib-customization:
Further customization via matplotlib
diff -r 2ecca0373b9b24eb84bd4dbd1d5c874ad3a6d0bc -r b1165fbb7bd24dcdbf61093a685f540567a7de87 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -39,7 +39,7 @@
local_owls_000:
- yt/frontends/owls/tests/test_outputs.py
- local_pw_003:
+ local_pw_006:
- yt/visualization/tests/test_plotwindow.py:test_attributes
- yt/visualization/tests/test_plotwindow.py:test_attributes_wt
- yt/visualization/tests/test_profile_plots.py:test_phase_plot_attributes
diff -r 2ecca0373b9b24eb84bd4dbd1d5c874ad3a6d0bc -r b1165fbb7bd24dcdbf61093a685f540567a7de87 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -13,7 +13,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-
import numpy as np
import matplotlib
import types
@@ -173,11 +172,15 @@
window_size : float
The size of the window on the longest axis (in units of inches),
including the margins but not the colorbar.
+ right_handed : boolean
+ Whether the implicit east vector for the image generated is set to make a right
+ handed coordinate system with a north vector and the normal vector, the
+ direction of the 'window' into the data.
"""
def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True,
- periodic=True, origin='center-window', oblique=False,
- window_size=8.0, fields=None, fontsize=18, aspect=None,
+ periodic=True, origin='center-window', oblique=False, right_handed=True,
+ window_size=8.0, fields=None, fontsize=18, aspect=None,
setup=False):
if not hasattr(self, "ds"):
self.ds = data_source.ds
@@ -187,8 +190,10 @@
self.center = None
self._periodic = periodic
self.oblique = oblique
+ self._right_handed = right_handed
self.buff_size = buff_size
self.antialias = antialias
+
self.aspect = aspect
skip = list(FixedResolutionBuffer._exclude_fields) + data_source._key_fields
if fields is None:
@@ -620,6 +625,11 @@
self._axes_unit_names = unit_name
return self
+ @invalidate_plot
+ def toggle_right_handed(self):
+ self._right_handed = not self._right_handed
+
+
class PWViewerMPL(PlotWindow):
"""Viewer using matplotlib as a backend via the WindowPlotMPL.
@@ -797,7 +807,6 @@
ia = ImageArray(ia)
else:
ia = image
-
self.plots[f] = WindowPlotMPL(
ia, self._field_transform[f].name,
self._field_transform[f].func,
@@ -805,6 +814,10 @@
self.figure_size, font_size,
self.aspect, fig, axes, cax)
+ if not self._right_handed:
+ ax = self.plots[f].axes
+ ax.invert_xaxis()
+
axes_unit_labels = ['', '']
comoving = False
hinv = False
@@ -1214,6 +1227,10 @@
('{yloc}', '{space}') ('lower', 'window')
('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
================================== ============================
+ 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
@@ -1238,7 +1255,7 @@
_frb_generator = FixedResolutionBuffer
def __init__(self, ds, axis, fields, center='c', width=None, axes_unit=None,
- origin='center-window', fontsize=18, field_parameters=None,
+ origin='center-window', right_handed=True, fontsize=18, field_parameters=None,
window_size=8.0, aspect=None, data_source=None):
# this will handle time series data and controllers
ts = self._initialize_dataset(ds)
@@ -1263,7 +1280,7 @@
validate_mesh_fields(slc, fields)
PWViewerMPL.__init__(self, slc, bounds, origin=origin,
fontsize=fontsize, fields=fields,
- window_size=window_size, aspect=aspect)
+ window_size=window_size, aspect=aspect, right_handed=right_handed)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
self.set_axes_unit(axes_unit)
@@ -1350,7 +1367,10 @@
('{yloc}', '{space}') ('lower', 'window')
('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
================================== ============================
-
+ right_handed : boolean
+ Whether the implicit east vector for the image generated is set to make a right
+ handed coordinate system with the direction of the
+ 'window' into the data.
data_source : YTSelectionContainer Object
Object to be used for data selection. Defaults to a region covering
the entire simulation.
@@ -1403,8 +1423,8 @@
def __init__(self, ds, axis, fields, center='c', width=None, axes_unit=None,
weight_field=None, max_level=None, origin='center-window',
- fontsize=18, field_parameters=None, data_source=None,
- method = "integrate", proj_style = None, window_size=8.0,
+ right_handed=True, fontsize=18, field_parameters=None, data_source=None,
+ method = "integrate", proj_style = None, window_size=8.0,
aspect=None):
ts = self._initialize_dataset(ds)
self.ts = ts
@@ -1439,7 +1459,7 @@
field_parameters=field_parameters, method=method,
max_level=max_level)
PWViewerMPL.__init__(self, proj, bounds, fields=fields, origin=origin,
- fontsize=fontsize, window_size=window_size,
+ right_handed=right_handed, fontsize=fontsize, window_size=window_size,
aspect=aspect)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
@@ -1503,6 +1523,10 @@
A vector defining the 'up' direction in the plot. This
option sets the orientation of the slicing plane. If not
set, an arbitrary grid-aligned north-vector is chosen.
+ right_handed : boolean
+ Whether the implicit east vector for the image generated is set to make a right
+ handed coordinate system with the north vector and the normal, 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
@@ -1517,7 +1541,7 @@
_frb_generator = ObliqueFixedResolutionBuffer
def __init__(self, ds, normal, fields, center='c', width=None,
- axes_unit=None, north_vector=None, fontsize=18,
+ axes_unit=None, north_vector=None, right_handed=True, fontsize=18,
field_parameters=None, data_source=None):
(bounds, center_rot) = get_oblique_window_parameters(normal,center,width,ds)
if field_parameters is None:
@@ -1537,7 +1561,7 @@
# aren't well-defined for off-axis data objects
PWViewerMPL.__init__(self, cutting, bounds, fields=fields,
origin='center-window',periodic=False,
- oblique=True, fontsize=fontsize)
+ right_handed=right_handed, oblique=True, fontsize=fontsize)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
self.set_axes_unit(axes_unit)
@@ -1639,6 +1663,10 @@
A vector defining the 'up' direction in the plot. This
option sets the orientation of the slicing plane. If not
set, an arbitrary grid-aligned north-vector is chosen.
+ right_handed : boolean
+ Whether the implicit east vector for the image generated is set to make a right
+ handed coordinate system with the north vector and the normal, the direction of the
+ 'window' into the data.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
method : string
@@ -1661,8 +1689,9 @@
def __init__(self, ds, normal, fields, center='c', width=None,
depth=(1, '1'), axes_unit=None, weight_field=None,
- max_level=None, north_vector=None, volume=None, no_ghost=False,
- le=None, re=None, interpolated=False, fontsize=18, method="integrate"):
+ max_level=None, north_vector=None, right_handed=True,
+ volume=None, no_ghost=False, le=None, re=None,
+ interpolated=False, fontsize=18, method="integrate"):
(bounds, center_rot) = \
get_oblique_window_parameters(normal,center,width,ds,depth=depth)
fields = ensure_list(fields)[:]
@@ -1688,7 +1717,8 @@
# aren't well-defined for off-axis data objects
PWViewerMPL.__init__(
self, OffAxisProj, bounds, fields=fields, origin='center-window',
- periodic=False, oblique=True, fontsize=fontsize)
+ periodic=False, oblique=True, right_handed=right_handed,
+ fontsize=fontsize)
if axes_unit is None:
axes_unit = get_axes_unit(width, ds)
self.set_axes_unit(axes_unit)
diff -r 2ecca0373b9b24eb84bd4dbd1d5c874ad3a6d0bc -r b1165fbb7bd24dcdbf61093a685f540567a7de87 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -91,7 +91,8 @@
"set_window_size": [((7.0, ), {})],
"set_zlim": [(('density', 1e-25, 1e-23), {}),
(('density', 1e-25, None), {'dynamic_range': 4})],
- "zoom": [((10, ), {})]}
+ "zoom": [((10, ), {})],
+ "toggle_right_handed": [((),{})]}
CENTER_SPECS = (
@@ -442,3 +443,4 @@
for field_name_list in field_names:
assert_raises(
YTInvalidFieldType, object, ds, normal, field_name_list)
+
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