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

Matthew Turk matthewturk at gmail.com
Fri Apr 16 16:22:16 PDT 2010


Hi Michael,

This is indeed a bug, and unfortunately I don't think I'll be able to
completely track it down until Wednesday or so.  Until then, there are
two other alternatives:

1. Don't specify the initial list of fields, simply access them --
typically they only need to be specified if the data object is
expensive to read or expensive to generate fields for.
2. Use a 3D data object, which should also work on 1- and 2-D data.

I'll be in touch when I figure it out.  Best,

Matt

On Fri, Apr 16, 2010 at 4:28 PM, Michael Kuhlen <mqk at astro.berkeley.edu> wrote:
> 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               *
> *                                                                   *
> *********************************************************************
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>



More information about the yt-users mailing list