<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><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="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);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">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>