[yt-users] Confused about units in derived fields

Nathan Goldbaum nathan12343 at gmail.com
Thu Nov 20 18:36:02 PST 2014


Hi Jill,

On Thu, Nov 20, 2014 at 6:27 PM, Jill Naiman <jill.naiman at cfa.harvard.edu>
wrote:

> Hi all,
>
> As the title states, I am confused - specifically about units.  I want to
> create a derived field where parts of the field are different values,
> dependent upon some cutoff criteria like so:
>
> def _dene2(field,data):
>     tl = data['temperature']
>     dl = data['density']
>     print("TEMP")
>     print(tl.in_cgs())
>     aux = np.where(tl.in_cgs() > 5000.)
>     np.putmask(dl,aux, 0.0)
>     dene = dl
>     return dene
>
>
> ds.add_field("dene", units="g/cm**3", function = _dene2)
>
>
> Not only does this produce a very worrisome error:  "RuntimeError:
> Something has gone terribly wrong, _function is NullFunc for ('flash',
> 'temp')"
>

This happens when field detection fails badly.  I'm a bit surprised to see
it referencing a "temp" field - have you defined a "temp" field somewhere?


>
> The print statement in there shows a bunch of values close to 1, which is
> why the "aux" mask never returns anything.But why is data a bunch of 1's in
> here?  How do I access/convert to the "real" units?
>

yt's field detection algorithm will feed a field fake data that is close to
1 to see if there are errors in the field definition.  The values close to
1 you are seeing almost certainly come from field detection.  If the field
validates correctly, real data will eventually be passed in.

Is there any chance you can reproduce this issue using one of the test
datasets on yt-project.org/data?  If so, can you pastebin a script that
causes the error you're seeing?  That should make it much easier to
reproduce and figure out exactly what's going wrong.

-Nathan


>
> Any help is appreciated,
> -Jill
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141120/811d9352/attachment.html>


More information about the yt-users mailing list