[yt-dev] yt-3.0 derived fields

Christopher Moody chrisemoody at gmail.com
Sat Mar 9 13:00:41 PST 2013


Hi everyone,
Fields in yt-3.0 are now defined like (field_type,field_name) but for
backwards-compatibility still maintains a field_name -> ("all",field_name)
mapping. Consider a few use cases:

keys = ["ParticleMassMsun",
        ("all","ParticleMassMsun"),
        ("stars","particle_mass"),
        ("stars","ParticleMassMsun") ]#broken

I think we all have natural expectations for what should happen, but at the
moment the last key in the series is broken. particle_mass is a native
field, ParticleMassMsun is a derived field:

def _ParticleMassMsun(field, data):
    return data["particle_mass"]/mass_sun_cgs
add_field("ParticleMassMsun", function=_ParticleMassMsun,
particle_type=True)

Note that in this case data["particle_mass"] maps to
data[("all","particle_mass")] even when I originally asked for
dd[("stars","ParticleMassMsun")], which is why things break.

So I propose a syntax where in the derived field definition we can do
something like data[(Ellipsis,"ParticleMassMsun")] or alternatively
data[(field.field_type,"ParticleMassMsun")]. This ensures that derived
fields will work intuitively and be as specific to a field type as they
want to be or just pass through whatever field type they may want.

Thanks!
chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20130309/85089d60/attachment.htm>


More information about the yt-dev mailing list