[yt-users] functions within functions

David Collins dcollins at physics.ucsd.edu
Wed Jul 13 07:56:48 PDT 2011


Could you send more of the error trace?  In broad strokes, I've
defined fields that I use in the creation of other fields in a similar
manner to what you described and it works fine, so I suspect that it
has something to do with the profile or something subtle in the actual
function definitions.

What's the source you're using for the BinnedProfile1D?

d.

On Wed, Jul 13, 2011 at 6:24 AM, Elizabeth Tasker <taskere at mcmaster.ca> wrote:
> 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
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>



-- 
Sent from my computer.



More information about the yt-users mailing list