[yt-users] YT 2.7 - Getting field values in code units

James Larrue-Baulch james.larrue at diopolis.com
Fri Jul 3 21:44:02 PDT 2015


Hello,

I have been working on a system with YT 2.7-dev (changeset 1b93a1840f38) 
and trying to graph field values in code units, specifically the 
density, but I cannot figure out how to convert to code units in YT 2.  
My data is from an Enzo cosmology simulation (i.e. expansion ON).

If I were using YT 3, I believe the following would work to convert to 
any units desired:

dataSet = load(inputDataFileName);
hierarchy = dataSet.index;
maxValue = hierarchy.find_max(dataFieldName)
ray = hierarchy.ortho_ray(0, (maxValue[1][1], maxValue[1][2]));
ray[xFieldName].convert_to_units(xAxisUnit);
// use "code_mass", "code_length", "code_time", etc. to get code units.

With YT 2, I am trying:

dataSet = load(inputDataFileName);
hierarchy = dataSet.hierarchy;
maxValue = hierarchy.find_max(dataFieldName)
ray = hierarchy.ortho_ray(0, (maxValue[1][1], maxValue[1][2]));
ray[xFieldName] = ray[xFieldName] * dataSet.units[xAxisUnit];

This works fine, if my "xAxisUnit" is a length unit, but no other units 
seem to be recognized.  While testing density, I tried to convert from 
cgs to mks:

KeyError: 'kg/m^3'

I listed the values in dataSet.units and they look to be only length units.

Should I just give up on YT 2 and move to a machine that has YT 3, or is 
it possible to convert density units with YT 2?

Regards,

James

PS The full script I am using is:

https://bitbucket.org/james_larrue/enzo-3.0-experimental/src/f425b7d5a10bf0da7cfd2fc146a464305f83d256/src/python/enzo-dataExporter.py?at=enzo-dev

but it contains much more code than my immediate goal.



More information about the yt-users mailing list