[yt-users] How to get total quantity of 'Particle Type' in a sphere?

Reju Sam John rejusamjohn at gmail.com
Tue Sep 6 10:59:20 PDT 2016


Hi Nathan
Thank you very much.  You correctly figure out the mistake. 😊😊😊

On Tue, Sep 6, 2016 at 8:38 PM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

>
>
> On Mon, Sep 5, 2016 at 10:17 AM, Reju Sam John <rejusamjohn at gmail.com>
> wrote:
>
>> Dear All,
>>
>> I have a user defined field of  'Particle Type' as shown below.
>>
>> def _KineticEnergyVMBVcorrParticle(field, data):
>>     return 0.5*data['particle_mass']*data['ParticleVelocityMagnitude']**2
>> add_field("KineticEnergyVMBVcorrParticle", function=_KineticEnergyVMBVcorrParticle,
>> take_log=False, units=r"\rm{erg}" )
>>
>
> Hi Reju,
>
> I think you just need to specify particle_type=True in the add_field call
> above.
>
> -Nathan
>
>
>> When I tried to calculate the total quantity of this quantity in a sphere
>>
>> ke_pari = sphere_ratio.quantities["TotalQuantity"]("KineticEnergyVMBVc
>> orrParticle")
>>
>> I am getting the following error.
>>
>>     ke_pari = sphere_ratio.quantities["Total
>> Quantity"]("KineticEnergyVMBVcorrParticle")
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py",
>> line 82, in __call__
>>     return self._call_func_lazy(args, kwargs)
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py",
>> line 89, in _call_func_lazy
>>     rv = self.func(GridChildMaskWrapper(g, self._data_source), *args,
>> **kwargs)
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py",
>> line 705, in _TotalQuantity
>>     if data[field].size < 1:
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.py",
>> line 50, in __getitem__
>>     data = self.data_source._get_data_from_grid(self.grid, item)
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
>> line 81, in save_state
>>     tr = func(self, grid, field, *args, **kwargs)
>>   File "/home/john/yt_new/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
>> line 2661, in _get_data_from_grid
>>     return tr[pointI].ravel()
>> IndexError: too many indices for array
>>
>> What could be the reason ?
>>
>> Thankyou
>> --
>> Reju Sam John
>>
>> _______________________________________________
>> yt-users mailing list
>> 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
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>


-- 
Reju Sam John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160906/bad352d3/attachment.htm>


More information about the yt-users mailing list