obspy.core.preview.resample_preview

resample_preview(trace, samples, method='accurate')[source]

Resamples a preview Trace to the chosen number of samples.

Parameters:
  • trace (Trace) Trace object to be resampled.
  • samples (int) Desired number of samples.
  • method (str, optional) Resample method. Available are 'fast' and 'accurate'. Defaults to 'accurate'.

Notes

This method will destroy the data in the original Trace object. Deepcopy the Trace if you want to continue using the original data.

The fast method works by reshaping the data array to a sample x int(npts/samples) matrix (npts are the number of samples in the original trace) and taking the maximum of each row. Therefore the last npts - int(npts/samples)*samples will be omitted. The worst case scenario is resampling a 1999 samples array to 1000 samples. 999 samples, almost half the data will be omitted.

The accurate method has no such problems because it will move a window over the whole array and take the maximum for each window. It loops over each window and is up to 10 times slower than the fast method. This of course is highly depended on the number of wished samples and the original trace and usually the accurate method is still fast enough.