
Dear Nathan, The particle filter worked well and I could read the star density from the data. Thanks! Now I want to subtract stellar mass density from Dark_Matter_Density. I was trying to define a new field "only_DM", but it did not work. Could you tell me what is wrong with this? (jupiter notebook session) import yt from yt.data_objects.particle_filters import add_particle_filter def stars(pfilter, data): filter = data[(pfilter.filtered_type, "particle_type")] == 2 return filter add_particle_filter("stars", function=stars, filtered_type='io', requires=["particle_type"]) ds.add_particle_filter('stars') def only_DM(field, data): return data['Dark_Matter_Density'] - data['deposit','stars_density'] ds=yt.load(".../redshift00??") ds.add_field(("Dark_Matter_Density", "only_DM_Density"), units="kg/m**3", function=only_DM) and the error message appears: YTFieldNotFound: Could not find field '('deposit', 'stars_density')' in redshift00??. Sincerely, Y.T. 2017-10-11 16:24 GMT-04:00 Nathan Goldbaum <nathan12343@gmail.com>:
OK, in that case I wouldn't try to infer the stellar mass from the Dark_Matter_Density field (which does include stellar mass despite the name), instead I would define a particle filter for stars ( http://yt-project.org/doc/analyzing/filtering.html# filtering-particle-fields) and then use the new particle type defined by the filter to create a deposited particle field ( http://yt-project.org/doc/analyzing/fields.html#deposited-particle-fields ).
There's an example in the docs for how to do this with Tipsy data here: http://yt-project.org/doc/cookbook/constructing_data_ objects.html#creating-particle-filters
For Enzo, you should use the particle_type field to create the filter - star particles in Enzo have particle_type equal to 2. Here's a short worked example:
https://gist.github.com/anonymous/acd4007dbff283fc3587a47e8ba41dc3
Hope that helps! And I hope to hear more from you - your name is particularly well suited to the yt project ;)
-Nathan
On Wed, Oct 11, 2017 at 12:58 PM, tyuta <y0u1t1a5.t@gmail.com> wrote:
Yes, it's Enzo data.
2017-10-11 10:17 GMT-04:00 Nathan Goldbaum <nathan12343@gmail.com>:
What simulation code are you working with? From the field names it sounds like Enzo data.
On Wed, Oct 11, 2017 at 9:13 AM tyuta <y0u1t1a5.t@gmail.com> wrote:
Dear yt-users,
Hi, I'm a new user of yt. I have a question about the default 'Density' field and 'Dark_Matter_Density' field. Do they contain stellar mass? If so, how can I read and subtract stellar mass from the data?
Sincerely, Y.T. _______________________________________________ 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