[yt-users] volume rendering handedness
Nathan Goldbaum
nathan12343 at gmail.com
Tue Jul 22 10:41:44 PDT 2014
On Tue, Jul 22, 2014 at 10:39 AM, Cameron Hummels <chummels at gmail.com>
wrote:
> I do know that the off_axis_projection() stuff still yields different
> results than the PlotWindow interface, as is best shown here in the docs:
>
>
> http://yt-project.org/docs/dev-3.0/visualizing/plots.html#off-axis-projection-plots
>
> Is this a known bug, or is this just a matter of tweaking something in the
> off_axis_projection function?
>
Likely a tweak is needed at the level of the volume renderer. This is
almost certainly related to what Mike is seeing.
> I saw that not all of the Righthandedness trello post had been resolved,
> but wasn't sure if this was related or not.
>
>
Definitely related.
>
>
> On Tue, Jul 22, 2014 at 10:07 AM, Michael Zingale <
> michael.zingale at stonybrook.edu> wrote:
>
>> I'll look deeper -- thanks for the pointer. I created this test dataset
>> specifically to make it easier to look at handedness. There are a few
>> quirks that may be related to all of this (such as the
>> draw_coordinate_vectors stuff) that I will also try to hunt down.
>>
>>
>> On Tue, Jul 22, 2014 at 12:37 PM, Nathan Goldbaum <nathan12343 at gmail.com>
>> wrote:
>>
>>> Hi Mike,
>>>
>>> At this point, if yt isn't using a right-handed coordinate system
>>> somewhere, it's a bug.
>>>
>>> If I remember correctly, save_annotated does a transpose on the image
>>> before saving it to disk - that might be the source of one of your
>>> workarounds?
>>>
>>> The orientation of volume rendering cameras is controlled via the
>>> Orientation class. You might want to poke around in there to see what it
>>> does - it might be the source of the left-handedness.
>>>
>>> I don't think anyone has gone through in detail to make sure the volume
>>> rendering orientation is consistent in all cases. It would be a major help
>>> to do that.
>>>
>>> -Nathan
>>>
>>>
>>> On Tue, Jul 22, 2014 at 9:00 AM, Michael Zingale <
>>> michael.zingale at stonybrook.edu> wrote:
>>>
>>>> I've been having trouble understanding the parameters that specify the
>>>> orientation of the camera for volume rendering. To help, I made a test
>>>> dataset. On [-1,1]^3, there is a sphere at the origin, a single cube on
>>>> the +x axis, two cubes on the +y axis, and three cubes on the +z axis.
>>>> When I do a simple volume-render, I see this:
>>>>
>>>> http://bender.astro.sunysb.edu/random/yt-test.png
>>>>
>>>> Note that it looks left-handed.
>>>>
>>>> I've attached my script. There are a few hacks that I needed to do
>>>> that I don't completely understand. In particular, if I turn on the
>>>> coordinate_vectors, the image is blank. I've seen this a lot. Also, I had
>>>> to make the north vector negative of what I would think.
>>>>
>>>> Mike
>>>>
>>>> --
>>>>
>>>> #!/usr/bin/env python
>>>>
>>>> import matplotlib
>>>> matplotlib.use('agg')
>>>>
>>>> # this example comes from
>>>> # http://yt-project.org/doc/visualizing/volume_rendering.html
>>>>
>>>> import math
>>>> import sys
>>>> import pylab
>>>>
>>>> from yt.mods import *
>>>> import yt.visualization.volume_rendering.api as vr
>>>>
>>>> def doit(plotfile):
>>>>
>>>> ds = load(plotfile)
>>>>
>>>> cm = "gist_rainbow"
>>>>
>>>>
>>>> field = ('gas', 'density')
>>>> use_log = False
>>>> vals = [0.1, 1]
>>>> sigma = 0.1
>>>>
>>>> dd = ds.h.all_data()
>>>>
>>>> ds.field_info[field].take_log = use_log
>>>>
>>>>
>>>> mi = min(vals)
>>>> ma = max(vals)
>>>>
>>>> if use_log:
>>>> mi, ma = np.log10(mi), np.log10(ma)
>>>>
>>>>
>>>> # Instantiate the ColorTransferfunction.
>>>> tf = vr.ColorTransferFunction((mi, ma))
>>>>
>>>> # Set up the camera parameters: center, looking direction, width,
>>>> resolution
>>>> c = np.array([0.0, 0.0, 0.0])
>>>> L = np.array([1.0, 1.0, 1.0])
>>>> L = np.array([1.0, 1.0, 1.2])
>>>> W = 1.5*ds.domain_width
>>>> N = 720
>>>>
>>>> north=[0.0,0.0,-1.0]
>>>>
>>>> for v in vals:
>>>> if (use_log):
>>>> tf.sample_colormap(math.log10(v), sigma**2, colormap=cm) #,
>>>> alpha=0.2)
>>>> else:
>>>> tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2)
>>>>
>>>>
>>>> # alternate attempt
>>>> ds.periodicity = (True, True, True)
>>>>
>>>> # Create a camera object
>>>> cam = vr.Camera(c, L, W, N, transfer_function=tf, ds=ds,
>>>> no_ghost=False, #data_source=reg,
>>>> north_vector=north,
>>>> fields = [field], log_fields = [use_log])
>>>>
>>>> #cam.rotate(3.0*np.pi/2., rot_vector=rot_vector)
>>>>
>>>>
>>>> # make an image
>>>> im = cam.snapshot()
>>>>
>>>>
>>>> # add an axes triad -- note if we do this, we HAVE to do draw
>>>> # domain, otherwise the image is blank (likely a bug)
>>>> #cam.draw_coordinate_vectors(im)
>>>>
>>>> # add the domain box to the image:
>>>> nim = cam.draw_domain(im)
>>>>
>>>> # increase the contrast -- for some reason, the enhance default
>>>> # to save_annotated doesn't do the trick (likely a bug)
>>>> max_val = im[:,:,:3].std() * 4.0
>>>> nim[:,:,:3] /= max_val
>>>>
>>>> f = pylab.figure()
>>>>
>>>> pylab.text(0.2, 0.85, "{:.3g} s".format(float(ds.current_time.d)),
>>>> transform=f.transFigure, color="white")
>>>>
>>>> cam._render_figure = f
>>>>
>>>> # save annotated -- this added the transfer function values,
>>>> # but this messes up our image size defined above
>>>> cam.save_annotated("yt-test.png", nim,
>>>> dpi=145, clear_fig=False)
>>>>
>>>>
>>>>
>>>> if __name__ == "__main__":
>>>>
>>>> # Choose a field
>>>> plotfile = ""
>>>>
>>>>
>>>> try: plotfile = sys.argv[1]
>>>> except: sys.exit("ERROR: no plotfile specified")
>>>>
>>>> doit(plotfile)
>>>>
>>>>
>>>>
>>>> --
>>>> Michael Zingale
>>>> Associate Professor
>>>>
>>>> Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY
>>>> 11794-3800
>>>> *phone*: 631-632-8225
>>>> *e-mail*: Michael.Zingale at stonybrook.edu
>>>> *web*: http://www.astro.sunysb.edu/mzingale
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>>
>>
>>
>> --
>> Michael Zingale
>> Associate Professor
>>
>> Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY
>> 11794-3800
>> *phone*: 631-632-8225
>> *e-mail*: Michael.Zingale at stonybrook.edu
>> *web*: http://www.astro.sunysb.edu/mzingale
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
>
> --
> Cameron Hummels
> Postdoctoral Researcher
> Steward Observatory
> University of Arizona
> http://chummels.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/20140722/755203fa/attachment.htm>
More information about the yt-users
mailing list