[yt-users] gradient field in yt3

Yuan Li yuan at astro.columbia.edu
Thu Aug 13 12:22:39 PDT 2015


Hi all:

I am having trouble creating a gradient field in yt3. What I want is the
gradient of logP, where logP is defined as:

@derived_field(name="logP",units="")
def _logP(field,data):
    return numpy.log(numpy.array(data["gas","pressure"]))

Then I add the gradient field:

pf.add_gradient_fields(("gas","logP"))

which seems to work and I can find it in pf.derived_field_list.

But if I try to use it, I get this error message:
yt.units.unit_object.UnitParseError: Cannot parse for unit data from '()'.
Please supply an expression of only Unit, Symbol, Pow, and Mulobjects.

Is this because logP does not have a unit?

Also, I had another unrelated question about the gradient fields:
Can I add the gradient fields globally instead of to a specific dataset?


Thanks!
Yuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150813/0e83262d/attachment.htm>


More information about the yt-users mailing list