[yt-users] bug in ortho_ray and derived fields?

Michael Kuhlen mqk at astro.berkeley.edu
Fri Apr 16 13:28:35 PDT 2010


Hi

I'm experiencing some weird behavior with ortho_ray() when used with
derived fields. I suspect this is a bug, but I'm new to yt, so maybe I'm
doing something incorrectly.

This is for a 1D Enzo simulation, and the only fields in the simulation
dataset are Density, x-velocity, and TotalEnergy. I defined two derived
fields, InternalEnergy and Pressure:

### define InternalEnergy field
def _InternalEnergy(field, data):
    return data['TotalEnergy'] - 0.5*data['x-velocity']*data['x-velocity']

add_field('InternalEnergy', function=_InternalEnergy,
units=r'\rm{erg}/\rm{g}')

### define Pressure field
def _Pressure(field, data):
    return (data.pf['Gamma'] - 1.0) * data['Density'] *
data['InternalEnergy']

add_field('Pressure', function=_Pressure, units=r'\rm{dyne}/\rm{cm}^{2}')


Next I want to extract a ray of Density, x-velocity, Pressure, and
InternalEnergy along the only dimension. I figured ortho_ray is the
right tool.

ray = pf.h.ortho_ray(0, [0.5, 0.5], ['x-velocity', 'Density',
'InternalEnergy', 'Pressure'])
print ray.keys()

This produces:
['Pressure', 'x', 'x-velocity', 'InternalEnergy', 'Density']

Perfect, everything as desired.


However, if I change the order of the input fields, some disappear from
the ray. Examples:

(1) ray = pf.h.ortho_ray(0, [0.5, 0.5], ['Density', 'x-velocity',
'Pressure', 'InternalEnergy'])
    print ray.keys()

    ['x', 'x-velocity', 'Pressure', 'Density']  -- 'InternalEnergy' is
missing.

(2) ray = pf.h.ortho_ray(0, [0.5, 0.5], ['Pressure', 'Density',
'x-velocity'])
    print ray.keys()

    ['Pressure']  -- 'Density' and 'x-velocity' are missing.

(3) ray = pf.h.ortho_ray(0, [0.5, 0.5], ['InternalEnergy', 'Density',
'x-velocity'])
    print ray.keys()

    ['InternalEnergy', 'Density']  -- 'x-velocity' is missing.


The pattern I'm seeing here is that whenever 'InternalEnergy' is
specified as an input only one field after it makes it into the ray.
When 'Pressure' is specified, no further fields make it.

I don't imagine this behavior is intended, but maybe it's due to some
user error on my part?


Thanks in advance for any clarifications.

Mike

-- 
*********************************************************************
*                                                                   *
*  Dr. Michael Kuhlen              Theoretical Astrophysics Center  *
*  email: mqk at astro.berkeley.edu   UC Berkeley                      *
*  cell phone: (831) 588-1468      601 Campbell Hall                *
*  skype username: mikekuhlen      Berkeley, CA 94720               *
*                                                                   *
*********************************************************************

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20100416/38f2d7a2/attachment.pgp>


More information about the yt-users mailing list