<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 29, 2014 at 3:27 PM, Sean Couch <span dir="ltr"><<a href="mailto:smc@tapir.caltech.edu" target="_blank">smc@tapir.caltech.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Nathan,<div><br></div><div>Thanks!  That seems to have fixed the units problem, but another has cropped up.  I’m guessing this is related to draw_lines not being fully updated to yt 3.0:</div><div><br></div><div><span><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">Traceback (most recent call last):</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "render_radv.py", line 53, in <module></div></span><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    cam.draw_line(im, [2e8,0.,0.]*ds.length_unit, [0.,2e8,0.]*ds.length_unit)</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "/work/00863/smc/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/camera.py", line 426, in draw_lin\</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">e</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    lines(im, np.array([px0,px1]), np.array([py0,py1]), color=np.array([color,color]),flip=1)</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "misc_utilities.pyx", line 215, in yt.utilities.lib.misc_utilities.lines (yt/utilities/lib/misc_utilitie\</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">s.c:4877)</div></div><div><br></div></div></blockquote><div><br></div><div>Yeah, it looks like it's not calling the lines() function correctly. I was able to reproduce this on my laptop and have issued a pull request to fix it, along with the issue you originally noticed with the draw_line function.  The reason why this was never updated is that there aren't any tests for this function. To head off breakage in the future, I've also added a quick test for these functions.</div><div><br></div><div><a href="https://bitbucket.org/yt_analysis/yt/pull-request/1380/fixing-issues-with-the-draw_line-function/diff">https://bitbucket.org/yt_analysis/yt/pull-request/1380/fixing-issues-with-the-draw_line-function/diff</a><br></div><div><br></div><div>You can test that locally by pulling in the changes to your local copy of the yt mercurial repository:</div><div><br></div><div>$ hg pull -r 2596e9f <a href="https://bitbucket.org/ngoldbaum/yt">https://bitbucket.org/ngoldbaum/yt</a></div><div>$ hg update 2596e9f</div><div>$ python setup.py develop</div><div><br></div><div>You might see an error on the hg update step if you've made local changes.  You can save any local changes you've made with "hg shelve" or just delete them with "hg update -C  2596e9f".</div><div><br></div><div>If you could leave a comment saying whether or not this fixes your issue on the pull request, that would be great.</div><div><br></div><div>-Nathan</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div><div>I’m looking into the source code now, but I thought you might have an idea straightaway.</div><span><font color="#888888"><div><br></div><div>Sean</div></font></span><div><div><div><br></div><div><br><div><blockquote type="cite"><div>On Dec 29, 2014, at 2:22 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Hi Sean,<div><br></div><div>Can you try again with:</div><div><br></div><div><span style="color:rgb(245,245,245);font-family:Monaco;font-size:14px;background-color:rgb(0,0,0)">cam.draw_line(im, [2e8,0.,0.]*ds.length_unit, [0.,2e8,0.]*ds.length_unit)</span><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">It looks like this function was never properly updated for yt-3.0.  What's happening is that the camera's origin vector is a YTArray, but the second and third argument of the draw_line function are specified in that function's docstrings as ndarrays.  When the draw_line function tries to compute the difference between camera.origin and [2e8, 0, 0], it throws a unit error (as it should) since camera.origin has units of code_length (which is the same as centimeters for your FLASH simulation), but x0 is unitless. </div><div class="gmail_extra"><br></div><div class="gmail_extra">We should probably add some code to the draw_line function so that if a user passes in a list or ndarray rather than a YTArray, we cast x0 and x1 to be YTArrays in code_length units.  This would be a super simple initial contribution to yt, if you're up for it.</div><div class="gmail_extra"><br></div><div class="gmail_extra">-Nathan</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 29, 2014 at 2:07 PM, Sean Couch <span dir="ltr"><<a href="mailto:smc@tapir.caltech.edu" target="_blank">smc@tapir.caltech.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Hi yt-users,<div><br></div><div>Newb question:  I’m trying to draw a line on my volume render of some FLASH data using camera.draw_line but I’m getting an error.  My guess is that it is something to do with units, but I can’t figure out how to fix what I’m doing.  I’m assuming that draw_line using code units, which for FLASH should be cgs.  Here is my code snippet:</div><div><br></div><div><br></div><div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"><span style="color:rgb(199,156,36)">cam</span> = ds.camera(c, L, W, N, transfer_function=tf, ds=ds, no_ghost=<span style="color:rgb(208,60,255)">True</span>,</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">                fields=field, log_fields=[<span style="color:rgb(208,60,255)">False</span>])</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)"><span style="color:rgb(199,156,36)">im</span> = cam.snapshot()</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);min-height:19px;background-color:rgb(0,0,0)"><br></div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">cam.draw_coordinate_vectors(im)</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">cam.draw_domain(im)</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">cam.draw_line(im, [2e8,0.,0.], [0.,2e8,0.])</div></div><div><br></div><div>And here is the error I get when I run it:</div><div><br></div><div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">Traceback (most recent call last):</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "render_radv.py", line 53, in <module></div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    cam.draw_line(im, [2e8,0.,0.], [0.,2e8,0.])</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "/work/00863/smc/yt-x86_64/src/yt-hg/yt/visualization/volume_rendering/camera.py", line 415, in draw_lin\</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">e</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    dx0 = ((x0-self.origin)*self.orienter.unit_vectors[1]).sum()</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "/work/00863/smc/yt-x86_64/src/yt-hg/yt/units/yt_array.py", line 716, in __rsub__</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    lo = sanitize_units_add(self, left_object, "subtraction")</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">  File "/work/00863/smc/yt-x86_64/src/yt-hg/yt/units/yt_array.py", line 134, in sanitize_units_add</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">    raise YTUnitOperationError(op_string, inp.units, dimensionless)</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">yt.utilities.exceptions.YTUnitOperationError: The subtraction operator for YTArrays with units (code_length) an\</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)">d (1) is not well defined.</div></div><div><br></div><div>Any help or guidance would be much appreciated!</div><div><br></div><div>Thanks,</div><div>Sean</div><div><br></div><br><br><div>
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">-----------------------------------------------------------<br>Sean M. Couch<br>Theoretical Astrophysics Including Relativity<br>California Institute of Technology<br>Mail Code 350-17<br>Pasadena, CA  91125<br><a href="tel:%28626%29%20395-4282" value="+16263954282" target="_blank">(626) 395-4282</a><br><a href="http://www.tapir.caltech.edu/~smc" target="_blank">www.tapir.caltech.edu/~smc</a></div></div>
</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><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></div></blockquote></div><br></div></div></div></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><br></div></div>