[yt-users] problems with the projection tool

Matthew Turk matthewturk at gmail.com
Mon Feb 15 08:39:07 PST 2010


Hi Luigi,

First off, thank you very much for providing a script that isolates
the problem!  It made it much easier for me to dig in and replicate
the issue.

First I'd like to echo what Britton said about accessing the pf --
it's guaranteed to be defined as data.pf, but it's not guaranteed to
be in the namespace otherwise.  Additionally, I'd like to just note
that "x-velocity" gets returned after having been converted via the
Enzo units in the parameter file (you can see what these are by
looking at pf["x-velocity"]) so you might be applying apples to
oranges.

I found two solutions to the issue.  One is to apply a validator:

add_field("EddyTurnover", function=EddyTurnover,
          validators=[lagos.ValidateSpatial(0)])

this mandates that the field EddyTurnover is only ever created inside
grids.  The field detection mechanism seems to get confused by the
nested x-velocity calls and the GridLevel usage, and I'm not sure why,
but I'm going to try to track it down.  But, this should fix it,
regardless!

The other solution was to change the definition of the field to avoid
using GridLevels:

--
def EddyTurnover(field, data):
    eddy = data["x-velocity"] / data["dx"]
    return eddy

def _convertEddyTurnover(data):
    return data.convert("cm")**-1.0

add_field("EddyTurnover", function=EddyTurnover,
convert_function=_convertEddyTurnover)
--

Note that here we've added a convert_function -- "x-velocity" will be
in cgs, but "dx" is in code units, so we need to divide by "cm" in
order to get it back in "seconds."  I haven't included the
"InitialTime" (code units) usage you had originally, but you should be
able to drop it back in without trouble.

I hope that helps -- let us know if there's anything else that goes
wrong, or anything unclear in this.

-Matt

On Mon, Feb 15, 2010 at 8:00 AM, Britton Smith <brittonsmith at gmail.com> wrote:
> Hi Luigi,
> I've looked over your code and I can't see anything specifically wrong.  Can
> you post the error message you're getting?  That might help.  As a side
> note, you may want to replace pf['InitialTime'] on line 35 with
> data.pf['InitialTime'].  The pf is global within your script, but if you
> those field functions in other files you will get an error because the
> function will not know about pf.
> Britton
>
> On Mon, Feb 15, 2010 at 6:09 AM, Luigi Iapichino
> <luigi at ita.uni-heidelberg.de> wrote:
>>
>> Dear all,
>>
>> I'm trying to plot the projection of a variable defined in a rather
>> involved
>> way, namely through an IF statement. I can use this variable for many
>> computations and I can plot slices of it, but somehow it does not work
>> with
>> projections. I attach an example script which isolates the problem. I
>> guess
>> it can run on any standard cosmological output of Enzo (v. 1.0; I haven't
>> worked with Enzo 1.5 yet). As I told you, if I change the
>> pc.add_projection(... at line 65 with
>> pc.add_slice(...
>> everything works well.
>> I'm using YT 1.6, and because of problems in my machine I cannot upgrade
>> to
>> 1.6.1 until next week, so I don't know if this issue has been already
>> fixed
>> by chance.
>> Looking forward to your suggestions,
>> Cheers,
>>
>>  Luigi
>>
>> --
>>
>> ---------------------------------------------------------------
>>
>> Luigi Iapichino
>> Zentrum fuer Astronomie der Universitaet Heidelberg
>> Institut fuer Theoretische Astrophysik
>> Albert-Ueberle-Str. 2, D-69120 Heidelberg, Germany
>> Tel: +49 6221 548983, Fax: +49 6221 544221
>> e-mail: luigi at ita.uni-heidelberg.de
>> URL: http://www.ita.uni-heidelberg.de/~luigi/
>>
>> _______________________________________________
>> 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