<div dir="ltr">Hooray! Thank you.</div><div class="gmail_extra"><br><div class="gmail_quote">On 14 November 2014 23:14, Britton Smith <span dir="ltr"><<a href="mailto:brittonsmith@gmail.com" target="_blank">brittonsmith@gmail.com</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">Hi Elizabeth,<div><br></div><div>I don't know whether that syntax works anymore, but the following should: have your field function without the @derived_field decorator, and then, after ds = yt.load(...), do ds.add_field("thermalenergy", function=..., units=...)</div><div><br></div><div>Britton</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Nov 14, 2014 at 11:33 AM, Elizabeth Tasker <span dir="ltr"><<a href="mailto:tasker@astro1.sci.hokudai.ac.jp" target="_blank">tasker@astro1.sci.hokudai.ac.jp</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 class="h5"><div dir="ltr">Hi,<div><br></div><div>I'm hitting a problem with deriving a field within a python notebook with yt 3.0. I'm following:</div><div><br></div><div> <a href="http://yt-project.org/docs/3.0/quickstart/derived_fields_and_profiles.html" target="_blank">http://yt-project.org/docs/3.0/quickstart/derived_fields_and_profiles.html</a><br></div><div><br></div><div>and have:</div><div><br></div><div><div>@derived_field(name = "thermenergy", units = "g * cm**2/s**2")</div><div>def _thermenergy(field, data):</div><div>    return data[("gas", "cell_mass")]*data[("gas", "thermal_energy")]</div><div><br></div></div><div><br></div><div>but I get:</div><div><br></div><div><div>TypeError                                 Traceback (most recent call last)</div><div><ipython-input-30-55b30d60c209> in <module>()</div><div>----> 1 @derived_field(name = "thermenergy", units = "g * cm**2/s**2")</div><div>      2 def _thermenergy(field, data):</div><div>      3     return data[("gas", "cell_mass")]*data[("gas", "thermal_energy")]</div><div>      4 </div><div>      5 yt.add_field("thermenergy", function=_thermenergy, units="gcm**2/s**2")</div><div><br></div><div>TypeError: 'NoneType' object is not callable</div></div><div><br></div><div><br></div><div>I don't get an error if I do:</div><div><br></div><div><div>def _thermenergy(field, data):</div><div>    return data[("gas", "cell_mass")]*data[("gas", "thermal_energy")]</div><div><br></div><div>yt.add_field("thermenergy", function=_thermenergy, units="gcm**2/s**2")</div></div><div><br></div><div>but nor can I use the field:</div><div><br></div><div><div>ds = yt.load("DD0002/sbcool_0002")</div><div>dd = ds.all_data()</div><div>dd["thermenergy"]</div></div><div><br></div><div><br></div><div><div>YTFieldNotFound                           Traceback (most recent call last)</div><div><ipython-input-33-c293394ac99f> in <module>()</div><div>      1 ds = yt.load("DD0002/sbcool_0002")</div><div>      2 dd = ds.all_data()</div><div>----> 3 dd["thermenergy"]</div></div><div><br></div><div><br></div><div>... what did I do wrong?</div><span><font color="#888888"><div><br></div><div>Elizabeth</div></font></span></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">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>