[yt-users] selecting data by refinement level

Nathan Goldbaum nathan12343 at gmail.com
Wed Jun 7 12:00:44 PDT 2017


On Wed, Jun 7, 2017 at 11:56 AM, Matthew Turk <matthewturk at gmail.com> wrote:

> Great!  As a quick note, you can use `.d` as shorthand for
> `to_ndarray()`.  The YTArray it returns is a subclass of ndarray, so
> should in general be usable in both ways; as you probably figured out,
> if you do any manipulation of individual elements it adds overhead and
> (often frustrating, but hopefully ultimately helpful), restrictions on
> combining incorrect units unless you look at it as a strict ndarray.
>

One tiny note:

YTArray.d is short for YTArray.ndarray_view(), which returns a view onto
the array. This doesn't copy the underlying data.

YTArray.to_ndarray() is equivalend to YTArray.value or YTArray.v, whcih
returns an ndarray containing a copy of the underlying array data. Getting
a copy sometimes adds overhead.

Choosing whether or now you want a copy comes down to what exactly you are
doing, since copying adds overhead, but it also prevents silently
overwriting data in an unexpected, nonlocal fashion.


>
> On Wed, Jun 7, 2017 at 1:53 PM, Klaus Weide <klaus at flash.uchicago.edu>
> wrote:
> > On Wed, 7 Jun 2017, Matthew Turk wrote:
> >
> >> Hi Klaus,
> >>
> >> Whoops, I said "grid_collection" but I meant "data_collection".
> >
> > Thanks Matt. I have not tried the 'collection of grids' approach yet, but
> > the following does what I want:
> >
> >         ds = yt.load(dump_path)
> >
> >         ad = ds.all_data()
> >         if fine_only:
> >             maxreflevel = ad.index.grid_levels.max()
> >             print '*** Filtering data so that only FLASH refinement
> level {} cells are used'.format(maxreflevel+1)
> >             ad.min_level = maxreflevel
> >             ad.max_level = maxreflevel
> >             print 'These cover a volume of %s' % ad['cell_volume'].sum()
> >         # .....
> >         data = {}
> >         data['dens'] = ad['dens'].to_ndarray()
> >         # .....
> >
> >
> > Klaus
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170607/6450bc9f/attachment.htm>


More information about the yt-users mailing list