Closed cristi-neagu closed 6 years ago
Hello Cristi,
this is similar to issue #90
It is, yes. I didn't notice it because it was a secondary issue, different from the original title. In any case, i feel it merits its own tracker.
Thanks for the tip Cristi yes indeed already issued, thanks Daniel, definitely needed :) scipy is already an optional dependency for export to netcdf or matlab, so why not adding this interpolation. however I am wondering how it performs against searchsorted used by Daniel ?
On my system, scipy does perform 2-3 times worse than searchsorted, over about 765000 data points. The worst performance i got was about 60ms, which is still reasonably fast. Both methods work just as well. Searchsorted has the advantage of speed, while scipy is more readable, in my opinion.
@cristi-neagu nice find. It does exactly what my implementation does; I'm thinking of adding script to the dependency list and use interp1d
After a few tests it seems that interp1d is 3x slower and raises exception for new timestamps outside the initial timestamp interval.
interp1d can be asked to either replace any values outside of bounds with given values, or extrapolate data, by using fill_value
.
You're right. One has to decide if the speed penalty is acceptable or not.
Hi, I put Daniel's snippet (thanks) for interpolation in last mdfreader commit. Can you check if that suits you ?
That code works perfectly. Thanks.
Fixed in d1d9a45
Resampling integer channels should not be done with linear interpolation (np.interp). Consider using scipy.interpolate.interp1d(kind='zero') instead. This could be hardcoded, or, if more flexibility is desired, give the user the option to specify zero order interpolation for integer signals.
The downside is that it would introduce an extra dependency on scipy in the mdf module.