[yt-users] precision of TotalQuantity

Britton Smith brittonsmith at gmail.com
Fri Jun 18 12:31:50 PDT 2010


G.S.,

I would recommend using the WeightedAverageQuantity derived quantity to
calculate field averages.  If you are doing unigrids, what you've done is
ok, but if you're using AMR, an unweighted average like what you've done is
a little improper, since the cells have different sizes.  In a unigrid, an
unweighted average is the same as weighting by CellVolume, so if that's
really what you're looking for, you could use the derived quantity above
with CellVolume as the weight field.  This may also solve your precision
problem.  However, you may want to think about other weighting methods in
the future if you do this for AMR.

Britton

On Fri, Jun 18, 2010 at 1:19 PM, <gso at physics.ucsd.edu> wrote:

> My script below gives the max min and mean of a field, however, the mean
> seems to be only giving me 6 digits of accuracy as seen in the output:
>
> min 5.3512599744055807e-30
> max 2.4254363112272260e-26
> mean 7.9708800000000001e-29
>
> it's very unlikely that the mean value has all those zeroes in it, is
> there a quick way to get higher accuracy using something similar to
> dd.quantites[] or do I have to calculate the total by looping over all the
> cells to get the higher precision I needed?
>
> From
> G.S.
>
> from yt.mods import *
> pf = EnzoStaticOutput("DD0273/DD0273")
> res=64
> #v,c = pf.h.find_min("Density")
> #print v,c
> dd = pf.h.all_data()
> field = "Density"
> extreme = dd.quantities["Extrema"](field)[0]
> zmin = extreme[0]
> zmax = extreme[1]
> mean = dd.quantities["TotalQuantity"](field)[0]/res**3
> print ("min %16.16e" % zmin)
> print ("max %16.16e" % zmax)
> print ("mean %16.16e" % mean)
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20100618/93f37533/attachment.htm>


More information about the yt-users mailing list