I have problems to calculate PPSDs for specific files. I tried to process years of data and noticed missing data coverage even though mseed files are there and seem to be all right. It applies to about 2/3 of all my files.
When calculating a ppsd for a single file, it works. But not, if there are several of those 'suspicious' files. Below I've put my script and necessary data to reproduce an example with two days of mseed data.
When calling ppsd.add for the second file, it returns false without giving more information of what is wrong.
Does anyone know, what could be the problem with the mseeds and how to fix it?
that's a problem of your data. It has problems with the sampling rate, I
suspect that's coming from buggy data loggers. In one file the sampling
rate is 50.0000114441 and in the other it's 50.0000228882, so looks like
a precision problem to me (at least I hope your data logger
In PPSD the first data added is determining the expected sampling rate
for all following data, otherwise it would get much more complicated
internally.
If you're sure that all of your data is 50 Hz and that this is merely a
bug of the data logger writing wrong sampling rate to miniseed, than you
could do something like..
for tr in st:
# just correct the wrong sampling rate, this is not doing resampling
if abs(tr.stats.sampling_rate - 50) < 1e-3:
tr.stats.sampling_rate = 50
ppsd.add(st)
Make sure to also set 50 as sampling rate for the stats object you use
to initialize the PPSD.. this is what determines the expected sampling
rate later on.
Also, like pointed out in the docs.. you should definitely use the
Parser object itself for the PPSD instead of the static PAZ, otherwise
you might get hurt by an instrument change.
cheers,
T
#!/usr/bin/env python3
import glob
from obspy import read
from obspy.io.xseed import Parser
from obspy.signal import PPSD