[yt-svn] commit/yt: chummels: Merged in atmyers/yt (pull request #1958)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Feb 16 19:34:23 PST 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/af128f1c867d/
Changeset: af128f1c867d
Branch: yt
User: chummels
Date: 2016-02-17 03:34:15+00:00
Summary: Merged in atmyers/yt (pull request #1958)
Making off axis projections have the same orientation vectors as before.
Affected #: 3 files
diff -r ee29ca6d81c95d55073d4cf9db89e9486c40156d -r af128f1c867d7f72132699e5d243a37583c36570 yt/visualization/volume_rendering/off_axis_projection.py
--- a/yt/visualization/volume_rendering/off_axis_projection.py
+++ b/yt/visualization/volume_rendering/off_axis_projection.py
@@ -19,7 +19,7 @@
from .utils import data_source_or_all
from yt.funcs import mylog, iterable
from yt.utilities.lib.grid_traversal import \
- PartitionedGrid
+ PartitionedGrid
from yt.data_objects.api import ImageArray
import numpy as np
@@ -151,8 +151,6 @@
vol.set_fields(fields)
camera = Camera(data_source)
camera.set_width(width)
- camera.switch_orientation(normal_vector=normal_vector,
- north_vector=north_vector)
if not iterable(resolution):
resolution = [resolution]*2
camera.resolution = resolution
@@ -160,6 +158,20 @@
width = data_source.ds.arr([width]*3)
camera.position = center - width[2]*camera.normal_vector
camera.focus = center
+
+ # If north_vector is None, we set the default here.
+ # This is chosen so that if normal_vector is one of the
+ # cartesian coordinate axes, the projection will match
+ # the corresponding on-axis projection.
+ if north_vector is None:
+ vecs = np.identity(3)
+ t = np.cross(vecs, normal_vector).sum(axis=1)
+ ax = t.argmax()
+ east_vector = np.cross(vecs[ax, :], normal_vector).ravel()
+ north_vector = np.cross(normal_vector, east_vector).ravel()
+ camera.switch_orientation(normal_vector,
+ north_vector)
+
sc.camera = camera
sc.add_source(vol)
diff -r ee29ca6d81c95d55073d4cf9db89e9486c40156d -r af128f1c867d7f72132699e5d243a37583c36570 yt/visualization/volume_rendering/tests/test_vr_orientation.py
--- a/yt/visualization/volume_rendering/tests/test_vr_orientation.py
+++ b/yt/visualization/volume_rendering/tests/test_vr_orientation.py
@@ -16,12 +16,14 @@
from yt import load_uniform_grid
from yt.utilities.answer_testing.framework import \
requires_answer_testing, \
- VRImageComparisonTest
+ VRImageComparisonTest, \
+ GenericImageTest
from yt.visualization.volume_rendering.api import \
Scene, \
Camera, \
VolumeSource, \
- ColorTransferFunction
+ ColorTransferFunction, \
+ off_axis_projection
def setup_ds():
@@ -149,3 +151,17 @@
sc.camera = cam
yield VRImageComparisonTest(
sc, ds, 'roll_%s_%04d' % (lens_type, frame), decimals)
+
+ orientations = [ [1.0, 0.0, 0.0],
+ [0.0, 1.0, 0.0],
+ [0.0, 0.0, 1.0],
+ [0.5, 0.4, 0.7],
+ [-0.3, -0.1, 0.8] ]
+ center = [0.5, 0.5, 0.5]
+ width = [0.04, 0.04, 0.4]
+ for orientation in orientations:
+ image = off_axis_projection(ds, center, orientation, width,
+ 512, "density", no_ghost=False)
+ def offaxis_image_func(filename_prefix):
+ return image.write_image(filename_prefix)
+ yield GenericImageTest(ds, offaxis_image_func, decimals)
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