[yt-users] Accessing less refined grids

Matthew Turk matthewturk at gmail.com
Fri Dec 9 05:01:20 PST 2011


Hi Elizabeth,

On Fri, Dec 9, 2011 at 6:53 AM, Elizabeth Tasker
<tasker at astro1.sci.hokudai.ac.jp> wrote:
> Hi,
>
> Is there an easy way of grabbing the value of the grid above (one less
> refined) than the current one? e.g. if I had the grid and cell number
> of a cell, could I deduce the grid and cell number of its parent?
>

Yup.  This could probably be made easier, by supplying a function or
something to some helper routine, but here's the way to figure it out.
 The details will vary if your grid has multiple parents, which is
possible in Enzo with particular choices of static refinement and is
possible in other codes like Boxlib-based codes.

In yt grids have the property Parent, which if there is one will be
another Grid, if there is none will be None, and if there are multiple
will be a list of grids.  You can also get the integer index of the
upper left edge of the grid, with respect to the dimensions on that
level.  So you can do:

ind = g.get_global_startindex()
parent = g.Parent
pind = ind/pf.refine_by - parent.get_global_startindex()

Then pind should refer to the i,j,k of the upper left edge of the
grid.  You can now apply offsets.  If you want to take a look at a
place where yt does this internally, yt/data_objects/grid_patch.py in
the fill_child_mask routine there is code that works similarly.

> I need to look at a smoothed field, which I could calculate, but it
> would just be equivalent to the less refined level, so I wondered if
> there was an easier way.

I hope so!  Let us know how it goes.

-Matt

>
> Elizabeth
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org



More information about the yt-users mailing list