<p dir="ltr">Hi John,<br>
On Apr 7, 2014 10:17 PM, "John Wise" <<a href="mailto:jwise@physics.gatech.edu">jwise@physics.gatech.edu</a>> wrote:<br>
><br>
> Hi Munier,<br>
><br>
> In v2.x, it seems like the interpolated star velocities aren't defined in the Enzo-specific fields in frontends/enzo/fields.py, even though that the metallicity_fraction, creation_time, and dynamical_time fields are defined.  However, the machinery is there to create these fields.<br>

><br>
> You can put the following in your .yt/my_plugins.py file or at the beginning of your script or add it to Enzo's fields.py file.<br>
><br>
> from yt.data_objects.field_info_container import ValidateSpatial<br>
> from yt.frontends.enzo.fields import _star_field<br>
> add_field('star_particle_velocity_x', function=_star_field,<br>
>           validators=[ValidateSpatial(0)])<br>
> add_field('star_particle_velocity_y', function=_star_field,<br>
>           validators=[ValidateSpatial(0)])<br>
> add_field('star_particle_velocity_z', function=_star_field,<br>
>           validators=[ValidateSpatial(0)])<br>
><br>
> With v3.0, this code looks like it will still work because _star_field is still defined.<br>
><br>
> However one new feature in 3.0 is particle filters, where you can single out the star particles and then use a deposit operator to interpolate it to the grid.  Here's what I tried, but I couldn't get it to work.  Maybe someone more familiar with 3.0 can chime in.  I tried for about 15-30 minutes, but I'm out of time now.  It'd be great to see an example like this.  I couldn't figure it out from YTEP-0013...<br>

><br>
> @particle_filter("star", ["particle_type"])<br>
> def finest(pfilter, data):<br>
>     return data["all", "particle_type"] != 1</p>
<p dir="ltr">Ah, here's the trick- filters can't act on unions, and "all" is a union. If you try it on "io" it should work.</p>
<p dir="ltr">Matt</p>
<p dir="ltr">><br>
> def _my_star_field(field, data):<br>
>     pfield = "particle_" + <a href="http://field.name">field.name</a>[5:]<br>
>     pos = data["star", "Coordinates"]<br>
>     d = data.deposit(pos, [data["star", pfield], data["star", "particle_mass"]], method = "weighted_mean")<br>
>     return d<br>
><br>
> add_field(name = ("deposit", "star_velocity_x"), function = _my_star_field, validators=[ValidateSpatial()])<br>
> add_field(name = ("deposit", "star_velocity_y"), function = _my_star_field, validators=[ValidateSpatial()])<br>
> add_field(name = ("deposit", "star_velocity_z"), function = _my_star_field, validators=[ValidateSpatial()])<br>
><br>
><br>
> Cheers,<br>
> John<br>
><br>
><br>
> On 04/07/2014 07:56 PM, Munier Azzam Salem wrote:<br>
>><br>
>> Hey Guys,<br>
>><br>
>>          I'm looking to work with star particle velocities, ideally:<br>
>> some sort of mass-weighted-average of star particle velocities within a<br>
>> given cell (I'm using enzo, if that's relevant). This doesn't seem to<br>
>> exist in th universal field list, although the cic_particle_velocity_x<br>
>> <<a href="http://yt-project.org/docs/dev/reference/field_list.html?highlight=field%20list#cic-particle-velocity-x">http://yt-project.org/docs/dev/reference/field_list.html?highlight=field%20list#cic-particle-velocity-x</a>>/y/z in<br>

>><br>
>> the enzo field list seem relevant.<br>
>><br>
>>          Any advice?<br>
>><br>
>>                 thanks!<br>
>>                      Munier<br>
>><br>
>> --<br>
>> Munier A. Salem // 845.489.6450<br>
>><br>
>><br>
>> _______________________________________________<br>
>> yt-users mailing list<br>
>> <a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
>> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
>><br>
><br>
> -- <br>
> John Wise<br>
> Assistant Professor of Physics<br>
> Center for Relativistic Astrophysics, Georgia Tech<br>
> <a href="http://cosmo.gatech.edu">http://cosmo.gatech.edu</a><br>
> _______________________________________________<br>
> yt-users mailing list<br>
> <a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</p>