-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
ENH: Allow interp to process multiple signals by passing multidimensional fp #26433
Comments
FYI, I implemented the function
Interpolate at a single point:
Interpolate at a collection of
|
If I'm reading the SciPy docs correctly, |
Thanks ngoldbaum ... "scipy.interpolate.interp1d" is marked as legacy so I'd prefer to not rely on it. Its documentation points users to np.interp. |
Drive-by comment: a possible non-legacy scipy incantation would be |
Proposed new feature or change:
Consider multiple 1D signals with identical x-coordinate sample points. It is sometimes desired to resample all of these signals to the same interpolated x-coordinates via linear interpolation. Currently, this requires multiple calls to numpy.interp, one for each signal. This is wasteful, because it requires re-calculation of interpolation weights.
For example, consider original time sample coordinates of t, and updated time sample coordinates of t_new. Also, consider three signals sampled in this way: s0, s1, and s2. To resample all three with current methods:
s0_resamp = np.interp(t_new, t, s0)
s1_resamp = np.interp(t_new, t, s1)
s2_resamp = np.interp(t_new, t, s2)
It would be helpful to do this in a single call, like this:
s = np.row_stack((s0, s1, s2))
s_new = np.interp(t_new, t, s)
In this case, the number of rows in s_new would be 3 (the number of 1D signals). The number of columns in s_new would be len(t_new).
In general, fp could be any number of dimensions. Interpolation could be performed along the final dimension by default, with an additional optional input to specify a different dimension for interpolation.
Note: Matlab's interp1 function offers this functionality, as noted in the function description: "If you have multiple sets of data that are sampled at the same point coordinates, then you can pass v as an array."
The text was updated successfully, but these errors were encountered: