<div dir="ltr">Hi Dave,<div><br></div><div>This is documented here:</div><div><br></div><div><a href="http://yt-project.org/doc/analyzing/units/comoving_units_and_code_units.html#The-unit-registry">http://yt-project.org/doc/analyzing/units/comoving_units_and_code_units.html#The-unit-registry</a><br></div><div><br></div><div>Since some units (e.g. "unitary", "code_length", or any other "code" unit) depend on knowledge about the dataset, we created two shortcuts, "ds.quan" and "ds.arr" to create YTQuantity instances (floats with units) and YTarray instances (numpy arrays with units) without needing to think about unit registries, which carry around all of the dataset-specific unit metadata.</div><div><br></div><div>This snippet:</div><div><br></div><div>    my_quan = ds.quan(3, 'code_length')</div><div><br></div><div>is 100% equivalent to:</div><div><br></div><div>    from yt import YTQuantity</div><div>    </div><div>    my_quan = YTQuantity(3, 'code_length', registry=ds.unit_registry)</div><div><br></div><div>You can see how the former is easier to read, although it's certainly a bit "magic". It *does* communicate that the unit "comes from" the dataset somehow, since you need a dataset instance to use it at all.</div><div><br></div><div>There's also ds.arr, which is similar to ds.quan, except it can work with array data, so you can do:</div><div><br></div><div>    my_arr = ds.arr([1, 2, 3], 'code_length')</div><div><br></div><div>Note that this song and dance is only necessary for units that depend on knowledge of a dataset. For physical units, you can always do something like:</div><div><br></div><div>    from yt.units import kpc</div><div><br></div><div>    three_kiloparsecs = 3*kpc</div><div><br></div><div>Hope that helps!</div><div><br></div><div>-Nathan</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 5, 2015 at 3:55 PM, Dave Semeraro <span dir="ltr"><<a href="mailto:semeraro@tacc.utexas.edu" target="_blank">semeraro@tacc.utexas.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal">Hey YT crowd,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">What does the quan method of a dataset do? If I have a dataset ds and I call ds.quan(0.1,’unitary’) (got that from an example somewhere) what does that return? I am tired of cutting and pasting from examples. I would like to know what I
 am doing for a change. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks, <u></u><u></u></p>
<p class="MsoNormal">Dave<u></u><u></u></p>
</div>
</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" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>