[yt-users] How to re-process a scene?

Nathan Goldbaum nathan12343 at gmail.com
Thu Sep 15 18:57:55 PDT 2016


Hi Scott,

So this is really two issues.

The first, is that the camera.zoom() function doesn't really zoom in on the
image, instead it decreases the "width" the volume rendering region by the
zoom factor. This makes a lot of sense for plane-parallel volume renderings
(the default), but not so much for perspective lenses as you saw. For a
perspective lens you should instead reposition the camera to be closer to
the focus to get the same effect.

Next, you also saw that manipulating the TransferFunctionHelper object
(source.tfh) after you've already done a volume rendering doesn't update
the transfer function. That's because the TransferFunctionHelper object is
only used to generate the transfer function (source.transfer_function) if
it isn't set yet. If it's already set, it reuses it. So in your example the
first time you called save(), the VolumeSource saw that no one had manually
created a transfer function, and used the TransferFunctionHelper object to
build one. Then, when you asked it for the second rendering, it just reused
the same one because right now the VolumeSource doesn't track if the
TransferFunctionHelper has been updated. To do what you mean, you need to
manually set the transfer function to be the one generated by the
TransferFunctionHelper:

source.tfh.build_transfer_function()
source.tfh.setup_default()
source.transfer_function = source.tfh.tf

After manipulating source.tfh.

Using as an example the script from the docs, here's how to make the second
image come out as you would expect for the perspective lens:

http://paste.yt-project.org/show/6823/

Which makes these two images:

http://i.imgur.com/gwUTWz1.png (rendering.png)
http://i.imgur.com/M1lSz0N.png (rendering2.png)

I think we could probably do a better job of detecting that the
TransferFunctionHelper has been manipulated and avoid this confusion, if
you'd like I invite you to open an issue about this on our issue tracker.
One might also argue that the zoom function should adjust the camera
position for perspective lenses.

Sorry the volume renderer isn't totally intuitive for this use case. I did
some work before the yt 3.3.1 release to improve things, but it's still
definitely not perfect. I think there's a lot of power there but it also
really needs some love from someone who is willing to think about corner
cases and interactive workflows.

-Nathan

On Thu, Sep 15, 2016 at 7:38 PM, Scott Feister <sfeister at gmail.com> wrote:

> Hi yt users,
>
> Hi there! I'm just starting to use yt to make volume renderings of FLASH
> simulations. While working through examples, I hit a roadblock, and I've
> had some difficulty finding good documentation on the what the
> "Scene.save()" function actually does; specifically, why it does different
> things on the first and second call. The first example in the user tutorial
> page for 3D volume rendering (http://yt-project.org/doc/
> visualizing/volume_rendering.html) looks something like this:
>
> ...
> *sc = yt.create_scene(ds, lens_type='perspective')*
> ...
> *source = sc[0]*
> *source.tfh.set_bounds((3e-31, 5e-27))*
> *...*
>
> *sc.save('rendering.png', sigma_clip=6.0)*
>
> And, voila, volume rendering saved to png.
>
> However, if I naively continue the script to re-render with new settings:
> *source.tfh.set_bounds((3e-35, 5e-27))*
> *sc.camera.zoom(2.0)*
>
> *sc.save('rendering2.png', sigma_clip=6.0)*
>
> I find that none of my new settings are reflected in "rendering2.png" --
> it's just a duplicate of "rendering.png"! But if I start again from scratch
> with a new scene, the settings take hold. This leaves me (a new user)
> scratching my head.
>
> So here is my question: Once you've created and saved a scene once, how do
> you change scene settings like colormap and camera angle?
>
> Best,
>
> Scott
>
>
> Scott Feister, Ph.D.
> Postdoctoral Researcher, Flash Center for Computational Science
> University of Chicago, Department of Astronomy and Astrophysics
>
> _______________________________________________
> 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/20160915/1eeb5a48/attachment.htm>


More information about the yt-users mailing list