CNES / pangeo-pyinterp

Python library for optimized interpolation.
https://pangeo-pyinterp.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
117 stars 17 forks source link

Using Euclidean Coordinates #27

Open 0xJustin opened 6 months ago

0xJustin commented 6 months ago

Hi- your interpolation library is one of the fastest around with the C++ implementation. I was hoping to use some of these functions for a project where I have a large shape=(1540, 1049, 521) array with scattered data of 3D vectors (~10,000 scattered points). Your functions work very quickly, but the casting to spherical coordinates is throwing off my results! Is there a manual way around this? I see the system parameter for Rtree, but I'm having a hard time figuring out what the valid options are. Thanks for your time!

Here is my code snippet- force_locations is an mx3 array, where m is the number of scattered data

import pyinterp field = np.zeros((vessel_seg.shape[0], vessel_seg.shape[1], vessel_seg.shape[2], 3)) n, p, q = vessel_seg.shape

print("Interpolating IDW") mesh_x = pyinterp.RTree()

mesh_x.packing(force_locations[:], force_displacements[:, 0])

mx, my, mz = np.meshgrid(np.arange(n), np.arange(p), np.arange(q))

indexing='ij')

coords = np.vstack((mx.ravel(), my.ravel(), mz.ravel())).T

rbf_x, neighbors = mesh_x.radial_basis_function( coords, within=False, k=19,
rbf='cubic',

smooth=1e-4,

num_threads=0)

field[coords[:, 0], coords[:, 1], coords[:, 2], 0] = rbf_x