[yt-users] Basic units quesions

Matthew Turk matthewturk at gmail.com
Wed Aug 25 14:11:28 PDT 2010


Hi Andrew,

Yes, the particle_velocities_[xyz] are in cm/s, as you guessed.  The
units definitely need to be included, but as you point out, they
aren't.  The way to get the string I see now is to actually call:

In [3]: pf.field_info["particle_velocity_x"].get_units()
Out[3]: ''

but as you can see this is empty.  Could you fill out a ticket:

http://yt.enzotools.org/newticket

(you can log in with any OpenID) so that this gets handled?  I can't
handle it just now, but I'm happy to make sure this is fixed.

As to the issue of the positions of the particles -- you raise a good
point.  As of right now, the positions in yt are mostly done with
respect to whatever the code (Enzo, Orion, etc) uses as a natural
normalization.  For Enzo, this typically means that it's 0..1 in all
dimensions.  The reason for this is that it was never clear to me when
I got started what the "right" thing to do was.  It didn't make sense
to convert them to some arbitrary normalization, but now it seems to
me that it would be and was the right thing to do.

I'll say off the bat, I think I like the convention that the lowercase
values (particle_position_[xyz]) are in the domain units.  This could
still be used for things like the kD-tree and whatnot, where the
values are easier if kept in some normalized fashion.  But then the
uppercase: "ParticlePositionX" could be in cm, where the 0,0,0 point
is the standard 0,0,0 of the cube.  (We could do the same for the
field "x", "y", "z", which are currently in domain units, but then
"X", "Y", "Z" could be in cm.)

What do you, and the others, think?  I'd like to move away from domain
units on the whole except where explicitly asked for; it requires
knowing too much about yt internals to write fields and to handle
data.  Additionally, in the future I anticipate we'll be modifying the
mechanism for accessing particles to allow for accessing directly by
particle type.

-Matt

On Wed, Aug 25, 2010 at 6:57 AM, Britton Smith <brittonsmith at gmail.com> wrote:
> 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
>
>
> _______________________________________________
> 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