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

Antoine Strugarek strugarek at ASTRO.UMontreal.CA
Thu Aug 7 09:10:54 PDT 2014


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']

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.

I must be missing something here but I really don’t get it. Many thanks in advance for your help!

Antoine


Antoine STRUGAREK
-------------------------------------------------------------------
Webpage 
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
--------------------------------------------------------------------







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140807/a4ffd794/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data.0000.hdf5_Slice_z_VRA.png
Type: image/png
Size: 116805 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140807/a4ffd794/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data.0000.hdf5_Slice_z_VRB.png
Type: image/png
Size: 184007 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140807/a4ffd794/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data.0000.hdf5_Slice_z_VVR.png
Type: image/png
Size: 173702 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20140807/a4ffd794/attachment-0002.png>


More information about the yt-users mailing list