<div dir="ltr">Dear Nathan,<div><br></div><div>The particle filter worked well and I could read the star density from the data. Thanks!</div><div>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?</div><div><br></div><div>(jupiter notebook session)</div><div><div>import yt</div><div>from yt.data_objects.particle_filters import add_particle_filter</div></div><div><br></div><div><div>def stars(pfilter, data):</div><div>    filter = data[(pfilter.filtered_type, "particle_type")] == 2</div><div>    return filter</div></div><div><br></div><div><div>add_particle_filter("stars", function=stars, filtered_type='io',</div><div>                    requires=["particle_type"])</div></div><div><br></div><div>ds.add_particle_filter('stars')<br></div><div><br></div><div><div>def only_DM(field, data):</div><div>    return data['Dark_Matter_Density'] - data['deposit','stars_density']</div></div><div><br></div><div>ds=yt.load(".../redshift00??")<br></div><div><br></div><div>ds.add_field(("Dark_Matter_Density", "only_DM_Density"), units="kg/m**3", function=only_DM)<br></div><div><br></div><div>and the error message appears:</div><div><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span class="gmail-ansi-red-fg" style="box-sizing:border-box;color:rgb(231,92,88)">YTFieldNotFound</span>: Could not find field '('deposit', 'stars_density')' in redshift00??.</pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline">Sincerely,</pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);background-color:transparent;border:0px;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;white-space:pre-wrap;vertical-align:baseline">Y.T.</pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-10-11 16:24 GMT-04:00 Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>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 (<a href="http://yt-project.org/doc/analyzing/filtering.html#filtering-particle-fields" target="_blank">http://yt-project.org/doc/<wbr>analyzing/filtering.html#<wbr>filtering-particle-fields</a>) and then use the new particle type defined by the filter to create a deposited particle field (<a href="http://yt-project.org/doc/analyzing/fields.html#deposited-particle-fields" target="_blank">http://yt-project.org/doc/<wbr>analyzing/fields.html#<wbr>deposited-particle-fields</a>).</div><div><br></div><div>There's an example in the docs for how to do this with Tipsy data here: <a href="http://yt-project.org/doc/cookbook/constructing_data_objects.html#creating-particle-filters" target="_blank">http://yt-project.org/doc/<wbr>cookbook/constructing_data_<wbr>objects.html#creating-<wbr>particle-filters</a></div><div><br></div><div>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:</div><div><br></div><div><a href="https://gist.github.com/anonymous/acd4007dbff283fc3587a47e8ba41dc3" target="_blank">https://gist.github.com/<wbr>anonymous/<wbr>acd4007dbff283fc3587a47e8ba41d<wbr>c3</a></div><div><br></div><div>Hope that helps! And I hope to hear more from you - your name is particularly well suited to the yt project ;)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Nathan<br></div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 11, 2017 at 12:58 PM, tyuta <span dir="ltr"><<a href="mailto:y0u1t1a5.t@gmail.com" target="_blank">y0u1t1a5.t@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, it's Enzo data.</div><div class="m_-7499531679438205703HOEnZb"><div class="m_-7499531679438205703h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-10-11 10:17 GMT-04:00 Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">What simulation code are you working with? From the field names it sounds like Enzo data.</div><br><div class="gmail_quote"><div><div class="m_-7499531679438205703m_-2520757203057627010h5"><div>On Wed, Oct 11, 2017 at 9:13 AM tyuta <<a href="mailto:y0u1t1a5.t@gmail.com" target="_blank">y0u1t1a5.t@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-7499531679438205703m_-2520757203057627010h5"><div><span style="font-size:14px">Dear yt-users,</span><div style="font-size:14px"><br></div><div style="font-size:14px">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?</div><div style="font-size:14px"><br></div><div style="font-size:14px">Sincerely,</div><div style="font-size:14px">Y.T.</div></div></div></div>
______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.o<wbr>rg</a><br>
</blockquote></div></div>
<br>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.o<wbr>rg</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-users-<wbr>spacepope.org</a><br>
<br></blockquote></div><br></div>