[yt-users] Total Active Particles?

Nathan Goldbaum nathan12343 at gmail.com
Fri May 13 15:05:49 PDT 2016


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:

    if field in ds.field_list:
        nparticles = ad[field].shape[0]
    else:
        nparticles = 0

Nathan

On Friday, May 13, 2016, David Collins <dcollins4096 at gmail.com> wrote:

>
> Cool.  I may try my hand at such an object.
>
> 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.
>
>
> Thanks!
> d.
>
> On Fri, May 13, 2016 at 4:42 PM, Nathan Goldbaum <nathan12343 at gmail.com
> <javascript:_e(%7B%7D,'cvml','nathan12343 at gmail.com');>> wrote:
>
>> This uses the ActiveParticleCosmology dataset from yt-project.org/data:
>>
>>     import yt
>>     ds = yt.load('ActiveParticleCosmology/DD0046/DD0046')
>>     ad = ds.all_data()
>>     print(ad['CenOstriker', 'creation_time'].shape)
>>
>> Which prints out (899755,), so there are 899755 active particles in this
>> simulation.
>>
>> 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...
>>
>> https://bitbucket.org/yt_analysis/yt/issues/718
>>
>> On Fri, May 13, 2016 at 3:32 PM, David Collins <dcollins4096 at gmail.com
>> <javascript:_e(%7B%7D,'cvml','dcollins4096 at gmail.com');>> wrote:
>>
>>> Hi, Everybody!
>>>
>>> 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.
>>>
>>> Thanks,
>>> d.
>>>
>>> --
>>> -- Sent from a computer.
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> <javascript:_e(%7B%7D,'cvml','yt-users at lists.spacepope.org');>
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> <javascript:_e(%7B%7D,'cvml','yt-users at lists.spacepope.org');>
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
>
> --
> -- Sent from a computer.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160513/a62a7270/attachment.htm>


More information about the yt-users mailing list