<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Nathan,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; font-family: Monaco; color: rgb(245, 245, 245); background-color: rgb(0, 0, 0);" class="">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);" class="">  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);" class="">    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);" class="">  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);" class="">e</div><div style="margin: 0px; font-size: 14px; font-family: Monaco; color: rgb(245, 245, 245); background-color: rgb(0, 0, 0);" class="">    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);" class="">  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);" class="">s.c:4877)</div></div><div class=""><br class=""></div><div class="">I’m looking into the source code now, but I thought you might have an idea straightaway.</div><div class=""><br class=""></div><div class="">Sean</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 29, 2014, at 2:22 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" class="">nathan12343@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Sean,<div class=""><br class=""></div><div class="">Can you try again with:</div><div class=""><br class=""></div><div class=""><span style="color:rgb(245,245,245);font-family:Monaco;font-size:14px;background-color:rgb(0,0,0)" class="">cam.draw_line(im, [2e8,0.,0.]*ds.length_unit, [0.,2e8,0.]*ds.length_unit)</span><br class=""></div><div class="gmail_extra"><br class=""></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 class=""></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 class=""></div><div class="gmail_extra">-Nathan</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 29, 2014 at 2:07 PM, Sean Couch <span dir="ltr" class=""><<a href="mailto:smc@tapir.caltech.edu" target="_blank" class="">smc@tapir.caltech.edu</a>></span> wrote:<br class=""><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" class="">Hi yt-users,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class=""><span style="color:rgb(199,156,36)" class="">cam</span> = ds.camera(c, L, W, N, transfer_function=tf, ds=ds, no_ghost=<span style="color:rgb(208,60,255)" class="">True</span>,</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class="">                fields=field, log_fields=[<span style="color:rgb(208,60,255)" class="">False</span>])</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class=""><span style="color:rgb(199,156,36)" class="">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)" class=""><br class=""></div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class="">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)" class="">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)" class="">cam.draw_line(im, [2e8,0.,0.], [0.,2e8,0.])</div></div><div class=""><br class=""></div><div class="">And here is the error I get when I run it:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class="">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)" class="">  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)" class="">    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)" class="">  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)" class="">e</div><div style="margin:0px;font-size:14px;font-family:Monaco;color:rgb(245,245,245);background-color:rgb(0,0,0)" class="">    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)" class="">  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)" class="">    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)" class="">  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)" class="">    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)" class="">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)" class="">d (1) is not well defined.</div></div><div class=""><br class=""></div><div class="">Any help or guidance would be much appreciated!</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Sean</div><div class=""><br class=""></div><br class=""><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class="">-----------------------------------------------------------<br class="">Sean M. Couch<br class="">Theoretical Astrophysics Including Relativity<br class="">California Institute of Technology<br class="">Mail Code 350-17<br class="">Pasadena, CA  91125<br class=""><a href="tel:%28626%29%20395-4282" value="+16263954282" target="_blank" class="">(626) 395-4282</a><br class=""><a href="http://www.tapir.caltech.edu/~smc" target="_blank" class="">www.tapir.caltech.edu/~smc</a></div></div>
</div>
<br class=""></div><br class="">_______________________________________________<br class="">
yt-users mailing list<br class="">
<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br class=""></div></blockquote></div><br class=""></div></body></html>