[yt-users] Basic units quesions

Britton Smith brittonsmith at gmail.com
Wed Aug 25 06:57:51 PDT 2010


Hi Andrew,

I'm not sure about the output from get_source, so I'll let someone else
comment on that.  In general, the units of the fields are in cgs.  The
exceptions to this are positions, both grid cell and particle positions, and
any field that has units implied by the name, such as CellMassMsun.  There
is a units conversion dict, pf.units, that you can use to convert positions
into usable units.  For example, multiply position by pf.units['mpc'] to get
proper Mpc.

Britton

On Wed, Aug 25, 2010 at 9:47 AM, Andrew Davis <andrew.davis at yale.edu> wrote:

> Hi yt users,
>
> I have some basic questions about the units.  I'm trying to follow through
> the
> cookbook and help site, but some of it isn't working.  Namely, the part
> about
> having it tell me what units some of the fields are in.
>
> When I follow the commands on the page:
> http://yt.enzotools.org/doc/howto/objects.html  This is what happens:
>
> In: pf=load("EZ2_0000")
> In: print(pf.h.field_list)
> Out: ['z-velocity', 'Temperature', 'Density', 'particle_velocity_z',
> 'TotalEnergy', 'Dark_Matter_Density', 'particle_position_z', 'x-velocity',
> 'particle_position_y', 'y-velocity', 'particle_index',
> 'particle_position_x',
> 'particle_mass', 'particle_velocity_x', 'particle_velocity_y']
>
> So, I see DM particle fields, which is what I'm interested in.  However,
> when I
> try to find their units, I get:
> In: print(pf.field_info["particle_velocity_x"].units)
> Out:
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
>
> /home/adavis/Research/YT/src/yt-1.7-svn/scripts/iyt in <module>()
> ----> 1
>      2
>      3
>      4
>      5
>
> AttributeError: 'DerivedField' object has no attribute 'units'
>
> I get the same error for the following fields:
> [xyz]-velocity, particle_velocity_[xyz], particle_position_[xyz], Density,
> TotalEnergy, Dark_Matter_Density, and particle_index (ok, this shouldn't
> have
> units)
>
> When I try the other method of getting at the units:
> pf.field_info["particle_velocity_x"].get_source() , there is nothing there
> that
> says anything about units.
>
> Out: def _Particles(field, data):
>        io = data.hierarchy.io
>        if not data.NumberOfParticles > 0:
>            return na.array([], dtype=dtype)
>        try:
>            return io._read_data_set(data, p_field).astype(dtype)
>        except io._read_exception:
>            pass
>        # This is bad.  But it's the best idea I have right now.
>        return data._read_data(p_field.replace("_"," ")).astype(dtype)
>
> And, while field_info["Density"].get_source() works, the same command for
> Temperature tells me that the units are g/cm^3, which is obviously wrong.
>
> So, my major question: particle positions seem to be in the [0-1] unit
> system,
> so conversion is simple for them.  Particle velocities, however, are
> unclear.
> They look like they're in cm/s, but I'd like to be sure.
>
> thanks!
>
> Andrew
>
>
>
> *************************************************************
> **  Andrew J. Davis             andrew.davis at yale.edu      **
> **  Dept. of Astronomy          203-432-5119               **
> **  Yale University             www.astro.yale.edu/adavis  **
> *************************************************************
>
>
>
> _______________________________________________
> 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/20100825/562c7d1e/attachment.htm>


More information about the yt-users mailing list