Coverage for /opt/obspy/update-docs/src/obspy/obspy/signal/tests/test_spectral_estimation : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*- The psd test suite. """
welch_taper
""" Test cases for psd. """ # directory where the test files are located
""" Test to compare results of PITSA's psd routine to the :func:`matplotlib.mlab.psd` routine wrapped in :func:`obspy.signal.spectral_estimation.psd`. The test works on 8192 samples long gaussian noise with a standard deviation of 0.1 generated with PITSA, sampling rate for processing in PITSA was 100.0 Hz, length of nfft 512 samples. The overlap in PITSA cannot be controlled directly, instead only the number of overlapping segments can be specified. Therefore the test works with zero overlap to have full control over the data segments used in the psd. It seems that PITSA has one frequency entry more, i.e. the psd is one point longer. I dont know were this can come from, for now this last sample in the psd is ignored. """
# in principle to mimic PITSA's results detrend should be specified as # some linear detrending (e.g. from matplotlib.mlab.detrend_linear) window=welch_taper, noverlap=NOVERLAP)
# mlab's psd routine returns Nyquist frequency as last entry, PITSA # seems to omit it and returns a psd one frequency sample shorter.
# test results. first couple of frequencies match not as exactly as all # the rest, test them separately with a little more allowance.. decimal=4) decimal=5) decimal=6)
""" Test that the helper function to generate the welch window delivers the same results as PITSA's routine. Testing both even and odd values for length of window. Not testing strange cases like length <5, though. """
""" Test PPSD routine with some real data. Data was downsampled to 100Hz so the ppsd is a bit distorted which does not matter for the purpose of testing. """ # load test file 'BW.KW1._.EHZ.D.2011.090_downsampled.asc.gz') 'BW.KW1._.EHZ.D.2011.090_downsampled__ppsd_hist_stack.npy') 'BW.KW1._.EHZ.D.2011.090_downsampled__ppsd_mixed.npz') # parameters for the test 'calib': 1.0, 'channel': 'EHZ', 'delta': 0.01, 'endtime': UTCDateTime(2011, 3, 31, 2, 36, 0, 180000), 'location': '', 'mseed': {'dataquality': 'D', 'record_length': 512, 'encoding': 'STEIM2', 'byteorder': '>'}, 'network': 'BW', 'npts': 936001, 'sampling_rate': 100.0, 'starttime': UTCDateTime(2011, 3, 31, 0, 0, 0, 180000), 'station': 'KW1'} 'poles': [(-0.037004 + 0.037016j), (-0.037004 - 0.037016j), (-251.33 + 0j), (-131.04 - 467.29j), (-131.04 + 467.29j)], 'sensitivity': 2516778400.0, 'zeros': [0j, 0j]} # read results and compare # add the same data a second time (which should do nothing at all) and # test again - but it will raise UserWarnings, which we omit for now # test the binning arrays
if __name__ == '__main__': unittest.main(defaultTest='suite') |