[yt-users] Best way to count particles?
Stephen Skory
s at skory.us
Fri Oct 12 15:40:24 PDT 2012
Hi Matt,
> What's the best way to get the number of particles of a particular
> type from a data object?
>
> i.e., the derived quantity way of doing:
>
> (dd["particle_type"] == something).sum()
This should probably work, what do you think Matt?
from yt.mods import *
def _pcount(field, data):
return (data["particle_type"] == 0).sum()
add_field("pcount", function=_pcount, particle_type=True)
pf = load("DD0252")
dd = pf.h.all_data()
print dd.quantities['TotalQuantity']('pcount')
--
Stephen Skory
s at skory.us
http://stephenskory.com/
510.621.3687 (google voice)
More information about the yt-users
mailing list