using taper function

Hi all,

I want to substitute the command of sac( ):


with the equivalent one in obspy. I'm trying to use taper ( ) where type is hann and is specified by this function ( ).
I don't understand how to do it.

Any suggestions?

Thank you, in advance

Hi Nikolaos,

I think this is not possible at the moment.
Of course you could do


but as far as I understand the window length is set implicitly to 0.5.
The only window type supporting a different window length is 'cosine'
via its parameter 'p' .



the "hann" taper is directly executed by scipy and, as Tom pointed out,
the corresponding scipy routine always tapers the whole length of the
time series.

So with the builtin taper it is not possible to do.
But writing a custom function that does the job is fairly easy.

Here's some (quick and dirty code)..

def my_hann_taper(trace):
    npts = trace.stats.npts
    window = scipy.signal.hann(int(0.05 * npts))
    wlen = len(window)
    left = window[:wlen]
    right = window[wlen:]
    middle = np.ones(int(0.95))
    window = np.concatenate((left, middle, right)) = * window

The rounding to ints for the length of the parts of the window would
need some attention to make sure you end up with a windowing function
that always fits the length of your data.

hope it helps,

Dear colleagues,

I cann't figure out what the problem I've been facing when using PPSD from OBSPY. The example data set as written in the tutorial works fine. But when I tried with my own data set, it fails and reported errors as attached below.

For understanding the example I write here: I am working with only 24-hours data (consisting of 24 1-hour files), 100 Hz sampling rate. The PPSD len(ppsd.times) resulted in 46 segments.

Any kind of comment and support is appreciated.

Best regards,


Sorry, this is actually a bug introduced in master (and not present in
the latest stable release 0.8.4) and tracked here:

Thanks for the feedback, I just fixed it for the file that was missing
in your case, so if you reinstall from master (as you likely did
before?), the problem should be gone.