Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Euclidean Coordinates #27

Closed
0xJustin opened this issue Feb 28, 2024 · 5 comments
Closed

Using Euclidean Coordinates #27

0xJustin opened this issue Feb 28, 2024 · 5 comments

Comments

@0xJustin
Copy link

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

@gusgustavsohn
Copy link

gusgustavsohn commented Nov 5, 2024

@0xJustin: We are on the same boat. This implementation is the best I have found so far, though I am not sure this can be used as is for a cartesian grid on a (flat) plane. Have you find a solution to this?

Could any of the developers shed a little light on to how to use (if possible) this package with planar coordinates?

Thanks for all your help, this is indeed a great implementation in terms of performance.

@0xJustin
Copy link
Author

0xJustin commented Nov 5, 2024

I ended up using this instead @gusgustavsohn https://smt.readthedocs.io/en/latest/

@gusgustavsohn
Copy link

@0xJustin : thanks for your quick answer! I'll take a look into that link that you provided. Could you point me to a particular function there, or example to get me going? Could you elaborate on the performance? Does it use RTree as well? I have unstructured data made of 1 million points that would like to regrid to a 1000x1000 array ... pyinterp did that very quickly ...

@0xJustin
Copy link
Author

0xJustin commented Nov 5, 2024

@gusgustavsohn https://smt.readthedocs.io/en/latest/_src_docs/surrogate_models/rbf.html You can see some of the docs here. My problem was different enough that I probably can't speculate on performance, but it was pretty good - the rbf implementation here is fast. Their Kriging implementation is more accurate, but slower

fbriol added a commit that referenced this issue Nov 5, 2024
@fbriol
Copy link
Collaborator

fbriol commented Nov 5, 2024

On the master branch, I updated the RTree class to include an optional ecef keyword. By default, this is set to false, preserving the previous behavior. When set to true, it enables the use of Cartesian coordinates directly, bypassing any conversions between LLA and ECEF. Let me know if you’re able to run some tests; otherwise, I can take a look at it tomorrow afternoon.

@fbriol fbriol mentioned this issue Nov 7, 2024
@fbriol fbriol closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants