If there aren't any particles, then (in my example) ('CenOstriker', 'creation_time') won't be in ds.field_list, so you could do something like:<div><br></div><div> if field in ds.field_list:</div><div> nparticles = ad[field].shape[0]</div><div> else:</div><div> nparticles = 0</div><div><br></div><div>Nathan<span></span><br><br>On Friday, May 13, 2016, David Collins <<a href="mailto:dcollins4096@gmail.com">dcollins4096@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Cool. I may try my hand at such an object.</div><div><br></div><div>The problem with doing something like ad['CenOstriker','creation_time'] is that if there are no particles it raises an error, so for smooth flying I'd need to put it in a try/except, but that's not a huge deal.</div><div><br></div><div><br></div><div>Thanks!</div><div>d.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 13, 2016 at 4:42 PM, Nathan Goldbaum <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','nathan12343@gmail.com');" target="_blank">nathan12343@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">This uses the ActiveParticleCosmology dataset from <a href="http://yt-project.org/data" target="_blank">yt-project.org/data</a>:<div><br></div><div><div> import yt</div><div> ds = yt.load('ActiveParticleCosmology/DD0046/DD0046')</div><div> ad = ds.all_data()</div><div> print(ad['CenOstriker', 'creation_time'].shape)</div></div><div><br></div><div>Which prints out (899755,), so there are 899755 active particles in this simulation.</div><div><br></div><div>There isn't a convenience function to get the number of each particle type in the simulation. Adding such a convenience function (or populating some Dataset attribute with this information when we load the data so we don't need to make another I/O pass over the dataset) would be a great addition to yt. There's even a very long-standing issue opened by me about this...</div><div><br></div><div><a href="https://bitbucket.org/yt_analysis/yt/issues/718" target="_blank">https://bitbucket.org/yt_analysis/yt/issues/718</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, May 13, 2016 at 3:32 PM, David Collins <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','dcollins4096@gmail.com');" target="_blank">dcollins4096@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi, Everybody!<div><br></div><div>Is there a field or function that totals the number of active particles? I see that I can get it from the grid, but I don't see anything for the whole ds.</div><div><br></div><div>Thanks,</div><div>d.<span><font color="#888888"><br clear="all"><div><br></div>-- <br><div><div dir="ltr">-- Sent from a computer.<br></div></div>
</font></span></div></div>
<br></div></div>_______________________________________________<br>
yt-users mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','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/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','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/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">-- Sent from a computer.<br></div></div>
</div>
</blockquote></div>