[yt-users] Unexpected behavior with camera.draw_domain and camera.draw_grids

Noel Scudder noel.scudder at stonybrook.edu
Tue Jul 9 15:53:49 PDT 2013


Hi yt users,

I'm having a lot of trouble recreating a volume rendering I did a couple of
weeks ago. Specifically, when I try to add
a boundary box to my snapshot through draw_domain() or grids through
draw_grids(), the transfer function rendering fades very significantly,
regardless of alpha value, and it did not behave this way before.
However, it does not fade for cam.draw_box(... , ... , np.array([0.1, 0.1,
0.1, 0.2]) . Since draw_domain is basically just a call to draw_box, I took
a look in camera.py and did a bit of testing, and the only difference is
that the color array is np.array([1.0,1.0,1.0,alpha]) (where alpha=0.2) for
draw_domain, and that is what seemed to be causing so much fade in the case
of draw_domain. I didn't experience this problem before. Also, I don't know
much about how this color stuff works, but I was under the impression that
only the alpha value determined how bright the box is compared to the
rendering underneath. Furthermore, when I decrease the alpha value, the box
fades, but so does the rendering underneath, which should not be the case
(?).

I see the same behavior when doing draw_grids. Here is the image I created
a couple of weeks ago: http://i.imgur.com/R0uhz2D.png
And here is the image that the same script (very nearly) creates now:
http://i.imgur.com/xcTmCMC.png
The rendering underneath the grids is nearly invisible in the second one.
If I stack another draw_grids onto the image after this, for a different
level range, the rendering goes completely invisible, and the first set of
grids almost does-- again, even with alpha values of ~0.05.

For reference, here is the script I'm using:

-----------------------
from yt.mods import *
pf = load("plt_derr_perr_grav_00020")
field = "pressure"
[variable definitions, cut out for clarity]

pf.h
pf.field_info[field].take_log=True

tf = ColorTransferFunction((mi-1, ma+1), nbins=1.0e6)

tf.sample_colormap(np.log10(2.0e21), 0.006, col_bounds=[mi,ma],
                   alpha=[55.0], colormap="RdBu_r")

tf.add_layers(6, mi=di, ma=da,
              col_bounds=[pu,da],
              alpha=26*na.ones(6,dtype='float64'), colormap="RdBu_r")

[more layers, cut out for clarity]

tf.grey_opacity=True


c = [5.0e9, 5.0e9, 5.0e9]
L = [0.15, 1.0, 0.4]
W = (pf.domain_right_edge - pf.domain_left_edge)*1.25
Nvec = 768

cam = pf.h.camera(c, L, W, (Nvec,Nvec), transfer_function = tf,
                  fields=[field], pf=pf, no_ghost=False)
im = cam.snapshot(clip_ratio=6.0)


im.add_background_color('black', inline=True)
cam.draw_box(im, np.array([3.0e9, 4.0e9, 4.0e9]),
             np.array([7.0e9, 6.0e9, 6.0e9]), np.array([0.1, 0.1, 0.1,
0.2]))

nim = cam.draw_grids(im, alpha=0.08, min_level=1)

nim.write_png('v1.png')
-----------------------

Am I doing something wrong or missing something obvious? Was the behavior
of draw_grids and draw_domain changed with the new update? Thanks for your
help!

-Noel Scudder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130709/0a9b48b1/attachment.htm>


More information about the yt-users mailing list