obspy.signal.spectral_estimation.PPSD

class PPSD(stats, paz=None, parser=None, skip_on_gaps=False, is_rotational_data=False, db_bins=(-200, -50, 1.0), ppsd_length=3600.0, overlap=0.5, water_level=600.0)[source]

Class to compile probabilistic power spectral densities for one combination of network/station/location/channel/sampling_rate.

Calculations are based on the routine used by [McNamara2004]. For information on New High/Low Noise Model see [Peterson2003].

Basic Usage

>>> from obspy import read
>>> from obspy.signal import PPSD
>>> st = read()
>>> tr = st.select(channel="EHZ")[0]
>>> paz = {'gain': 60077000.0,
...        '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]}
>>> ppsd = PPSD(tr.stats, paz)
>>> print(ppsd.id)
BW.RJOB..EHZ
>>> print(ppsd.times)
[]

Now we could add data to the probabilistic psd (all processing like demeaning, tapering and so on is done internally) and plot it like ...

>>> ppsd.add(st) 
>>> print(ppsd.times) 
>>> ppsd.plot() 

... but the example stream is too short and does not contain enough data.

Note

For a real world example see the ObsPy Tutorial.

Saving and Loading

The PPSD object supports saving to a pickled file with optional compression:

>>> ppsd.save("myfile.pkl.bz2", compress=True) 

The saved PPSD can then be loaded again using the static method load(), e.g. to add more data or plot it again:

>>> ppsd = PPSD.load("myfile.pkl.bz2")  

The load() method detects compression automatically.

Note

While saving the PPSD with compression enabled takes significantly longer, it can reduce the resulting file size by more than 80%.

Note

It is safer (but a bit slower) to provide a Parser instance with information from e.g. a Dataless SEED than to just provide a static PAZ dictionary.

Attributes

__doc__ unicode(string [, encoding[, errors]]) -> object
__module__ str(object) -> string

Public Methods

add Process all traces with compatible information and add their spectral estimates to the histogram containing the probabilistic psd.
get_mean Returns periods and mean psd values (i.e.
get_mode Returns periods and mode psd values (i.e.
get_percentile Returns periods and approximate psd values for given percentile value.
plot Plot the 2D histogram of the current PPSD.
plot_coverage Plot the data coverage of the histogram of the current PPSD.
save Saves the PPSD as a pickled file with optional compression.

Private Methods

_PPSD__check_ppsd_length Adds ppsd_length and overlap attributes if not existing.
_PPSD__check_time_present Checks if the given UTCDateTime is already part of the current PPSD
_PPSD__get_normalized_cumulative_histogram Returns the current histogram in a cumulative version normalized per period column, i.e.
_PPSD__insert_data_times Gets gap information of stream and adds the encountered gaps to the gap
_PPSD__insert_gap_times Gets gap information of stream and adds the encountered gaps to the gap
_PPSD__insert_used_time Inserts the given UTCDateTime at the right position in the list keeping
_PPSD__plot_coverage Helper function to plot coverage into given axes.
_PPSD__process Processes a segment of data and adds the information to the
_PPSD__sanity_check Checks if trace is compatible for use in the current PPSD instance.
_PPSD__setup_bins Makes an initial dummy psd and thus sets up the bins and all the rest.

Special Methods

__init__ Initialize the PPSD object setting all fixed information on the station