[yt-users] Counting number of cells

Devan Conroy devan.conroy at student.fairfield.edu
Fri Jul 27 11:00:51 PDT 2012


Thanks so much, Greg!

On Fri, Jul 27, 2012 at 9:46 AM, Greg Meece <meecegr at gmail.com> wrote:

> 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
>>
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>


-- 
Devan Conroy
Fairfield University 2013
Mathematics Major
Computer Science/French Minor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20120727/8622fda0/attachment.html>


More information about the yt-users mailing list