-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ENH: Rbf interpolation of large multi-dimensional data #9215
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
Conversation
d067cb9
to
bf6aee4
Compare
Thanks @jrsassen.
sounds good
yes that makes sense
Unfortunately we cannot do this - it will break |
Thanks for the feedback, @rgommers
Yes, you're right, that was a bit extreme. At first I thought it would be necessary, but I was mistaken. I have removed this change. |
@jrsassen if you don't mind, could you open a separate PR for just the performance improvement with |
scipy/interpolate/rbf.py
Outdated
array of distance. E.g, the default: 'euclidean', such that the result | ||
is a matrix of the distances from each point in ``x1`` to each point in | ||
``x2``. For more options, see documentation of | ||
scipy.spatial.distances.cdist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, plus use backticks to create a link: `scipy.spatial.distance.cdist`
CI failure is unrelated |
Sorry, not awake yet - CI failure is in
|
I have opened a separate PR #9222 for the 'spatial.distance' part as requested. I also understand the problem CI turns up, the interface (esp. the return value of |
gh-9222 is merged, this can now be rebased on master |
Finally got around to it, also fixed the problem that CI reported before. |
scipy/interpolate/rbf.py
Outdated
@@ -192,9 +193,14 @@ def __init__(self, *args, **kwargs): | |||
self.xi = np.asarray([np.asarray(a, dtype=np.float_).flatten() | |||
for a in args[:-1]]) | |||
self.N = self.xi.shape[-1] | |||
self.di = np.asarray(args[-1]).flatten() | |||
self.di = np.asarray(args[-1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a backwards compatibility break, in two ways:
di
is public, and you're changing its shape for >1-D input- you're using
di.ndim
as an indication that the interpolation should now be multi-dimensional.
This should be avoided. I suspect that there's no better way than adding a new keyword argument (e.g. flatten=True
or `mode='1-D') that preserves backwards compat but allows the user to enable multi-dim interpolation.
Needs a rebase again |
So far, Rbf only allowed for the interpolation of one-dimensional data. This commit introduces the necessary changes to allow component-wise interpolation of multi-dimensional data. The resulting linear system has to be solved onces per target dimension, hence LU factorization is used.
Hey, I rebased and introduced |
Looks good. Let's get this in before it needs one more rebase. Sorry it took so long @jrsassen, and thanks! |
So far, scipy.interpolate.Rbf could only be used to interpolate one-dimensional functions, I added the capability to also interpolate multi-dimensional functions.
Furthermore, I changed the way the norm is computed in Rbf to exploit the much faster implementations from scipy.spatial.distance.
Lastly, I also aligned the interface of Rbf to other interpolations in scipy.interpolate such as griddata or LinearNDInterpolator.
Example usage: