
Hi everyone, I want to write a new field based on the neighbour cells like this: vx = data[ftype, "velocity_x"][sl_right,sl_center,sl_center] but I got " global name 'ftype' is not defined". I suppose that I have the same problem with sl_left, sl_right , sl_center. Thanks, Jose _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Jose, Presuming that you have sl_right and sl_center defined in your field already, you should be able to just substitute “gas” for ftype, since the velocity fields are “gas" fields. Best, John
On Dec 19, 2014, at 11:04 AM, José Utreras <jutreras@das.uchile.cl> wrote:
Hi everyone,
I want to write a new field based on the neighbour cells like this:
vx = data[ftype, "velocity_x"][sl_right,sl_center,sl_center]
but I got " global name 'ftype' is not defined". I suppose that I have the same problem with sl_left, sl_right , sl_center.
Thanks,
Jose _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Thanks for your answer John I have to define sl_right, sl_center :global name 'sl_right' is not defined I'm not really sure how to do it. I want to do something like these: vx = data["gas", "velocity_x"][sl_right,sl_center,sl_center] vx+= data["gas", "velocity_x"][sl_center,sl_right,sl_center] ... add the x velocity of 6 neighbour cells. Thanks 2014-12-19 13:31 GMT-03:00 John ZuHone <jzuhone@gmail.com>:
Jose,
Presuming that you have sl_right and sl_center defined in your field already, you should be able to just substitute “gas” for ftype, since the velocity fields are “gas" fields.
Best,
John
On Dec 19, 2014, at 11:04 AM, José Utreras <jutreras@das.uchile.cl> wrote:
Hi everyone,
I want to write a new field based on the neighbour cells like this:
vx = data[ftype, "velocity_x"][sl_right,sl_center,sl_center]
but I got " global name 'ftype' is not defined". I suppose that I have the same problem with sl_left, sl_right , sl_center.
Thanks,
Jose _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

On Fri, Dec 19, 2014 at 10:14 AM, José Utreras <jutreras@das.uchile.cl> wrote:
Thanks for your answer John I have to define sl_right, sl_center :global name 'sl_right' is not defined
I'm not really sure how to do it. I want to do something like these:
vx = data["gas", "velocity_x"][sl_right,sl_center,sl_center] vx+= data["gas", "velocity_x"][sl_center,sl_right,sl_center]
Hi Jose, This code looks like came from the definition of the vorticity field. You're correct that ftype, sl_right, sl_center, and sl_left aren't defined inside the voriticity field definition. That's because the voriticity field is a closure (a special type of python function that is able to use varibles defined in the enclosing scope around the function definition). I'd encourage you to take a look at yt/fields/fluid_vector_fields.py to see how this works inside yt: https://bitbucket.org/yt_analysis/yt/src/5007c9a46622118abab89dc153dbfb6591c...
...
add the x velocity of 6 neighbour cells.
Your field definition will need a ValidateSpatial field validator (like vorticity). ValidateSpatial will make it so data is passed into a field definition along with a user-selectable number of ghost zones.
Thanks
2014-12-19 13:31 GMT-03:00 John ZuHone <jzuhone@gmail.com>:
Jose,
Presuming that you have sl_right and sl_center defined in your field already, you should be able to just substitute “gas” for ftype, since the velocity fields are “gas" fields.
Best,
John
On Dec 19, 2014, at 11:04 AM, José Utreras <jutreras@das.uchile.cl> wrote:
Hi everyone,
I want to write a new field based on the neighbour cells like this:
vx = data[ftype, "velocity_x"][sl_right,sl_center,sl_center]
but I got " global name 'ftype' is not defined". I suppose that I have the same problem with sl_left, sl_right , sl_center.
Thanks,
Jose _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
John ZuHone
-
José Utreras
-
Nathan Goldbaum