[yt-users] troubles with derived field: 1+1 is not equal to 2

Nathan Goldbaum nathan12343 at gmail.com
Thu Aug 7 10:07:59 PDT 2014


Hi Antoine,

I'm not sure what's going wrong here.  I have a few ideas below.  If the
dataset is small enough it would probably help if you could share it using
e.g. dropbox or google drive along with your full analysis script.
Alternately, can you reproduce the issue using one of the public datasets
on yt-project.org/data?


On Thu, Aug 7, 2014 at 9:10 AM, Antoine Strugarek <
strugarek at astro.umontreal.ca> wrote:

> Hello,
>
> I’m new to yt so this maybe solved easily, though it puzzled me for quite
> some time and I still don’t understand what is going on.
>
> I try to create derived fields to analyze a simulation using AMR, from an
> output from CHOMBO. I define the following derived fields:
>
> def _VRA(field,data):
>     return  data['Cylsin']*data['Vx2']
> def _VRB(field,data):
>     return  data['Cylcos']*data['Vx1']
> def _VVR(field,data):
>     return  data['VRA']+data['VRB']
>

Are 'Cylsin' and 'Cylcos' on-disk fields or are they derived fields as
well?  If so, can you share their definitions?


>
> Then I add them to my yt object:
>
>     ds=yt.load(file)
>
>     ds.index
>     ds.add_field(('chombo','VRA'),function=_VRA,units='cm/s',take_log=
> False)
>     ds.add_field(('chombo','VRB'),function=_VRB,units='cm/s',take_log=
> False)
>     ds.add_field(('chombo','VVR'),function=_VVR,units='cm/s',take_log=
> False)
>
>
> and everything goes on smoothly (they are the only variables named this
> way). Now, If I try to slice VRA and VRB I obtain the (correct) attached
> plots. Both VRA and VRB are strictly positive. If I try to slice VVR which
> is the sum VRA+VRB, I obtained the third attached plot which does not
> correspond to the expected sum (there are even negative values)! I suspect
> something went odd in the slice function, but I used the exact same lines
> of code to generate the three plots.
>

What happens if instead of passing in the field tuple ('chombo', 'VRA'),
you instead pass in 'VRA' or ('gas', 'VRA').  Saying the field type is
'chombo' for a derived field doesn't really make much sense.  For a chombo
dataset, a 'chombo' field must be on-disk and is always in code units.  By
creating a derived field with explicit CGS units you might be confusing
yt's field system.



>
> I must be missing something here but I really don’t get it. Many thanks in
> advance for your help!
>
> Antoine
>
>
>   Antoine STRUGAREK
> -------------------------------------------------------------------
> Webpage
> <https://googledrive.com/host/0BxBaqwiaesNkcDBWcUFCdmMxSUU/strugarek.html>
>
> Département de physique, Université de Montréal
> strugarek at astro.umontreal.ca
> (+1) 514 343 7077
> --------------------------------------------------------------------
> DSM/IRFU/SAp/LDEE CEA Saclay
> DSM/IRFM/SCCP CEA Cadarache
> antoine.strugarek at cea.fr
> --------------------------------------------------------------------
>
>
>
>
>
>
>
>
> _______________________________________________
> 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/20140807/38174cb5/attachment.html>


More information about the yt-users mailing list