<div dir="ltr">ok, the following change makes things good for me, but I'd like others to comment.<div><br></div><div>in camera.py: show_mpl, I change the </div><div><br></div><div>origin='upper'</div><div><br></div>
<div>to </div><div><br></div><div>origin='lower'</div><div><br></div><div>then I set the north vector as my intuition suggests, (0,0,1) to be +z, and the plot has the right orientation and handedness.</div><div><br>
</div><div>(There is a separate issues still the sometimes using draw_coordinate_vector() erases the image, but when I can get it to show, it has the right handedness too).  Here's another plot from actual data (uploaded to the yt data page) showing things that look right to me:</div>
<div><br></div><div><a href="http://bender.astro.sunysb.edu/random/xrb_vol_radvel.png">http://bender.astro.sunysb.edu/random/xrb_vol_radvel.png</a><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Jul 22, 2014 at 3:50 PM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">so that swapaxes(0,1) in save_annotated is needed -- otherwise the plot is sideways.  Looks like we need a flip as well though.</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="">On Tue, Jul 22, 2014 at 12:37 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span> wrote:<br>

</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Mike,<div><br></div><div>At this point, if yt isn't using a right-handed coordinate system somewhere, it's a bug.</div>

<div><br></div><div>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?</div>

<div><br></div><div>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.</div><div>



<br></div><div>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.</div><div><br></div><div>-Nathan</div></div>



<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Tue, Jul 22, 2014 at 9:00 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">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:<div>




<br></div><div><a href="http://bender.astro.sunysb.edu/random/yt-test.png" target="_blank">http://bender.astro.sunysb.edu/random/yt-test.png</a><br></div><div><br></div><div>Note that it looks left-handed.</div><div><br>



</div><div>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.</div>




<div><br></div><div>Mike<br clear="all"><div><br></div><div>--</div><div><br></div><div><div>#!/usr/bin/env python</div><div><br></div><div>import matplotlib</div><div>matplotlib.use('agg')</div><div><br></div><div>




# this example comes from </div><div># <a href="http://yt-project.org/doc/visualizing/volume_rendering.html" target="_blank">http://yt-project.org/doc/visualizing/volume_rendering.html</a></div><div><br></div><div>import math</div>



<div>import sys</div>
<div>import pylab</div><div><br></div><div>from yt.mods import *</div><div>import yt.visualization.volume_rendering.api as vr</div><div><br></div><div>def doit(plotfile):</div><div><br></div><div>    ds = load(plotfile)</div>




<div><br></div><div>    cm = "gist_rainbow"</div><div><br></div><div><br></div><div>    field = ('gas', 'density')</div><div>    use_log = False</div><div>    vals = [0.1, 1]</div><div>    sigma = 0.1</div>




<div><br></div><div>    dd = ds.h.all_data()</div><div><br></div><div>    ds.field_info[field].take_log = use_log</div><div><br></div><div><br></div><div>    mi = min(vals)</div><div>    ma = max(vals)</div><div>    </div>




<div>    if use_log:</div><div>        mi, ma = np.log10(mi), np.log10(ma)</div><div>        </div><div><br></div><div>    # Instantiate the ColorTransferfunction.</div><div>    tf =  vr.ColorTransferFunction((mi, ma))</div>




<div><br></div><div>    # Set up the camera parameters: center, looking direction, width, resolution</div><div>    c = np.array([0.0, 0.0, 0.0])</div><div>    L = np.array([1.0, 1.0, 1.0])</div><div>    L = np.array([1.0, 1.0, 1.2])</div>




<div>    W = 1.5*ds.domain_width</div><div>    N = 720</div><div><br></div><div>    north=[0.0,0.0,-1.0]</div><div><br></div><div>    for v in vals:</div><div>        if (use_log):</div><div>            tf.sample_colormap(math.log10(v), sigma**2, colormap=cm) #, alpha=0.2)</div>




<div>        else:</div><div>            tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2)</div><div><br></div><div><br></div><div>    # alternate attempt</div><div>    ds.periodicity = (True, True, True)</div><div>




<br></div><div>    # Create a camera object</div><div>    cam = vr.Camera(c, L, W, N, transfer_function=tf, ds=ds, </div><div>                    no_ghost=False, #data_source=reg,</div><div>                    north_vector=north,</div>




<div>                    fields = [field], log_fields = [use_log])</div><div><br></div><div>    #cam.rotate(3.0*np.pi/2., rot_vector=rot_vector)</div><div><br></div><div><br></div><div>    # make an image</div><div>    im = cam.snapshot()</div>




<div><br></div><div><br></div><div>    # add an axes triad -- note if we do this, we HAVE to do draw</div><div>    # domain, otherwise the image is blank (likely a bug)</div><div>    #cam.draw_coordinate_vectors(im)</div>




<div><br></div><div>    # add the domain box to the image:</div><div>    nim = cam.draw_domain(im)</div><div><br></div><div>    # increase the contrast -- for some reason, the enhance default</div><div>    # to save_annotated doesn't do the trick (likely a bug)</div>




<div>    max_val = im[:,:,:3].std() * 4.0</div><div>    nim[:,:,:3] /= max_val</div><div><br></div><div>    f = pylab.figure()</div><div><br></div><div>    pylab.text(0.2, 0.85, "{:.3g} s".format(float(ds.current_time.d)),</div>




<div>               transform=f.transFigure, color="white")</div><div><br></div><div>    cam._render_figure = f</div><div>    </div><div>    # save annotated -- this added the transfer function values, </div><div>




    # but this messes up our image size defined above</div><div>    cam.save_annotated("yt-test.png", nim, </div><div>                       dpi=145, clear_fig=False)</div><div><br></div><div><br></div><div><br>




</div><div>if __name__ == "__main__":</div><div><br></div><div>    # Choose a field</div><div>    plotfile = ""</div><div><br></div><div><br></div><div>    try: plotfile = sys.argv[1]</div><div>    except: sys.exit("ERROR: no plotfile specified")</div>




<div><br></div><div>    doit(plotfile)</div><span><font color="#888888"><div><br></div><div><br></div></font></span></div><span><font color="#888888"><div><br></div>-- <br><div>Michael Zingale</div>

<div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>
<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>



<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</font></span></div></div>
<br></div></div>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>

<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>
<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>
<div><i>phone</i>:  631-632-8225</div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div><div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>