[yt-users] Another data structure question

Matthew Turk matthewturk at gmail.com
Wed Nov 9 03:45:30 PST 2011


Hi Elizabeth,

On Wed, Nov 9, 2011 at 4:55 AM, Elizabeth Tasker
<tasker at astro1.sci.hokudai.ac.jp> wrote:
> Hi,
>
> Another question about yt data structures.
>
> If I have:
>
> dd = pf.h.all_data()
>
> Then dd["Density"] contains all the density values in all the cells on all the grids?

Nope -- it contains the highest resolution values.  No spatial
locations are duplicated.  But otherwise, yes, this is how it works.
Note that Density is not read & concatenated until asked for.

> Given that, how does the indexing work? For instance:
>
> dd["Density"][100]
>
> is a single value, so have the grids and cells been numbered such that each cell in the simulation has a unique index?

Each cell in that data object has a unique index; if I make a slice or
a sphere, the index will be different.  Index 100 will refer to the
same cell independent of which field you are indexing.

> And if that's true, then
>
>
> dd["TotalEnergy"][100]
>
> is guaranteed to be the same cell?

Yes.  The ordering and indexing is typically done by flattening masked
arrays of all the grids, where the grids are ordered typically either
from finest to coarsest or coarsest to finest.

>
> Finally, if I know the grid number and cell index of a cell I want to mark (e.g. via Sam's neighbour finding routine: grids, cis = kd.locate_neighbors_from_position(position) ), then can I work out what its uniform index will be such that I can then do:
>
> newfield = na.zeros(dd["x"].shape, dtype='float64')
>
> newfield[index] = value-of-my-choice

I don't think this is going to be easy; I think your better bet is to
mark individual grids and then have the 3D regions extract that
information.

-Matt

>
> ?
>
> Thank you!
>
> 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