NOAA-ORR-ERD / cell_tree2d

Cell Tree data structure for fast searching of an unstructured grid for the polygon containing the specified point
16 stars 11 forks source link

API clean up? #7

Closed ChrisBarker-NOAA closed 7 years ago

ChrisBarker-NOAA commented 7 years ago

I noticed that there is:

CellTree.find_poly()

and

CelTree.multi_locate

these should either be merged -- allow multi-locate to take a single point (and jsut cal it locate, or ??)

or at least give them similar names.

jay-hennen commented 7 years ago

This has been done. Now use CellTree.locate(points) and it should work for singular (x,y), lists [(x1,y1),(x2,y2)], tuples, arrays, whatever. I've also moved the vectorization from cython into C, for quite a major speedup, apparently, and renamed several functions in the C as well

ChrisBarker-NOAA commented 7 years ago

great, thanks!

I wonder why the cython looping was slower? but whatever we're using C anyway, so why not?

jay-hennen commented 7 years ago

The loop was slower because there was just quantitatively more generated C code within the loop itself. Difference between calling a function once versus 70k times.

ChrisBarker-NOAA commented 7 years ago

ah, got it -- calling a function in a loop, rather than doing the actual work in the loop (kinds like inlining)