[yt-users] functions within functions

Elizabeth Tasker taskere at mcmaster.ca
Wed Jul 13 05:24:26 PDT 2011


Hi,

I'm not sure where this is actually a yt question or a python one...

I'm trying to create a slice of a new field that consists of the PotentialField (in the raw Enzo output) minus the background value, created by the profile tool.

I have two functions that I created to do this:

def _DiskRadius(field, data):
    .....
    return dradius

add_field("DiskRadius", function=_DiskRadius)

That returns the value of the radius in the disk plane and

def _SubtractBackgroundPotential(field, data):
	.....
	profile = BinnedProfile1D(source, 128, "DiskRadius", 0.0, 16.0)
	.....

add_field("SubtractBackgroundPotential", function=_SubtractBackgroundPotential)


which uses the first function to create a profile as a function of disk radius.

then I have:

p = pc.add_slice("SubtractBackgroundPotential", 2)



Except that yt fails inside def _SubtractBackgroundPotential(field, data) because it can't find DiskRadius:

---> 23     profile = BinnedProfile1D(source, 128, "DiskRadius", 0.0, 16.0)


Could anyone tell me how to get function 2 recognizing function 1?

Thank you,

Elizabeth


More information about the yt-users mailing list