obspy / obspy

ObsPy: A Python Toolbox for seismology/seismological observatories.
https://www.obspy.org
Other
1.15k stars 530 forks source link

Downsampling / Resampling using scipy.signal.resample #314

Closed trac2github closed 12 years ago

trac2github commented 12 years ago

Downsampling by now is only done by lowpass filtering and integer decimation. Might be convinient to wrap scipy.signal.resample in Trace and Stream. As far as I see, scipy.signal.resample is equivalent to the exact reconstruction but done in frequency domain:

[http://en.wikipedia.org/wiki/Sampling_theorem#Reconstruction]

[http://en.wikipedia.org/wiki/Whittaker%E2%80%93Shannon_interpolation_formula]

Opinions, comments, experience with this?

Martin

trac2github commented 12 years ago

[barsch] +1 - but should be wrapped in obspy.signal to make sure that scipy as dependency is installed

trac2github commented 12 years ago

[beyreuth] yes, resample is a correct functions for this. We discussed this before but did not find time to implement it..., so +1 from too

trac2github commented 12 years ago

[driel] I read a bit more into the theory, and there is one difference to resampling using the sampling theoreme: in fourier domain, it is assumed, that the function is periodic. This leads to 'ringing', if the function does not go to zero at the boundaries. Zero padding might help, but I guess FFT makes detrending/tapering necessary to be stable in that case.

Also see [http://stackoverflow.com/questions/1851384/resampling-interpolating-matrix]

On the other hand, in timedomain it is quite expensive (N² compared to N log(N)).

So, I suggest to wrap the scipy function and add some comment in the docstring...

trac2github commented 12 years ago

[megies] would be very handy to have for a lot of people i imagine. i would also go for the scipy frequency domain routine. if tapering/detrending is necessary i would include it controlled via kwargs with the defaults being True.

trac2github commented 12 years ago

[barsch] In [3442/obspy]: {{{

!CommitTicketReference repository="obspy" revision="3442"

trac2github commented 12 years ago

[beyreuth] The new trace method now holds: {{{#!python 1264 from scipy.signal import resample 1265 factor = float(self.stats.npts) / num 1266 self.data = resample(self.data, num, window=window) 1267 self.stats.delta *= factor }}}

trac2github commented 12 years ago

[anonymous] I would suggest to make the lowpass filter optional (maybe default), because in some applications it is necessary to use some specific filter and then it is better to do that manually before the resampling. I had some issues with the old decimate routine because of that.

trac2github commented 12 years ago

[barsch] In [3773/obspy]: {{{

!CommitTicketReference repository="obspy" revision="3773"