[yt-svn] commit/yt: ngoldbaum: Merged in atmyers/yt (pull request #2214)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Jun 15 13:58:31 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/5bb5a38e4eb1/
Changeset: 5bb5a38e4eb1
Branch: yt
User: ngoldbaum
Date: 2016-06-15 20:58:20+00:00
Summary: Merged in atmyers/yt (pull request #2214)
[BUGFIX] Fixes for off-axis slice plots. Closes #1214.
Affected #: 4 files
diff -r 9bcee915d549eb251157fbe2b82c5b5e8fb783b9 -r 5bb5a38e4eb16d60edafa5c601ab956d578cb9ee yt/utilities/lib/pixelization_routines.pyx
--- a/yt/utilities/lib/pixelization_routines.pyx
+++ b/yt/utilities/lib/pixelization_routines.pyx
@@ -275,14 +275,14 @@
cx = inv_mat[0,0]*cxpx + inv_mat[0,1]*cypx + center[0]
cy = inv_mat[1,0]*cxpx + inv_mat[1,1]*cypx + center[1]
cz = inv_mat[2,0]*cxpx + inv_mat[2,1]*cypx + center[2]
- if fabs(xsp - cx) * 0.95 > dxsp or \
- fabs(ysp - cy) * 0.95 > dysp or \
- fabs(zsp - cz) * 0.95 > dzsp:
+ if fabs(xsp - cx) * 0.99 > dxsp or \
+ fabs(ysp - cy) * 0.99 > dysp or \
+ fabs(zsp - cz) * 0.99 > dzsp:
continue
mask[i, j] += 1
my_array[i, j] += dsp
my_array /= mask
- return my_array
+ return my_array.T
@cython.cdivision(True)
diff -r 9bcee915d549eb251157fbe2b82c5b5e8fb783b9 -r 5bb5a38e4eb16d60edafa5c601ab956d578cb9ee yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -273,8 +273,7 @@
True, the velocity fields will be scaled by their local
(in-plane) length, allowing morphological features to be more
clearly seen for fields with substantial variation in field
- strength (normalize is not implemented and thus ignored for
- Cutting Planes).
+ strength.
"""
_type_name = "velocity"
_supported_geometries = ("cartesian", "spectral_cube")
@@ -290,7 +289,9 @@
if plot._type_name == "CuttingPlane":
qcb = CuttingQuiverCallback("cutting_plane_velocity_x",
"cutting_plane_velocity_y",
- self.factor)
+ self.factor, scale=self.scale,
+ normalize=self.normalize,
+ scale_units=self.scale_units)
else:
ax = plot.data.axis
(xi, yi) = (plot.data.ds.coordinates.x_axis[ax],
@@ -336,7 +337,9 @@
if plot._type_name == "CuttingPlane":
qcb = CuttingQuiverCallback("cutting_plane_magnetic_field_x",
"cutting_plane_magnetic_field_y",
- self.factor)
+ self.factor, scale=self.scale,
+ scale_units=self.scale_units,
+ normalize=self.normalize)
else:
xax = plot.data.ds.coordinates.x_axis[plot.data.axis]
yax = plot.data.ds.coordinates.y_axis[plot.data.axis]
@@ -855,11 +858,16 @@
"""
_type_name = "cquiver"
_supported_geometries = ("cartesian", "spectral_cube")
- def __init__(self, field_x, field_y, factor):
+
+ def __init__(self, field_x, field_y, factor=16, scale=None,
+ scale_units=None, normalize=None):
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
self.factor = factor
+ self.scale = scale
+ self.scale_units = scale_units
+ self.normalize = normalize
def __call__(self, plot):
x0, x1 = plot.xlim
@@ -870,6 +878,7 @@
nx = plot.image._A.shape[0] / self.factor
ny = plot.image._A.shape[1] / self.factor
indices = np.argsort(plot.data['dx'])[::-1]
+
pixX = pixelize_off_axis_cartesian(
plot.data['x'], plot.data['y'], plot.data['z'],
plot.data['px'], plot.data['py'],
@@ -877,7 +886,7 @@
plot.data.center, plot.data._inv_mat, indices,
plot.data[self.field_x],
int(nx), int(ny),
- (x0, x1, y0, y1),).transpose()
+ (x0, x1, y0, y1)).transpose()
pixY = pixelize_off_axis_cartesian(
plot.data['x'], plot.data['y'], plot.data['z'],
plot.data['px'], plot.data['py'],
@@ -885,10 +894,16 @@
plot.data.center, plot.data._inv_mat, indices,
plot.data[self.field_y],
int(nx), int(ny),
- (x0, x1, y0, y1),).transpose()
+ (x0, x1, y0, y1)).transpose()
X,Y = np.meshgrid(np.linspace(xx0,xx1,nx,endpoint=True),
np.linspace(yy0,yy1,ny,endpoint=True))
- plot._axes.quiver(X,Y, pixX, pixY)
+
+ if self.normalize:
+ nn = np.sqrt(pixX**2 + pixY**2)
+ pixX /= nn
+ pixY /= nn
+
+ plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
plot._axes.hold(False)
diff -r 9bcee915d549eb251157fbe2b82c5b5e8fb783b9 -r 5bb5a38e4eb16d60edafa5c601ab956d578cb9ee yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -103,7 +103,7 @@
mat = np.transpose(np.column_stack((perp1,perp2,normal)))
center = np.dot(mat,center)
- w = tuple(el.in_units('unitary') for el in width)
+ w = tuple(el.in_units('code_length') for el in width)
bounds = tuple(((2*(i % 2))-1)*w[i//2]/2 for i in range(len(w)*2))
return (bounds, center)
diff -r 9bcee915d549eb251157fbe2b82c5b5e8fb783b9 -r 5bb5a38e4eb16d60edafa5c601ab956d578cb9ee yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -13,6 +13,7 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import itertools
+import numpy as np
import os
import tempfile
import shutil
@@ -27,6 +28,7 @@
from yt.visualization.api import \
SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
from yt.units.yt_array import YTArray, YTQuantity
+from yt.frontends.stream.api import load_uniform_grid
from collections import OrderedDict
def setup():
@@ -400,3 +402,20 @@
[assert_array_almost_equal(py, y, 14) for py, y in zip(plot.ylim, ylim)]
[assert_array_almost_equal(pw, w, 14) for pw, w in zip(plot.width, pwidth)]
assert_true(aun == plot._axes_unit_names)
+
+def test_on_off_compare():
+ # fake density field that varies in the x-direction only
+ den = np.arange(32**3) / 32**2 + 1
+ den = den.reshape(32, 32, 32)
+ den = np.array(den, dtype=np.float64)
+ data = dict(density = (den, "g/cm**3"))
+ bbox = np.array([[-1.5, 1.5], [-1.5, 1.5], [-1.5, 1.5]])
+ ds = load_uniform_grid(data, den.shape, length_unit="Mpc", bbox=bbox, nprocs=64)
+
+ sl_on = SlicePlot(ds, "z", ["density"])
+
+ L = [0, 0, 1]
+ north_vector = [0, 1, 0]
+ sl_off = OffAxisSlicePlot(ds, L, 'density', center=[0,0,0], north_vector=north_vector)
+
+ assert_array_almost_equal(sl_on.frb['density'], sl_off.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