[yt-svn] commit/yt: atmyers: Merged in jzuhone/yt (pull request #1957)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jan 27 09:48:40 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/440902ffb795/
Changeset:   440902ffb795
Branch:      yt
User:        atmyers
Date:        2016-01-27 17:48:31+00:00
Summary:     Merged in jzuhone/yt (pull request #1957)

Changes to off_axis_projection
Affected #:  11 files

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c doc/source/cookbook/offaxis_projection.py
--- a/doc/source/cookbook/offaxis_projection.py
+++ b/doc/source/cookbook/offaxis_projection.py
@@ -26,7 +26,7 @@
 # Create the off axis projection.
 # Setting no_ghost to False speeds up the process, but makes a
 # slighly lower quality image.
-image, sc= yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
+image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
 
 # Write out the final image and give it a name
 # relating to what our dataset is called.

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c doc/source/cookbook/offaxis_projection_colorbar.py
--- a/doc/source/cookbook/offaxis_projection_colorbar.py
+++ b/doc/source/cookbook/offaxis_projection_colorbar.py
@@ -32,7 +32,7 @@
 # Also note that we set the field which we want to project as "density", but
 # really we could use any arbitrary field like "temperature", "metallicity"
 # or whatever.
-image, sc = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
+image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
 
 # Image is now an NxN array representing the intensities of the various pixels.
 # And now, we call our direct image saver.  We save the log of the result.

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c doc/source/visualizing/plots.rst
--- a/doc/source/visualizing/plots.rst
+++ b/doc/source/visualizing/plots.rst
@@ -328,7 +328,7 @@
    W = [0.02, 0.02, 0.02]
    c = [0.5, 0.5, 0.5]
    N = 512
-   image, sc = yt.off_axis_projection(ds, c, L, W, N, "density")
+   image = yt.off_axis_projection(ds, c, L, W, N, "density")
    yt.write_image(np.log10(image), "%s_offaxis_projection.png" % ds)
 
 Here, ``W`` is the width of the projection in the x, y, *and* z

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -54,7 +54,7 @@
                  width=(1.0,"unitary"), dims=100, thermal_broad=False,
                  atomic_weight=56., depth=(1.0,"unitary"), depth_res=256,
                  method="integrate", weight_field=None, no_shifting=False,
-                 north_vector=None, no_ghost=True):
+                 north_vector=None, no_ghost=True, data_source=None):
         r""" Initialize a PPVCube object.
 
         Parameters
@@ -121,6 +121,8 @@
             accuracy/smoothness in resulting image.  The effects are
             less notable when the transfer function is smooth and
             broad. Default: True
+        data_source : yt.data_objects.data_containers.YTSelectionContainer, optional
+            If specified, this will be the data source used for selecting regions to project.
 
         Examples
         --------
@@ -186,10 +188,14 @@
             self.current_v = self.vmid_cgs[i]
             if isinstance(normal, string_types):
                 prj = ds.proj("intensity", ds.coordinates.axis_id[normal], method=method,
-                              weight_field=weight_field)
+                              weight_field=weight_field, data_source=data_source)
                 buf = prj.to_frb(width, self.nx, center=self.center)["intensity"]
             else:
-                buf, sc = off_axis_projection(ds, self.center, normal, width,
+                if data_source is None:
+                    source = ds
+                else:
+                    source = data_source
+                buf = off_axis_projection(source, self.center, normal, width,
                                           (self.nx, self.ny), "intensity",
                                           north_vector=north_vector, no_ghost=no_ghost,
                                           method=method, weight=weight_field)

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -19,7 +19,7 @@
 from yt.units import dimensions
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     parallel_root_only
-from yt.visualization.volume_rendering.old_camera import off_axis_projection
+from yt.visualization.volume_rendering.off_axis_projection import off_axis_projection
 import re
 
 pyfits = _astropy.pyfits
@@ -732,26 +732,28 @@
         Deprecated, this is still in the function signature for API
         compatibility
     north_vector : a sequence of floats
-         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.
+        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.
     method : string
-         The method of projection.  Valid methods are:
+        The method of projection.  Valid methods are:
 
-         "integrate" with no weight_field specified : integrate the requested
-         field along the line of sight.
+        "integrate" with no weight_field specified : integrate the requested
+        field along the line of sight.
 
-         "integrate" with a weight_field specified : weight the requested
-         field by the weighting field and integrate along the line of sight.
+        "integrate" with a weight_field specified : weight the requested
+        field by the weighting field and integrate along the line of sight.
 
-         "sum" : This method is the same as integrate, except that it does not
-         multiply by a path length when performing the integration, and is
-         just a straight summation of the field along the given axis. WARNING:
-         This should only be used for uniform resolution grid datasets, as other
-         datasets may result in unphysical images.
+        "sum" : This method is the same as integrate, except that it does not
+        multiply by a path length when performing the integration, and is
+        just a straight summation of the field along the given axis. WARNING:
+        This should only be used for uniform resolution grid datasets, as other
+        datasets may result in unphysical images.
+    data_source : yt.data_objects.data_containers.YTSelectionContainer, optional
+        If specified, this will be the data source used for selecting regions to project.
     """
     def __init__(self, ds, normal, fields, center='c', width=(1.0, 'unitary'),
-                 weight_field=None, image_res=512, depth_res=256,
+                 weight_field=None, image_res=512, depth_res=256, data_source=None,
                  north_vector=None, depth=(1.0,"unitary"), no_ghost=False, method='integrate'):
         fields = ensure_list(fields)
         center, dcenter = ds.coordinates.sanitize_center(center, 4)
@@ -761,8 +763,12 @@
         if not iterable(image_res):
             image_res = (image_res, image_res)
         res = (image_res[0], image_res[1])
+        if data_source is None:
+            source = ds
+        else:
+            source = data_source
         for field in fields:
-            buf[field] = off_axis_projection(ds, center, normal, wd, res, field,
+            buf[field] = off_axis_projection(source, center, normal, wd, res, field,
                                              no_ghost=no_ghost, north_vector=north_vector,
                                              method=method, weight=weight_field).swapaxes(0, 1)
         center = ds.arr([0.0] * 2, 'code_length')

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/utilities/tests/test_fits_image.py
--- a/yt/utilities/tests/test_fits_image.py
+++ b/yt/utilities/tests/test_fits_image.py
@@ -25,7 +25,7 @@
     FITSSlice, FITSOffAxisSlice, \
     FITSOffAxisProjection, \
     assert_same_wcs
-from yt.visualization.volume_rendering.old_camera import \
+from yt.visualization.volume_rendering.off_axis_projection import \
     off_axis_projection
 
 

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -569,7 +569,7 @@
         width = self.ds.arr((self.bounds[1] - self.bounds[0],
                              self.bounds[3] - self.bounds[2],
                              self.bounds[5] - self.bounds[4]))
-        buff, sc = off_axis_projection(dd.ds, dd.center, dd.normal_vector,
+        buff = off_axis_projection(dd.ds, dd.center, dd.normal_vector,
                                    width, dd.resolution, item,
                                    weight=dd.weight_field, volume=dd.volume,
                                    no_ghost=dd.no_ghost, interpolated=dd.interpolated,

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -372,7 +372,7 @@
     Examples
     --------
 
-    >>> image, sc = off_axis_projection(ds, c, L, W, N, "Density", no_ghost=False)
+    >>> image = off_axis_projection(ds, c, L, W, N, "Density", no_ghost=False)
     >>> write_projection(image, 'test.png', 
                          colorbar_label="Column Density (cm$^{-2}$)", 
                          title="Offaxis Projection", limits=(1e-5,1e-3), 

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c yt/visualization/tests/test_offaxisprojection.py
--- a/yt/visualization/tests/test_offaxisprojection.py
+++ b/yt/visualization/tests/test_offaxisprojection.py
@@ -72,7 +72,7 @@
     # make sure they are able to be projected, then remove and try next
     # iteration
     for oap_kwargs in oap_kwargs_list:
-        image, sc = off_axis_projection(*oap_args, **oap_kwargs)
+        image = off_axis_projection(*oap_args, **oap_kwargs)
         for wp_kwargs in wp_kwargs_list:
             write_projection(image, fn % oap_kwargs, **wp_kwargs)
             yield assert_equal, os.path.exists(fn % oap_kwargs), True

diff -r c20ca31d9d7c34e66ab9ae02f3868af0fd08ba7f -r 440902ffb795b23c044a09e96c3d1f2e1539273c 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
@@ -96,14 +96,12 @@
     -------
     image : array
         An (N,N) array of the final integrated values, in float64 form.
-    sc : Scene instance
-        A Scene instance that was created and can be modified for further use.
 
     Examples
     --------
 
-    >>> image, sc = off_axis_projection(ds, [0.5, 0.5, 0.5], [0.2,0.3,0.4],
-                      0.2, N, "temperature", "density")
+    >>> image = off_axis_projection(ds, [0.5, 0.5, 0.5], [0.2,0.3,0.4],
+    ...                             0.2, N, "temperature", "density")
     >>> write_image(np.log10(image), "offaxis.png")
 
     """
@@ -199,4 +197,4 @@
             image[:,:,0] /= image[:,:,1]
             image[mask] = 0
 
-    return image[:,:,0], sc
+    return image[:,:,0]

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