<div dir="ltr"><div>Thanks, Matt, John, some follow-up</div><div><br></div><div>"<span style="font-family:arial,sans-serif;font-size:13px">In any case, the difference in the total quantity is about a few percent it looks like. Are you attempting to quantify something with that level of sensitivity?"</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">- I'm trying to compare star particle mass, and if I use TotalQuantity and StarMassMsun comparing to summing the star particle's mass.  For small halos that are only a few cells, the difference can be quite high ~O(10%).  So from the perspective of actually particles inside the halo, I should use the particle list inside the 3D object, right?  Same thing with dark matter particle mass?</span></div>
<div><br></div><div>"<span style="font-family:arial,sans-serif;font-size:13px">The output isn't what you might expect, because numpy uses the dtype </span><span style="font-family:arial,sans-serif;font-size:13px">of the array for the accumulation." </span></div>
<div>- I don't quite understand why would float32 accumulation with sum() not equal to the actual thing but casting it as float64 does (isn't 2^32 < 512^3 so no overflow should occur)?  Should I always use arr.sum(dtype='float64') when using sum() with possible large datasets?</div>
<div><br></div><div>From</div><div>G.S.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 21, 2013 at 5:43 AM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Geoffrey,<br>
<div><div class="h5"><br>
On Fri, Dec 20, 2013 at 9:02 PM, Geoffrey So <<a href="mailto:gsiisg@gmail.com">gsiisg@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I found that using a Enzo dataset I was getting slightly different numbers<br>
> when<br>
> 1) using the list of dark matter particles selected by creation_time < 0.0<br>
><br>
> In [97]: sph_dm = sph['creation_time'] < 0.0<br>
> In [98]: print "%12.12e" % (sph['ParticleMassMsun'][sph_dm]).sum()<br>
> 1.211311468567e+11<br>
><br>
> 2) compared to summing the dark matter particles inside a 3D container with<br>
> TotalQuantity<br>
><br>
> In [101]: print "%12.12e" %<br>
> (sph.quantities['TotalQuantity']('Dark_Matter_Density')[0]*vol/Msun)<br>
> 1.188937185993e+11<br>
><br>
> I'm wondering if the field and particles are handled differently when being<br>
> counted as inside or outside the 3D container?<br>
><br>
<br>
</div></div>I think John's answer is completely correct, and likely the dominant<br>
problem, but there's a funny thing that happens if you're not extra<br>
careful with big arrays.  As an example, something that I ran into a<br>
couple years ago:<br>
<br>
# This is an array filled with ones.<br>
arr = numpy.ones((512, 512, 512), dtype="float32")<br>
print arr.sum()<br>
print arr.size<br>
print arr.sum(dtype = "float64")<br>
<br>
The output isn't what you might expect, because numpy uses the dtype<br>
of the array for the accumulation.  The quantities -- thanks to Doug<br>
Rudd -- are uniformly careful about upgrading to 64 bits the<br>
accumulators used for quantities.  Again, I don't think this is<br>
dominant, but it is something to be aware of.<br>
<br>
-Matt<br>
<div class="HOEnZb"><div class="h5"><br>
> From<br>
> G.S.<br>
><br>
> _______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
_______________________________________________<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" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</div></div></blockquote></div><br></div>