Counting number of cells
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
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@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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Thanks so much, Greg! On Fri, Jul 27, 2012 at 9:46 AM, Greg Meece <meecegr@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@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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Devan Conroy Fairfield University 2013 Mathematics Major Computer Science/French Minor
participants (2)
-
Devan Conroy
-
Greg Meece