Doing a lot of ways in numpy

Good morning, I am introducing a Cressman filter to calculate weight averages in Numpy. I use the Ball Tree implication (thanks to Jake VanderPlas) to return a list of locations for each point in the query array. The query array (q) is of the form [n, 3] and at each point has x, y, z at point I to make the weighted average of the points stored in the tree. the code wrapped around the tree returns points at a certain distance, so I get arrays of variable length arrays. I use where to look for non-empty records (i.e. positions where there were at least some points in the radius of influence), creating an isgood array ...

Then I iterate over all the query points to return a weighted average of self.z values ​​(note that this can be either dims = 1 or dims = 2 to allow multiple co-grid)

so the thing that complicates the use of a map or other faster methods is the uneven length of the arrays inside self.distances and self.locations ... I'm still pretty green to numpy / python, but I can't think of a way to make this array wise ( i.e. do not return to loops)

self.locations, self.distances = self.tree.query_radius( q, r, return_distance=True)
t2=time()
if debug: print "Removing voids"
isgood=np.where( np.array([len(x) for x in self.locations])!=0)[0]
interpol = np.zeros( (len(self.locations),) + np.shape(self.z[0]) )
interpol.fill(np.nan)
for dist, ix, posn, roi in zip(self.distances[isgood], self.locations[isgood], isgood, r[isgood]):
    interpol[isgood[jinterpol]] = np.average(self.z[ix], weights=(roi**2-dist**2) / (roi**2 + dist**2), axis=0)
    jinterpol += 1

so ... Any tips on how to speed up the loop? ..

, , , , 240x240x34 4 , 99 ( C cython.. , !) 100 , ... , , ? ? np.mean , , , ? float32, 64... ints ( ... !

+3
1

Cressman vs :

http://www.flame.org/~cdoswell/publications/radar_oa_00.pdf

( , ). , " ", , 0,01 ( - ).

? , , , , . , , ( ). , - ​​ . , .

0

All Articles