[yt-svn] commit/yt: 11 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Oct 28 18:41:55 PDT 2015
11 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/badbbb9071ac/
Changeset: badbbb9071ac
Branch: yt
User: atmyers
Date: 2015-10-21 19:50:16+00:00
Summary: merging
Affected #: 17 files
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/amrkdtree_downsampling.py
--- a/doc/source/cookbook/amrkdtree_downsampling.py
+++ b/doc/source/cookbook/amrkdtree_downsampling.py
@@ -40,7 +40,7 @@
render_source.set_volume(kd_low_res)
render_source.set_fields('density')
sc.render()
-sc.save("v1.png")
+sc.save("v1.png", sigma_clip=6.0)
# This operation was substantiall faster. Now lets modify the low resolution
# rendering until we find something we like.
@@ -49,14 +49,14 @@
tf.clear()
tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
alpha=np.ones(4, dtype='float64'), colormap='RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v2.png")
+sc.render()
+sc.save("v2.png", sigma_clip=6.0)
# This looks better. Now let's try turning on opacity.
tf.grey_opacity = True
-sc.render(sigma_clip=6.0)
-sc.save("v3.png")
+sc.render()
+sc.save("v3.png", sigma_clip=6.0)
#
## That seemed to pick out som interesting structures. Now let's bump up the
## opacity.
@@ -64,13 +64,13 @@
tf.clear()
tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
alpha=10.0 * np.ones(4, dtype='float64'), colormap='RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v4.png")
+sc.render()
+sc.save("v4.png", sigma_clip=6.0)
#
## This looks pretty good, now lets go back to the full resolution AMRKDTree
#
render_source.set_volume(kd)
-sc.render(sigma_clip=6.0)
-sc.render("v5.png")
+sc.render()
+sc.save("v5.png", sigma_clip=6.0)
# This looks great!
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/camera_movement.py
--- a/doc/source/cookbook/camera_movement.py
+++ b/doc/source/cookbook/camera_movement.py
@@ -14,18 +14,18 @@
frame = 0
# Move to the maximum density location over 5 frames
for _ in cam.iter_move(max_c, 5):
- sc.render(sigma_clip=8.0)
- sc.save('camera_movement_%04i.png' % frame)
+ sc.render()
+ sc.save('camera_movement_%04i.png' % frame, sigma_clip=8.0)
frame += 1
# Zoom in by a factor of 10 over 5 frames
for _ in cam.iter_zoom(10.0, 5):
- sc.render(sigma_clip=8.0)
- sc.save('camera_movement_%04i.png' % frame)
+ sc.render()
+ sc.save('camera_movement_%04i.png' % frame, sigma_clip=8.0)
frame += 1
# Do a rotation over 5 frames
for _ in cam.iter_rotate(np.pi, 5):
- sc.render(sigma_clip=8.0)
- sc.save('camera_movement_%04i.png' % frame)
+ sc.render()
+ sc.save('camera_movement_%04i.png' % frame, sigma_clip=8.0)
frame += 1
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -218,6 +218,17 @@
.. yt_cookbook:: custom_transfer_function_volume_rendering.py
+.. _cookbook-sigma_clip:
+
+Volume Rendering with Sigma Clipping
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In this recipe we output several images with different values of sigma_clip
+set in order to change the contrast of the resulting image. See
+:ref:`sigma_clip` for more information.
+
+.. yt_cookbook:: sigma_clip.py
+
Zooming into an Image
~~~~~~~~~~~~~~~~~~~~~
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/custom_camera_volume_rendering.py
--- a/doc/source/cookbook/custom_camera_volume_rendering.py
+++ b/doc/source/cookbook/custom_camera_volume_rendering.py
@@ -18,5 +18,5 @@
# save to disk with a custom filename and apply sigma clipping to eliminate
# very bright pixels, producing an image with better contrast.
-sc.render(sigma_clip=4)
-sc.save('custom.png')
+sc.render()
+sc.save('custom.png', sigma_clip=4)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/opaque_rendering.py
--- a/doc/source/cookbook/opaque_rendering.py
+++ b/doc/source/cookbook/opaque_rendering.py
@@ -12,8 +12,8 @@
tf.clear()
tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
alpha=np.logspace(-3,0,4), colormap = 'RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v1.png")
+sc.render()
+sc.save("v1.png", sigma_clip=6.0)
# In this case, the default alphas used (np.logspace(-3,0,Nbins)) does not
# accentuate the outer regions of the galaxy. Let's start by bringing up the
@@ -23,31 +23,31 @@
tf.clear()
tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
alpha=np.logspace(0,0,4), colormap = 'RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v2.png")
+sc.render()
+sc.save("v2.png", sigma_clip=6.0)
# Now let's set the grey_opacity to True. This should make the inner portions
# start to be obcured
tf.grey_opacity = True
-sc.render(sigma_clip=6.0)
-sc.save("v3.png")
+sc.render()
+sc.save("v3.png", sigma_clip=6.0)
# That looks pretty good, but let's start bumping up the opacity.
tf.clear()
tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
alpha=10.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v4.png")
+sc.render()
+sc.save("v4.png", sigma_clip=6.0)
# Let's bump up again to see if we can obscure the inner contour.
tf.clear()
tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
alpha=30.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v5.png")
+sc.render()
+sc.save("v5.png", sigma_clip=6.0)
# Now we are losing sight of everything. Let's see if we can obscure the next
# layer
@@ -55,15 +55,15 @@
tf.clear()
tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
alpha=100.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-sc.render(sigma_clip=6.0)
-sc.save("v6.png")
+sc.render()
+sc.save("v6.png", sigma_clip=6.0)
# That is very opaque! Now lets go back and see what it would look like with
# grey_opacity = False
tf.grey_opacity=False
-sc.render(sigma_clip=6.0)
-sc.save("v7.png")
+sc.render()
+sc.save("v7.png", sigma_clip=6.0)
# That looks pretty different, but the main thing is that you can see that the
# inner contours are somewhat visible again.
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/sigma_clip.py
--- /dev/null
+++ b/doc/source/cookbook/sigma_clip.py
@@ -0,0 +1,17 @@
+import yt
+
+# Load the dataset.
+ds = yt.load("enzo_tiny_cosmology/RD0009/RD0009")
+
+# Create a volume rendering, which will determine data bounds, use the first
+# acceptable field in the field_list, and set up a default transfer function.
+
+# Render and save output images with different levels of sigma clipping.
+# Sigma clipping removes the highest intensity pixels in a volume render,
+# which affects the overall contrast of the image.
+sc = yt.create_scene(ds, field=('gas', 'density'))
+sc.render()
+sc.save('clip_0.png')
+sc.save('clip_2.png', sigma_clip=2)
+sc.save('clip_4.png', sigma_clip=4)
+sc.save('clip_6.png', sigma_clip=6)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/simple_volume_rendering.py
--- a/doc/source/cookbook/simple_volume_rendering.py
+++ b/doc/source/cookbook/simple_volume_rendering.py
@@ -6,5 +6,5 @@
# Create a volume rendering, which will determine data bounds, use the first
# acceptable field in the field_list, and set up a default transfer function.
-# This will save a file named 'data0043_density_volume_rendered.png' to disk.
+# This will save a file named 'data0043_Render_density.png' to disk.
im, sc = yt.volume_render(ds, field=('gas', 'density'))
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/cookbook/various_lens.py
--- a/doc/source/cookbook/various_lens.py
+++ b/doc/source/cookbook/various_lens.py
@@ -34,8 +34,8 @@
cam.set_width(ds.domain_width * 0.5)
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_plane-parallel.png')
+sc.render()
+sc.save('lens_plane-parallel.png', sigma_clip=6.0)
# Perspective lens
cam = Camera(ds, lens_type='perspective')
@@ -51,8 +51,8 @@
cam.set_width(ds.domain_width * 0.5)
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_perspective.png')
+sc.render()
+sc.save('lens_perspective.png', sigma_clip=6.0)
# Stereo-perspective lens
cam = Camera(ds, lens_type='stereo-perspective')
@@ -67,8 +67,8 @@
cam.lens.disparity = ds.domain_width[0] * 1.e-3
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_stereo-perspective.png')
+sc.render()
+sc.save('lens_stereo-perspective.png', sigma_clip=6.0)
# Fisheye lens
dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 10)
@@ -82,8 +82,8 @@
cam.lens.fov = 360.0
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_fisheye.png')
+sc.render()
+sc.save('lens_fisheye.png', sigma_clip=6.0)
# Spherical lens
cam = Camera(ds, lens_type='spherical')
@@ -100,8 +100,8 @@
cam.set_width(ds.domain_width * 0.5)
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_spherical.png')
+sc.render()
+sc.save('lens_spherical.png', sigma_clip=6.0)
# Stereo-spherical lens
cam = Camera(ds, lens_type='stereo-spherical')
@@ -116,5 +116,5 @@
cam.lens.disparity = ds.domain_width[0] * 1.e-3
sc.camera = cam
sc.add_source(vol)
-sc.render(sigma_clip=6.0)
-sc.save('lens_stereo-spherical.png')
+sc.render()
+sc.save('lens_stereo-spherical.png', sigma_clip=6.0)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 doc/source/visualizing/volume_rendering.rst
--- a/doc/source/visualizing/volume_rendering.rst
+++ b/doc/source/visualizing/volume_rendering.rst
@@ -167,20 +167,21 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If your images appear to be too dark, you can try using the ``sigma_clip``
-keyword in the :meth:`~yt.visualization.volume_rendering.scene.Scene.render`
-or :func:`~yt.visualization.volume_rendering.volume_rendering.volume_render` functions.
-Because the brightness range in an image is scaled to match the range of
-emissivity values of underlying rendering, if you have a few really
+keyword in the :meth:`~yt.visualization.volume_rendering.scene.Scene.save`
+or :func:`~yt.visualization.volume_rendering.volume_rendering.volume_render`
+functions. Because the brightness range in an image is scaled to match the
+range of emissivity values of underlying rendering, if you have a few really
high-emissivity points, they will scale the rest of your image to be quite
dark. ``sigma_clip = N`` can address this by removing values that are more
than ``N`` standard deviations brighter than the mean of your image.
Typically, a choice of 4 to 6 will help dramatically with your resulting image.
+See the cookbook recipe :ref:`cookbook-sigma_clip` for a demonstration.
.. python-script::
sc = yt.create_scene(ds, 'density')
- sc.render(sigma_clip=4)
- sc.save()
+ sc.render()
+ sc.save(sigma_clip=4)
.. _transfer_functions:
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -678,8 +678,8 @@
def run(self):
tmpfd, tmpname = tempfile.mkstemp(suffix='.png')
os.close(tmpfd)
- self.scene.render(sigma_clip=1.0)
- self.scene.save(tmpname)
+ self.scene.render()
+ self.scene.save(tmpname, sigma_clip=1.0)
image = mpimg.imread(tmpname)
os.remove(tmpname)
return [zlib.compress(image.dumps())]
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -124,7 +124,7 @@
return self
- def render(self, sigma_clip=None, camera=None):
+ def render(self, camera=None):
r"""Render all sources in the Scene.
Use the current state of the Scene object to render all sources
@@ -133,10 +133,6 @@
Parameters
----------
- sigma_clip: float, optional
- Image will be clipped before saving to the standard deviation
- of the image multiplied by this value. Useful for enhancing
- images. Default: None
camera: :class:`Camera`, optional
If specified, use a different :class:`Camera` to render the scene.
@@ -168,7 +164,7 @@
self.last_render = bmp
return bmp
- def save(self, fname=None):
+ def save(self, fname=None, sigma_clip=None):
r"""Saves the most recently rendered image of the Scene to disk.
Once you have created a scene and rendered that scene to an image
@@ -182,6 +178,13 @@
If specified, save the rendering as a bitmap to the file "fname".
If unspecified, it creates a default based on the dataset filename.
Default: None
+ sigma_clip: float, optional
+ Image values greater than this number times the standard deviation
+ plus the mean of the image will be clipped before saving. Useful
+ for enhancing images as it gets rid of rare high pixel values.
+ Default: None
+
+ floor(vals > std_dev*sigma_clip + mean)
Returns
-------
@@ -198,7 +201,11 @@
>>> sc = yt.create_scene(ds)
>>> # Modify camera, sources, etc...
>>> sc.render()
- >>> sc.save('test.png')
+ >>> sc.save('raw.png')
+ >>> # make another image with sigma_clip=2
+ >>> sc.save('clipped_2.png', sigma_clip=2)
+ >>> # make yet another image with sigma_clip=4
+ >>> sc.save('clipped_4.png', sigma_clip=4)
Or alternatively:
@@ -236,7 +243,7 @@
self.render()
mylog.info("Saving render %s", fname)
- self.last_render.write_png(fname)
+ self.last_render.write_png(fname, sigma_clip=sigma_clip)
def _validate(self):
r"""Validate the current state of the scene."""
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
--- a/yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
+++ b/yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
@@ -21,5 +21,5 @@
frames = 10
for i in range(frames):
sc.camera.yaw(angle/frames)
- sc.render(sigma_clip=6.0)
- sc.save('test_rot_%04i.png' % i)
+ sc.render()
+ sc.save('test_rot_%04i.png' % i, sigma_clip=6.0)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/tests/test_lenses.py
--- a/yt/visualization/volume_rendering/tests/test_lenses.py
+++ b/yt/visualization/volume_rendering/tests/test_lenses.py
@@ -55,8 +55,8 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_perspective_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_perspective_%s.png' % self.field[1], sigma_clip=6.0)
def test_stereoperspective_lens(self):
sc = Scene()
@@ -68,8 +68,8 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_stereoperspective_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_stereoperspective_%s.png' % self.field[1], sigma_clip=6.0)
def test_fisheye_lens(self):
dd = self.ds.sphere(self.ds.domain_center,
@@ -86,8 +86,8 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_fisheye_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_fisheye_%s.png' % self.field[1], sigma_clip=6.0)
def test_plane_lens(self):
dd = self.ds.sphere(self.ds.domain_center,
@@ -102,8 +102,8 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_plane_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_plane_%s.png' % self.field[1], sigma_clip=6.0)
def test_spherical_lens(self):
sc = Scene()
@@ -115,8 +115,8 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_spherical_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_spherical_%s.png' % self.field[1], sigma_clip=6.0)
def test_stereospherical_lens(self):
w = (self.ds.domain_width).in_units('code_length')
@@ -130,5 +130,5 @@
tf.grey_opacity = True
sc.camera = cam
sc.add_source(vol)
- sc.render(sigma_clip=6.0)
- sc.save('test_stereospherical_%s.png' % self.field[1])
+ sc.render()
+ sc.save('test_stereospherical_%s.png' % self.field[1], sigma_clip=6.0)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/tests/test_scene.py
--- a/yt/visualization/volume_rendering/tests/test_scene.py
+++ b/yt/visualization/volume_rendering/tests/test_scene.py
@@ -76,11 +76,11 @@
mi_bound = ((ma-mi)*(0.10))+mi
ma_bound = ((ma-mi)*(0.90))+mi
tf.map_to_colormap(mi_bound, ma_bound, scale=0.01, colormap='Reds_r')
- sc.render(sigma_clip=6.0)
- sc.save('test_scene.png')
+ sc.render()
+ sc.save('test_scene.png', sigma_clip=6.0)
nrot = 2
for i in range(nrot):
sc.camera.pitch(2*np.pi/nrot)
- sc.render(sigma_clip=6.0)
- sc.save('test_rot_%04i.png' % i)
+ sc.render()
+ sc.save('test_rot_%04i.png' % i, sigma_clip=6.0)
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/tests/test_sigma_clip.py
--- /dev/null
+++ b/yt/visualization/volume_rendering/tests/test_sigma_clip.py
@@ -0,0 +1,54 @@
+"""
+Test Simple Volume Rendering Scene
+
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2014, yt Development Team.
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+import os
+import tempfile
+import shutil
+import yt
+from yt.testing import fake_random_ds
+from unittest import TestCase
+
+# This toggles using a temporary directory. Turn off to examine images.
+use_tmpdir = True
+
+
+def setup():
+ """Test specific setup."""
+ from yt.config import ytcfg
+ ytcfg["yt", "__withintesting"] = "True"
+
+
+class SigmaClipTest(TestCase):
+ def setUp(self):
+ if use_tmpdir:
+ self.curdir = os.getcwd()
+ # Perform I/O in safe place instead of yt main dir
+ self.tmpdir = tempfile.mkdtemp()
+ os.chdir(self.tmpdir)
+ else:
+ self.curdir, self.tmpdir = None, None
+
+ def tearDown(self):
+ if use_tmpdir:
+ os.chdir(self.curdir)
+ shutil.rmtree(self.tmpdir)
+
+ def test_sigma_clip(self):
+ ds = fake_random_ds(32)
+ sc = yt.create_scene(ds)
+ im = sc.render()
+ sc.save('raw.png')
+ sc.save('clip_2.png', sigma_clip=2)
+ sc.save('clip_4.png', sigma_clip=4.0)
+ print(sc)
+ return im, sc
diff -r 48577b8fe920eafe3eaa2e2a4ab69eef13387f26 -r badbbb9071ac0d41805b723ec58e20a57bf60292 yt/visualization/volume_rendering/volume_rendering.py
--- a/yt/visualization/volume_rendering/volume_rendering.py
+++ b/yt/visualization/volume_rendering/volume_rendering.py
@@ -113,6 +113,6 @@
>>> im, sc = yt.volume_render(ds, fname='test.png', sigma_clip=4.0)
"""
sc = create_scene(data_source, field=field)
- im = sc.render(sigma_clip=sigma_clip)
- sc.save(fname=fname)
+ im = sc.render()
+ sc.save(fname=fname, sigma_clip=sigma_clip)
return im, sc
https://bitbucket.org/yt_analysis/yt/commits/3a60f8a0e7b3/
Changeset: 3a60f8a0e7b3
Branch: yt
User: atmyers
Date: 2015-10-21 19:56:14+00:00
Summary: merging
Affected #: 1 file
https://bitbucket.org/yt_analysis/yt/commits/ffbcd98c159b/
Changeset: ffbcd98c159b
Branch: yt
User: atmyers
Date: 2015-10-21 21:57:56+00:00
Summary: merging
Affected #: 1 file
diff -r 3a60f8a0e7b3ba1fd2b67fbacde076a7773ca0f3 -r ffbcd98c159ba43e42d9247a3f90d4f6d625d196 yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -501,8 +501,19 @@
# DRAW SOME POINTS
camera.lens.setup_box_properties(camera)
px, py, dz = camera.lens.project_to_plane(camera, vertices)
+
+ # Non-plane-parallel lenses only support 1D array
+ # 1D array needs to be transformed to 2D to get points plotted
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0], camera.resolution[1], 4)
+ z.shape = (camera.resolution[0], camera.resolution[1])
+
zpoints(empty, z, px.d, py.d, dz.d, self.colors, self.color_stride)
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0] * camera.resolution[1], 1, 4)
+ z.shape = (camera.resolution[0] * camera.resolution[1], 1)
+
self.zbuffer = zbuffer
return zbuffer
@@ -616,8 +627,19 @@
# DRAW SOME LINES
camera.lens.setup_box_properties(camera)
px, py, dz = camera.lens.project_to_plane(camera, vertices)
+
+ # Non-plane-parallel lenses only support 1D array
+ # 1D array needs to be transformed to 2D to get lines plotted
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0], camera.resolution[1], 4)
+ z.shape = (camera.resolution[0], camera.resolution[1])
+
zlines(empty, z, px.d, py.d, dz.d, self.colors, self.color_stride)
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0] * camera.resolution[1], 1, 4)
+ z.shape = (camera.resolution[0] * camera.resolution[1], 1)
+
self.zbuffer = zbuffer
return zbuffer
@@ -884,8 +906,19 @@
z = zbuffer.z
# Draw the vectors
+
+ # Non-plane-parallel lenses only support 1D array
+ # 1D array needs to be transformed to 2D to get lines plotted
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0], camera.resolution[1], 4)
+ z.shape = (camera.resolution[0], camera.resolution[1])
+
zlines(empty, z, px.d, py.d, dz.d, self.colors, self.color_stride)
+ if 'plane-parallel' not in str(camera.lens):
+ empty.shape = (camera.resolution[0] * camera.resolution[1], 1, 4)
+ z.shape = (camera.resolution[0] * camera.resolution[1], 1)
+
# Set the new zbuffer
self.zbuffer = zbuffer
return zbuffer
https://bitbucket.org/yt_analysis/yt/commits/1f60d09d81e7/
Changeset: 1f60d09d81e7
Branch: yt
User: atmyers
Date: 2015-10-27 01:26:02+00:00
Summary: removing unused imports from the scene docstring examples
Affected #: 1 file
diff -r ffbcd98c159ba43e42d9247a3f90d4f6d625d196 -r 1f60d09d81e75f1b7116d5e21af9d3cd3f81b760 yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -59,8 +59,6 @@
and then modify the Scene later:
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -145,8 +143,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -194,8 +190,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -206,8 +200,6 @@
Or alternatively:
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -272,8 +264,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -353,8 +343,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -395,8 +383,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
@@ -427,8 +413,6 @@
--------
>>> import yt
- >>> import numpy as np
- >>> from yt.visualization.volume_rendering.api import PointSource
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>>
>>> sc = yt.create_scene(ds)
https://bitbucket.org/yt_analysis/yt/commits/f84d18c4af35/
Changeset: f84d18c4af35
Branch: yt
User: atmyers
Date: 2015-10-27 01:54:57+00:00
Summary: show() and _repr_png_() methods for Scenes
Affected #: 1 file
diff -r 1f60d09d81e75f1b7116d5e21af9d3cd3f81b760 -r f84d18c4af351826494d88e2d4ad382ef262c7ce yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -20,6 +20,7 @@
from .render_source import OpaqueSource, BoxSource, CoordinateVectorSource, \
GridSource, RenderSource
from .zbuffer_array import ZBuffer
+from yt.visualization.image_writer import write_bitmap
class Scene(object):
@@ -424,6 +425,14 @@
self.add_source(coords)
return self
+ def show(self):
+ return self
+
+ def _repr_png_(self):
+ if self.last_render is None:
+ self.render()
+ return write_bitmap(self.last_render, filename=None)
+
def __repr__(self):
disp = "<Scene Object>:"
disp += "\nSources: \n"
https://bitbucket.org/yt_analysis/yt/commits/d4f126b18fe1/
Changeset: d4f126b18fe1
Branch: yt
User: atmyers
Date: 2015-10-27 02:03:01+00:00
Summary: show and _repr_png methods for Scene objects
Affected #: 1 file
diff -r f84d18c4af351826494d88e2d4ad382ef262c7ce -r d4f126b18fe1f8537d5de768557659709f650e8c yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -21,6 +21,7 @@
GridSource, RenderSource
from .zbuffer_array import ZBuffer
from yt.visualization.image_writer import write_bitmap
+from yt.extern.six.moves import builtins
class Scene(object):
@@ -425,8 +426,34 @@
self.add_source(coords)
return self
+
def show(self):
- return self
+ r"""This will send the most recently rendered image to the IPython
+ notebook.
+
+ If yt is being run from within an IPython session, and it is able to
+ determine this, this function will send the current image of this Scene
+ to the notebook for display. If there is no current image, it will
+ run the render() method on this Scene before sending the result to the
+ notebook.
+
+ If yt can't determine if it's inside an IPython session, this will raise
+ YTNotInsideNotebook.
+
+ Examples
+ --------
+
+ >>> import yt
+ >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
+ >>>
+ >>> sc = yt.create_scene(ds)
+ >>> sc.show()
+
+ """
+ if "__IPYTHON__" in dir(builtins):
+ return self
+ else:
+ raise YTNotInsideNotebook
def _repr_png_(self):
if self.last_render is None:
https://bitbucket.org/yt_analysis/yt/commits/76c2129009dc/
Changeset: 76c2129009dc
Branch: yt
User: atmyers
Date: 2015-10-28 06:57:26+00:00
Summary: make background black
Affected #: 1 file
diff -r d4f126b18fe1f8537d5de768557659709f650e8c -r 76c2129009dcc28582cb747668faa9e4c2c1a952 yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -458,7 +458,9 @@
def _repr_png_(self):
if self.last_render is None:
self.render()
- return write_bitmap(self.last_render, filename=None)
+ im = self.last_render.add_background_color(background='black',
+ inline=False)
+ return write_bitmap(im, filename=None)
def __repr__(self):
disp = "<Scene Object>:"
https://bitbucket.org/yt_analysis/yt/commits/0c3a1a459ca2/
Changeset: 0c3a1a459ca2
Branch: yt
User: atmyers
Date: 2015-10-28 07:19:34+00:00
Summary: allow write_png to accept filename=None, in which case the png is returned as a string
Affected #: 1 file
diff -r 76c2129009dcc28582cb747668faa9e4c2c1a952 -r 0c3a1a459ca275a50181a7902162b3b3dfff46a7 yt/data_objects/image_array.py
--- a/yt/data_objects/image_array.py
+++ b/yt/data_objects/image_array.py
@@ -246,7 +246,8 @@
Parameters
----------
filename: string
- Note filename not be modified.
+ Filename to save to. If None, PNG contents will be returned as a
+ string.
sigma_clip: float, optional
Image will be clipped before saving to the standard deviation
of the image multiplied by this value. Useful for enhancing
@@ -291,7 +292,7 @@
else:
out = scaled
- if filename[-4:] != '.png':
+ if filename is not None and filename[-4:] != '.png':
filename += '.png'
if clip_ratio is not None:
https://bitbucket.org/yt_analysis/yt/commits/89c3466f330d/
Changeset: 89c3466f330d
Branch: yt
User: atmyers
Date: 2015-10-28 07:19:59+00:00
Summary: dynamically create the _repr_png method using the input value of sigma_clip
Affected #: 1 file
diff -r 0c3a1a459ca275a50181a7902162b3b3dfff46a7 -r 89c3466f330dfc20c4aff6b88b02dd640a461e04 yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -20,8 +20,8 @@
from .render_source import OpaqueSource, BoxSource, CoordinateVectorSource, \
GridSource, RenderSource
from .zbuffer_array import ZBuffer
-from yt.visualization.image_writer import write_bitmap
from yt.extern.six.moves import builtins
+from types import MethodType
class Scene(object):
@@ -427,7 +427,7 @@
return self
- def show(self):
+ def show(self, sigma_clip=None):
r"""This will send the most recently rendered image to the IPython
notebook.
@@ -451,17 +451,19 @@
"""
if "__IPYTHON__" in dir(builtins):
+ # dynamically set the _repr_png(self) method using the
+ # input value of sigma_clip
+ def func(self):
+ if self.last_render is None:
+ self.render()
+ return self.last_render.write_png(filename=None,
+ sigma_clip=sigma_clip,
+ background='black')
+ self._repr_png_ = MethodType(func, self, Scene)
return self
else:
raise YTNotInsideNotebook
- def _repr_png_(self):
- if self.last_render is None:
- self.render()
- im = self.last_render.add_background_color(background='black',
- inline=False)
- return write_bitmap(im, filename=None)
-
def __repr__(self):
disp = "<Scene Object>:"
disp += "\nSources: \n"
https://bitbucket.org/yt_analysis/yt/commits/f4c6a5fe72ea/
Changeset: f4c6a5fe72ea
Branch: yt
User: atmyers
Date: 2015-10-28 18:07:19+00:00
Summary: implementing show() using a non-public attribute instead
Affected #: 1 file
diff -r 89c3466f330dfc20c4aff6b88b02dd640a461e04 -r f4c6a5fe72ea4440328eccd4411bce7bea1d689e yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -79,6 +79,9 @@
self.camera = None
# An image array containing the last rendered image of the scene
self.last_render = None
+ # A non-public attribute used to get around the fact that we can't
+ # pass kwargs into _repr_png_()
+ self._sigma_clip = None
def get_source(self, source_num):
"""Returns the volume rendering source indexed by ``source_num``"""
@@ -451,19 +454,20 @@
"""
if "__IPYTHON__" in dir(builtins):
- # dynamically set the _repr_png(self) method using the
- # input value of sigma_clip
- def func(self):
- if self.last_render is None:
- self.render()
- return self.last_render.write_png(filename=None,
- sigma_clip=sigma_clip,
- background='black')
- self._repr_png_ = MethodType(func, self, Scene)
+ self._sigma_clip = sigma_clip
return self
else:
raise YTNotInsideNotebook
+ def _repr_png_(self):
+ if self.last_render is None:
+ self.render()
+ png = self.last_render.write_png(filename=None,
+ sigma_clip=self._sigma_clip,
+ background='black')
+ self._sigma_clip = None
+ return png
+
def __repr__(self):
disp = "<Scene Object>:"
disp += "\nSources: \n"
https://bitbucket.org/yt_analysis/yt/commits/60428e2d8aad/
Changeset: 60428e2d8aad
Branch: yt
User: atmyers
Date: 2015-10-28 18:14:24+00:00
Summary: don't need this import any more
Affected #: 1 file
diff -r f4c6a5fe72ea4440328eccd4411bce7bea1d689e -r 60428e2d8aad1b87ca57ef6eb3c2fa53fed70dad yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -21,7 +21,6 @@
GridSource, RenderSource
from .zbuffer_array import ZBuffer
from yt.extern.six.moves import builtins
-from types import MethodType
class Scene(object):
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