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

Noel Scudder noel.scudder at stonybrook.edu
Wed Jul 10 12:04:22 PDT 2013


Hi Sam,

Great, this seemed to have worked. With a bit of tweaking, I'm able to
basically recreate my original rendering: http://i.imgur.com/D8z0oFg.png Thanks
for fixing this!

-Noel

On Wed, Jul 10, 2013 at 12:54 PM, Sam Skillman <samskillman at gmail.com>wrote:

> Hi Noel,
>
> Thanks for bringing this up.  I'm afraid I messed up (or really never had
> it right to begin with!) how rgba channels are blended when using
> grey_opacity=True renders.  I've posted a PR here:
> https://bitbucket.org/yt_analysis/yt/pull-request/553/fix-for-grey_opacity-grid-line-drawing/diffthat resolves this problem for me.  I don't expect it to take too long to
> be reviewed and pulled in to the main repository, but if you are in a hurry
> feel free to pull down the changes and test it out yourself. If you aren't
> familiar on how to do that, please let me know.
>
> Best,
> Sam
>
> BTW, very nice volume rendering!
>
>
> On Tue, Jul 9, 2013 at 4:53 PM, Noel Scudder <noel.scudder at stonybrook.edu>wrote:
>
>> 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
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130710/8957c502/attachment.html>


More information about the yt-users mailing list