[SciPy-User] Strange behaviour of scipy.interpolate.interp1d in with kind="zero"
Propadovic Nenad
npropadovic at gmail.com
Thu Jun 22 03:12:44 EDT 2017
Hello Oleksandr,
thank you for the swift answer.
I think we can settle for an untreated edge case and/or an inconsistency.
The values at times 0.004, 0.008, 0.012, 0.016 are exactly what I expect,
after all: the exact values that the original signal at the exact points in
time.
I will file a bug, as you proposed.
Regards,
Nenad
> Hi Nenad:
>
> This probably how the kind="zero" is implemented (uses a constant value
> from the left side of the interval) and since in your case you do not have
> any data to the right of the point, it is never used.
>
> Maybe it could be called bug.... (You could try to submit an issue on
> github)
>
> Apparently, now for it to work as you want, you would need to extend your
> sig a bit:
>
> import numpy
> from scipy.interpolate import interp1d
> t = numpy.array([0.000, 0.004, 0.008, 0.012, 0.016, 0.02, 0.03])
> sig = numpy.array([0, 1, 2, 3, 4, 5, 6])
> t_new = numpy.array([0.0, 0.001, 0.003, 0.004, 0.008, 0.012, 0.016, 0.0196,
> 0.02])
> f = interp1d(t, sig, kind='zero')
> s_resampled = f(t_new)
> print(s_resampled)
> [ 0. 0. 0. 1. 2. 3. 4. 4. 5.]
>
>
> Cheers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170622/4fbe8d8c/attachment.html>
More information about the SciPy-User
mailing list