<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 5, 2016 at 10:17 AM, Reju Sam John <span dir="ltr"><<a href="mailto:rejusamjohn@gmail.com" target="_blank">rejusamjohn@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">Dear All, <div><br></div><div>I have a user defined field of  'Particle Type' as shown below.</div><div><br></div><div><font face="monospace, monospace">def _<wbr>KineticEnergyVMBVcorrParticle(<wbr>field, data):</font></div><div><font face="monospace, monospace">    return 0.5*data['particle_mass']*<wbr>data['<wbr>ParticleVelocityMagnitude']**2</font></div><div><font face="monospace, monospace">add_field("<wbr>KineticEnergyVMBVcorrParticle"<wbr>, function=_<wbr>KineticEnergyVMBVcorrParticle, take_log=False, units=r"\rm{erg}" )  </font></div></div></blockquote><div><br></div><div>Hi Reju,</div><div><br></div><div>I think you just need to specify particle_type=True in the add_field call above.</div><div><br></div><div>-Nathan </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>When I tried to calculate the total quantity of this quantity in a sphere <br><br><font face="monospace, monospace">ke_pari = sphere_ratio.quantities["<wbr>TotalQuantity"]("<wbr>KineticEnergyVMBVcorrParticle"<wbr>)</font></div><div><br></div><div>I am getting the following error.</div><div> <br clear="all"><div><div> <font face="monospace, monospace">   ke_pari = sphere_ratio.quantities["<wbr>TotalQuantity"]("<wbr>KineticEnergyVMBVcorrParticle"<wbr>)</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>derived_quantities.py", line 82, in __call__</font></div><div><font face="monospace, monospace">    return self._call_func_lazy(args, kwargs)</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>derived_quantities.py", line 89, in _call_func_lazy</font></div><div><font face="monospace, monospace">    rv = self.func(<wbr>GridChildMaskWrapper(g, self._data_source), *args, **kwargs)</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>derived_quantities.py", line 705, in _TotalQuantity</font></div><div><font face="monospace, monospace">    if data[field].size < 1:</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>derived_quantities.py", line 50, in __getitem__</font></div><div><font face="monospace, monospace">    data = self.data_source._get_data_<wbr>from_grid(self.grid, item)</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>data_containers.py", line 81, in save_state</font></div><div><font face="monospace, monospace">    tr = func(self, grid, field, *args, **kwargs)</font></div><div><font face="monospace, monospace">  File "/home/john/yt_new/yt-x86_64/<wbr>src/yt-hg/yt/data_objects/<wbr>data_containers.py", line 2661, in _get_data_from_grid</font></div><div><font face="monospace, monospace">    return tr[pointI].ravel()</font></div><div><font face="monospace, monospace">IndexError: too many indices for array</font></div></div><div><br></div><div>What could be the reason ?</div><div><br></div><div>Thankyou </div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr">Reju Sam John</div></div>
</font></span></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></div>