[yt-users] Counting number of cells

Greg Meece meecegr at gmail.com
Fri Jul 27 09:46:20 PDT 2012


Hi Devan,

The pf hierarchy contains data on the number of cells at each level. One
way to get the total number of cells in the simulation is below. It is
quite possible that there is a more elegant way to do this, but this worked
for me:

from yt.mods import *
from yt.utilities.definitions import MAXLEVEL

def cellCounter(filePath):
   pf = load(filePath)
   hir = pf.h

   sumCells = 0

   for i in range(MAXLEVEL):
      sumCells = sumCells + hir.level_stats['numcells'][i]

   return sumCells

--Greg


On Fri, Jul 27, 2012 at 12:29 PM, Devan Conroy <
devan.conroy at student.fairfield.edu> wrote:

> Hi all,
>
> My name is Devan Conroy and I am working at SLAC as a summer intern in the
> SULI program with Jeff Oishi.  I am trying to figure out how to count
> the number of cells in the grid when loading in data.  I tried using
> (len(DataIn)), but got the error: object of type 'AMRRegion' has no len().
>
> Any suggestions?
>
> Thank you,
> Devan Conroy
>
> --
> Devan Conroy
> Fairfield University 2013
> Mathematics Major
> Computer Science/French Minor
>
>
> _______________________________________________
> 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/20120727/8526e4d5/attachment.html>


More information about the yt-users mailing list