[yt-svn] commit/yt-doc: 4 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Feb 19 11:56:30 PST 2013
4 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/commits/b4487b1cae41/
changeset: b4487b1cae41
user: samskillman
date: 2013-02-18 19:25:10
summary: Updating documentation with fixed up VR examples. Adding ImageArray to the api
docstrings. Adding changes to the changelog.
affected #: 6 files
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/api/api.rst
--- a/source/api/api.rst
+++ b/source/api/api.rst
@@ -259,6 +259,20 @@
~yt.data_objects.field_info_container.ValidateProperty
~yt.data_objects.field_info_container.ValidateSpatial
+Image Handling
+--------------
+
+For volume renderings and fixed resolution buffers the image object returned is
+an ``ImageArray`` object, which has useful functions for image saving and
+writing to bitmaps.
+
+.. autosummary::
+ :toctree: generated/
+
+ ~yt.data_objects.image_array.ImageArray
+ ~yt.data_objects.image_array.ImageArray.write_png
+ ~yt.data_objects.image_array.ImageArray.write_hdf5
+
Extension Types
---------------
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/changelog.rst
--- a/source/changelog.rst
+++ b/source/changelog.rst
@@ -143,10 +143,22 @@
Notebook to enable better integration.
* Metallicity-dependent X-ray fields have now been added.
* Grid lines can now be added to volume renderings.
- * Volume renderings now have alpha blending
+ * Volume rendering backend has been updated to use an alpha channel, fixing
+ parallel opaque volume renderings. This also enables easier blending of
+ multiple images and annotations to the rendering. Users are encouraged
+ to look at the capabilities of the ``ImageArray`` for writing out renders,
+ as updated in the cookbook examples. Volume renders can now be saved with
+ an arbitrary background color.
* Periodicity, or alternately non-periodicity, is now a part of radius
calculations.
- * AMRKDTree has been rewritten to allow for sub-region selection.
+ * The AMRKDTree has been rewritten. This allows parallelism with other than
+ power-of-2 MPI processes, arbitrary sets of grids, and splitting of
+ unigrids.
+ * Fixed Resolution Buffers and volume rendering images now utilize a new
+ ImageArray class that stores information such as data source, field names,
+ and other information in a .info dictionary. See the ``ImageArray``
+ docstrings for more information on how they can be used to save to a bitmap
+ or hdf5 file.
Version 2.4
-----------
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/cookbook/camera_movement.py
--- a/source/cookbook/camera_movement.py
+++ b/source/cookbook/camera_movement.py
@@ -27,17 +27,17 @@
# Do a rotation over 5 frames
for i, snapshot in enumerate(cam.rotation(np.pi, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
# Move to the maximum density location over 5 frames
for i, snapshot in enumerate(cam.move_to(max_c, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
# Zoom in by a factor of 10 over 5 frames
for i, snapshot in enumerate(cam.zoomin(10.0, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/cookbook/rendering_with_box_and_grids.py
--- a/source/cookbook/rendering_with_box_and_grids.py
+++ b/source/cookbook/rendering_with_box_and_grids.py
@@ -47,11 +47,11 @@
im = cam.snapshot("%s_volume_rendered.png" % pf, clip_ratio=8.0)
# Add the domain edges, with an alpha blending of 0.3:
-cam.draw_domain(im, alpha=0.3)
-write_image(im, '%s_vr_domain.png' % pf)
+nim = cam.draw_domain(im, alpha=0.3)
+nim.write_png('%s_vr_domain.png' % pf)
# Add the grids, colored by the grid level with the algae colormap
-cam.draw_grids(im, alpha=0.3, cmap='algae')
-write_image(im, '%s_vr_grids.png' % pf)
+nim = cam.draw_grids(im, alpha=0.3, cmap='algae')
+nim.write_png('%s_vr_grids.png' % pf)
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/cookbook/simple_volume_rendering.py
--- a/source/cookbook/simple_volume_rendering.py
+++ b/source/cookbook/simple_volume_rendering.py
@@ -12,12 +12,12 @@
# Create a transfer function to map field values to colors.
# We bump up our minimum to cut out some of the background fluid
-tf = ColorTransferFunction((np.log10(mi)+2.0, np.log10(ma)))
+tf = ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
# Add three guassians, evenly spaced between the min and
# max specified above with widths of 0.02 and using the
# gist_stern colormap.
-tf.add_layers(3, w=0.02, colormap="gist_stern")
+tf.add_layers(5, w=0.02, colormap="spectral")
# Choose a center for the render.
c = [0.5, 0.5, 0.5]
diff -r 671b010e4f51d170d7a44612fcf2357d88786531 -r b4487b1cae410ea7e7da5854a233af0a413e24e2 source/visualizing/volume_rendering.rst
--- a/source/visualizing/volume_rendering.rst
+++ b/source/visualizing/volume_rendering.rst
@@ -39,51 +39,45 @@
Here is a working example for the IsolatedGalaxy dataset from the 2012 yt workshop.
.. code-block:: python
+ from yt.mods import *
- from yt.mods import *
-
- pf = load("galaxy0030/galaxy0030")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Choose a field
field = 'Density'
# Do you want the log of the field?
use_log = True
-
+
# Find the bounds in log space of for your field
dd = pf.h.all_data()
mi, ma = dd.quantities["Extrema"](field)[0]
-
+
if use_log:
mi,ma = np.log10(mi), np.log10(ma)
-
+
# Instantiate the ColorTransferfunction.
tf = ColorTransferFunction((mi, ma))
-
+
# Set up the camera parameters: center, looking direction, width, resolution
c = (pf.domain_right_edge + pf.domain_left_edge)/2.0
L = np.array([1.0, 1.0, 1.0])
W = 0.3 / pf["unitary"]
N = 256
-
+
# Create a camera object
cam = pf.h.camera(c, L, W, N, tf, fields = [field], log_fields = [use_log])
-
- # Set up the filename using pf and field.
- fn = "%s_%s_rendering.png" % (pf, field)
-
- # Now let's add some isocontours, and take a snapshot.
+
+ # Now let's add some isocontours, and take a snapshot, saving the image
+ # to a file.
tf.add_layers(10, 0.01, colormap = 'RdBu_r')
- im = cam.snapshot('test_rendering.png',clip_ratio=6.0)
-
- # Take a snapshot, saving the image to file fn.
- im = cam.snapshot(fn)
-
+ im = cam.snapshot('test_rendering.png')
+
# To add the domain box to the image:
- cam.draw_domain(im)
- write_bitmap(im, 'test_rendering_with_domain.png')
+ nim = cam.draw_domain(im)
+ nim.write_png('test_rendering_with_domain.png')
# To add the grid outlines to the image:
- cam.draw_grids(im)
- write_bitmap(im, 'test_rendering_with_grids.png')
+ nim = cam.draw_grids(im)
+ nim.write_png('test_rendering_with_grids.png')
Method
------
https://bitbucket.org/yt_analysis/yt-doc/commits/4688ae1a52c9/
changeset: 4688ae1a52c9
user: samskillman
date: 2013-02-18 19:34:13
summary: Adding cookbook on saving images with different background colors.
affected #: 1 file
diff -r b4487b1cae410ea7e7da5854a233af0a413e24e2 -r 4688ae1a52c965cdabfc486e8a0adbaa5588227e source/cookbook/image_background_colors.py
--- /dev/null
+++ b/source/cookbook/image_background_colors.py
@@ -0,0 +1,35 @@
+from yt.mods import *
+
+# This shows how to save ImageArray objects, such as those returned from
+# volume renderings, to pngs with varying backgrounds.
+
+# Lets make a fake "rendering" that has 4 channels and looks like a linear
+# gradient from the bottom to top.
+im = np.zeros([64,128,4])
+for i in xrange(im.shape[0]):
+ for k in xrange(im.shape[2]):
+ im[i,:,k] = np.linspace(0.,10.*k, im.shape[1])
+im_arr = ImageArray(im)
+
+# in this case you would have gotten im_arr from something like:
+# im_arr = cam.snapshot()
+
+# To save it with the default settings, we can just use write_png, where it
+# rescales the image and uses a black background.
+im_arr.write_png('standard.png')
+
+# write_png accepts a background keyword argument that defaults to 'black'.
+# Other choices include:
+# black (0.,0.,0.,1.)
+# white (1.,1.,1.,1.)
+# None (0.,0.,0.,0.) <-- Transparent!
+# any rgba list/array: [r,g,b,a], bounded by 0..1
+im_arr.write_png('black_bg.png', background='black')
+im_arr.write_png('white_bg.png', background='white')
+im_arr.write_png('green_bg.png', background=[0.,1.,0.,1.])
+im_arr.write_png('transparent_bg.png', background=None)
+
+
+
+
+
https://bitbucket.org/yt_analysis/yt-doc/commits/dcd1336ba4cd/
changeset: dcd1336ba4cd
user: samskillman
date: 2013-02-19 17:02:02
summary: Adding cookbook entry for modifying image background colors to simple plots.
affected #: 1 file
diff -r 4688ae1a52c965cdabfc486e8a0adbaa5588227e -r dcd1336ba4cd6c42a08d69357934dfc3f53755ef source/cookbook/simple_plots.rst
--- a/source/cookbook/simple_plots.rst
+++ b/source/cookbook/simple_plots.rst
@@ -103,3 +103,10 @@
.. yt_cookbook:: simple_volume_rendering.py
+Image Background Colors
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Here we see how to take an image and save it using different background colors.
+
+.. yt_cookbook:: image_background_colors.py
+
https://bitbucket.org/yt_analysis/yt-doc/commits/3101a9bd7702/
changeset: 3101a9bd7702
user: MatthewTurk
date: 2013-02-19 20:56:25
summary: Merged in samskillman/yt-doc (pull request #81)
Rendering, ImageArray docs.
affected #: 8 files
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/api/api.rst
--- a/source/api/api.rst
+++ b/source/api/api.rst
@@ -259,6 +259,20 @@
~yt.data_objects.field_info_container.ValidateProperty
~yt.data_objects.field_info_container.ValidateSpatial
+Image Handling
+--------------
+
+For volume renderings and fixed resolution buffers the image object returned is
+an ``ImageArray`` object, which has useful functions for image saving and
+writing to bitmaps.
+
+.. autosummary::
+ :toctree: generated/
+
+ ~yt.data_objects.image_array.ImageArray
+ ~yt.data_objects.image_array.ImageArray.write_png
+ ~yt.data_objects.image_array.ImageArray.write_hdf5
+
Extension Types
---------------
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/changelog.rst
--- a/source/changelog.rst
+++ b/source/changelog.rst
@@ -144,10 +144,22 @@
Notebook to enable better integration.
* Metallicity-dependent X-ray fields have now been added.
* Grid lines can now be added to volume renderings.
- * Volume renderings now have alpha blending
+ * Volume rendering backend has been updated to use an alpha channel, fixing
+ parallel opaque volume renderings. This also enables easier blending of
+ multiple images and annotations to the rendering. Users are encouraged
+ to look at the capabilities of the ``ImageArray`` for writing out renders,
+ as updated in the cookbook examples. Volume renders can now be saved with
+ an arbitrary background color.
* Periodicity, or alternately non-periodicity, is now a part of radius
calculations.
- * AMRKDTree has been rewritten to allow for sub-region selection.
+ * The AMRKDTree has been rewritten. This allows parallelism with other than
+ power-of-2 MPI processes, arbitrary sets of grids, and splitting of
+ unigrids.
+ * Fixed Resolution Buffers and volume rendering images now utilize a new
+ ImageArray class that stores information such as data source, field names,
+ and other information in a .info dictionary. See the ``ImageArray``
+ docstrings for more information on how they can be used to save to a bitmap
+ or hdf5 file.
Version 2.4
-----------
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/cookbook/camera_movement.py
--- a/source/cookbook/camera_movement.py
+++ b/source/cookbook/camera_movement.py
@@ -27,17 +27,17 @@
# Do a rotation over 5 frames
for i, snapshot in enumerate(cam.rotation(np.pi, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
# Move to the maximum density location over 5 frames
for i, snapshot in enumerate(cam.move_to(max_c, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
# Zoom in by a factor of 10 over 5 frames
for i, snapshot in enumerate(cam.zoomin(10.0, 5, clip_ratio = 8.0)):
- write_bitmap(snapshot, 'camera_movement_%04i.png' % frame)
+ snapshot.write_png('camera_movement_%04i.png' % frame)
frame += 1
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/cookbook/image_background_colors.py
--- /dev/null
+++ b/source/cookbook/image_background_colors.py
@@ -0,0 +1,35 @@
+from yt.mods import *
+
+# This shows how to save ImageArray objects, such as those returned from
+# volume renderings, to pngs with varying backgrounds.
+
+# Lets make a fake "rendering" that has 4 channels and looks like a linear
+# gradient from the bottom to top.
+im = np.zeros([64,128,4])
+for i in xrange(im.shape[0]):
+ for k in xrange(im.shape[2]):
+ im[i,:,k] = np.linspace(0.,10.*k, im.shape[1])
+im_arr = ImageArray(im)
+
+# in this case you would have gotten im_arr from something like:
+# im_arr = cam.snapshot()
+
+# To save it with the default settings, we can just use write_png, where it
+# rescales the image and uses a black background.
+im_arr.write_png('standard.png')
+
+# write_png accepts a background keyword argument that defaults to 'black'.
+# Other choices include:
+# black (0.,0.,0.,1.)
+# white (1.,1.,1.,1.)
+# None (0.,0.,0.,0.) <-- Transparent!
+# any rgba list/array: [r,g,b,a], bounded by 0..1
+im_arr.write_png('black_bg.png', background='black')
+im_arr.write_png('white_bg.png', background='white')
+im_arr.write_png('green_bg.png', background=[0.,1.,0.,1.])
+im_arr.write_png('transparent_bg.png', background=None)
+
+
+
+
+
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/cookbook/rendering_with_box_and_grids.py
--- a/source/cookbook/rendering_with_box_and_grids.py
+++ b/source/cookbook/rendering_with_box_and_grids.py
@@ -47,11 +47,11 @@
im = cam.snapshot("%s_volume_rendered.png" % pf, clip_ratio=8.0)
# Add the domain edges, with an alpha blending of 0.3:
-cam.draw_domain(im, alpha=0.3)
-write_image(im, '%s_vr_domain.png' % pf)
+nim = cam.draw_domain(im, alpha=0.3)
+nim.write_png('%s_vr_domain.png' % pf)
# Add the grids, colored by the grid level with the algae colormap
-cam.draw_grids(im, alpha=0.3, cmap='algae')
-write_image(im, '%s_vr_grids.png' % pf)
+nim = cam.draw_grids(im, alpha=0.3, cmap='algae')
+nim.write_png('%s_vr_grids.png' % pf)
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/cookbook/simple_plots.rst
--- a/source/cookbook/simple_plots.rst
+++ b/source/cookbook/simple_plots.rst
@@ -103,3 +103,10 @@
.. yt_cookbook:: simple_volume_rendering.py
+Image Background Colors
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Here we see how to take an image and save it using different background colors.
+
+.. yt_cookbook:: image_background_colors.py
+
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/cookbook/simple_volume_rendering.py
--- a/source/cookbook/simple_volume_rendering.py
+++ b/source/cookbook/simple_volume_rendering.py
@@ -12,12 +12,12 @@
# Create a transfer function to map field values to colors.
# We bump up our minimum to cut out some of the background fluid
-tf = ColorTransferFunction((np.log10(mi)+2.0, np.log10(ma)))
+tf = ColorTransferFunction((np.log10(mi)+1, np.log10(ma)))
# Add three guassians, evenly spaced between the min and
# max specified above with widths of 0.02 and using the
# gist_stern colormap.
-tf.add_layers(3, w=0.02, colormap="gist_stern")
+tf.add_layers(5, w=0.02, colormap="spectral")
# Choose a center for the render.
c = [0.5, 0.5, 0.5]
diff -r 2bc0ca9761b86d84964955f5d080bd09932f879d -r 3101a9bd7702c315478af2901c896d8a77f722e0 source/visualizing/volume_rendering.rst
--- a/source/visualizing/volume_rendering.rst
+++ b/source/visualizing/volume_rendering.rst
@@ -39,51 +39,45 @@
Here is a working example for the IsolatedGalaxy dataset from the 2012 yt workshop.
.. code-block:: python
+ from yt.mods import *
- from yt.mods import *
-
- pf = load("galaxy0030/galaxy0030")
+ pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Choose a field
field = 'Density'
# Do you want the log of the field?
use_log = True
-
+
# Find the bounds in log space of for your field
dd = pf.h.all_data()
mi, ma = dd.quantities["Extrema"](field)[0]
-
+
if use_log:
mi,ma = np.log10(mi), np.log10(ma)
-
+
# Instantiate the ColorTransferfunction.
tf = ColorTransferFunction((mi, ma))
-
+
# Set up the camera parameters: center, looking direction, width, resolution
c = (pf.domain_right_edge + pf.domain_left_edge)/2.0
L = np.array([1.0, 1.0, 1.0])
W = 0.3 / pf["unitary"]
N = 256
-
+
# Create a camera object
cam = pf.h.camera(c, L, W, N, tf, fields = [field], log_fields = [use_log])
-
- # Set up the filename using pf and field.
- fn = "%s_%s_rendering.png" % (pf, field)
-
- # Now let's add some isocontours, and take a snapshot.
+
+ # Now let's add some isocontours, and take a snapshot, saving the image
+ # to a file.
tf.add_layers(10, 0.01, colormap = 'RdBu_r')
- im = cam.snapshot('test_rendering.png',clip_ratio=6.0)
-
- # Take a snapshot, saving the image to file fn.
- im = cam.snapshot(fn)
-
+ im = cam.snapshot('test_rendering.png')
+
# To add the domain box to the image:
- cam.draw_domain(im)
- write_bitmap(im, 'test_rendering_with_domain.png')
+ nim = cam.draw_domain(im)
+ nim.write_png('test_rendering_with_domain.png')
# To add the grid outlines to the image:
- cam.draw_grids(im)
- write_bitmap(im, 'test_rendering_with_grids.png')
+ nim = cam.draw_grids(im)
+ nim.write_png('test_rendering_with_grids.png')
Method
------
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
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