I want to substitute the command of sac( http://www.iris.edu/files/sac-manual/commands/taper.html ):
TAPER TYPE HANNING WIDTH 0.05
with the equivalent one in obspy. I'm trying to use taper ( http://docs.obspy.org/packages/autogen/obspy.core.trace.Trace.taper.html?highlight=taper#obspy.core.trace.Trace.taper ) where type is hann and is specified by this function ( http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.hann.html#scipy.signal.hann ).
I don't understand how to do it.
Thank you, in advance
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
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)..
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))
trace.data = trace.data * 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,
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.
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.