[yt-users] yt-3.0 : derived fields in python notebooks
Elizabeth Tasker
tasker at astro1.sci.hokudai.ac.jp
Fri Nov 14 03:33:52 PST 2014
Hi,
I'm hitting a problem with deriving a field within a python notebook with
yt 3.0. I'm following:
http://yt-project.org/docs/3.0/quickstart/derived_fields_and_profiles.html
and have:
@derived_field(name = "thermenergy", units = "g * cm**2/s**2")
def _thermenergy(field, data):
return data[("gas", "cell_mass")]*data[("gas", "thermal_energy")]
but I get:
TypeError Traceback (most recent call last)
<ipython-input-30-55b30d60c209> in <module>()
----> 1 @derived_field(name = "thermenergy", units = "g * cm**2/s**2")
2 def _thermenergy(field, data):
3 return data[("gas", "cell_mass")]*data[("gas",
"thermal_energy")]
4
5 yt.add_field("thermenergy", function=_thermenergy,
units="gcm**2/s**2")
TypeError: 'NoneType' object is not callable
I don't get an error if I do:
def _thermenergy(field, data):
return data[("gas", "cell_mass")]*data[("gas", "thermal_energy")]
yt.add_field("thermenergy", function=_thermenergy, units="gcm**2/s**2")
but nor can I use the field:
ds = yt.load("DD0002/sbcool_0002")
dd = ds.all_data()
dd["thermenergy"]
YTFieldNotFound Traceback (most recent call last)
<ipython-input-33-c293394ac99f> in <module>()
1 ds = yt.load("DD0002/sbcool_0002")
2 dd = ds.all_data()
----> 3 dd["thermenergy"]
... what did I do wrong?
Elizabeth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141114/a1835167/attachment.htm>
More information about the yt-users
mailing list