obspy.signal.spectral_estimation.PPSD¶
-
class
PPSD
(stats, metadata, skip_on_gaps=False, db_bins=(-200, -50, 1.0), ppsd_length=3600.0, overlap=0.5, special_handling=None, period_smoothing_width_octaves=1.0, period_step_octaves=0.125, period_limits=None, **kwargs)[source]¶ Bases:
object
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 [Peterson1993].
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_processed) []
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) # doctest: +SKIP >>> print(ppsd.times) # doctest: +SKIP >>> ppsd.plot() # doctest: +SKIP
… 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 numpy npz compressed binary file:
>>> ppsd.save_npz("myfile.npz") # doctest: +SKIP
The saved PPSD can then be loaded again using the static method
load_npz()
, e.g. to plot the results again. If additional data is to be processed (note that another option is to combine multiple npz files usingadd_npz()
), metadata must be provided again, since they are not stored in the numpy npz file:>>> ppsd = PPSD.load_npz("myfile.npz") # doctest: +SKIP
Note
When using metadata from an
Inventory
, aParser
instance or from a RESP file, information on metadata will be correctly picked for the respective starttime of the data trace. This means that instrument changes are correctly taken into account during response removal. This is obviously not the case for a static PAZ dictionary!Attributes
NPZ_STORE_KEYS
NPZ_STORE_KEYS_ARRAY_TYPES
NPZ_STORE_KEYS_LIST_TYPES
NPZ_STORE_KEYS_SIMPLE_TYPES
NPZ_STORE_KEYS_VERSION_NUMBERS
__dict__
__doc__
__module__
__weakref__
list of weak references to the object (if defined)
channel
current_histogram
current_histogram_count
current_histogram_cumulative
current_times_used
db_bin_centers
db_bin_edges
delta
len
Trace length for one psd segment.
location
merge_method
network
nfft
nlap
period_bin_centers
Return centers of period bins (geometric mean of left and right edge of period smoothing ranges).
period_bin_left_edges
Returns left edges of period bins (same length as number of bins).
period_bin_right_edges
Returns right edges of period bins (same length as number of bins).
period_xedges
Returns edges of period histogram bins (one element longer than number of bins).
psd_frequencies
psd_periods
psd_values
Returns all individual smoothed psd arrays as a list.
station
step
Time step between start times of adjacent psd segments in seconds (assuming gap-less data).
times_data
times_gaps
times_processed
Public Methods
Process all traces with compatible information and add their spectral estimates to the histogram containing the probabilistic psd.
Add previously computed PPSD results to current PPSD instance.
Calculate and set current 2D histogram stack, optionally with start- and endtime and time of day restrictions.
Extract PSD values for given period in seconds.
Returns periods and mean psd values (i.e.
Returns periods and mode psd values (i.e.
Returns periods and approximate psd values for given percentile value.
Load previously computed PPSD results.
Plot the 2D histogram of the current PPSD.
Plot the data coverage of the histogram of the current PPSD.
Plot the temporal evolution of the PSD in a spectrogram-like plot.
Plot the evolution of PSD value of one (or more) period bins over time.
Saves the PPSD as a compressed numpy binary (npz format).
Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
Checks if the given UTCDateTime is already part of the current PPSD instance.
Gets gap information of stream and adds the encountered gaps to the gap list of the PPSD instance.
Gets gap information of stream and adds the encountered gaps to the gap list of the PPSD instance.
Inserts the given UTCDateTime and processed/octave-binned spectrum at the right position in the lists, keeping the order intact.
Helper function to plot coverage into given axes.
Processes a segment of data and save the psd information.
Checks if trace is compatible for use in the current PPSD instance.
See
PPSD.add_npz()
.Helper routine to get a list of 2-tuples with gapless portions of processed PPSD time ranges.
Reuse a previously created figure returned by
plot(show=False)()
and plot the current histogram stack (pre-computed usingcalculate_histogram()
) into the figure.Set up period binning.
For details on restrictions see
calculate_histogram()
.Special Methods
Default dir() implementation.
Default object formatter.
Initialize the PPSD object setting all fixed information on the station that should not change afterwards to guarantee consistent spectral estimates.
This method is called when a class is subclassed.
Create and return a new object.
Helper for pickle.
Helper for pickle.
Size of object in memory, in bytes.
Abstract classes can override this to customize issubclass().