[yt-dev] A sketch for a cut_region selector

Nathan Goldbaum nathan12343 at gmail.com
Tue Nov 18 22:58:04 PST 2014


Hi all,

I spent some time tonight thinking of a way to supply a cut_region as a
data_source for a SlicePlot.

Right now this will raise a NotImplementedError, since cut_regions don't
work using selectors. Instead, they override data selection at the level of
the chunking system.  This is a problem for a SlicePlot, since a slice is
really a 2D selection object and makes use of a selector object to decide
whether or not data should be included in the slice. Cut regions
technically could be implemented using selectors, but they don't lend
themselves to the geometrically focused selector API.

One way around this is to eat some memory and pass the positions of cells
that pass the cut_region selection criteria down to the cython selector. Lo
and behold, it actually works!   Kind of.

I've pasted the necessary diff here: http://paste.yt-project.org/show/5210/

Here's an example script: http://paste.yt-project.org/show/5211/

After much gnashing of teeth (about 20 minutes worth on my laptop), this
should produce the following image: http://imgur.com/DlHruOi

The way I've done this is really bad: not only am I re-aquiring the GIL and
messing with python objects inside a tight cython function, but I'm also
using the python objects to do an O(N^2) search algorithm!

I think it's possible to speed this up significantly by using a smarter
search algorithm implemented in C.  Before I spend effort on that, I wanted
to send this e-mail out to summarize my thoughts and check to see if this
is a crazy approach.

If this is a worthy approach, does anyone know of an O(logN) search
algorithm I could use to find a 3D position in a list of 3D positions?

Thanks for taking a look :)

-Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20141118/6c9ef041/attachment.htm>


More information about the yt-dev mailing list