signal_spectrogram function

Calculate spectrograms (power spectral density estimates) from time series.

Calculate spectrograms (power spectral density estimates) from time series.

This function creates spectrograms from seismic signals. It supports the standard spectrogram approach and the Welch method.

signal_spectrogram( data, time, dt, Welch = FALSE, window, overlap = 0.5, window_sub, overlap_sub = 0.5, method = "periodogram", cpu = NULL, plot = FALSE, ... )

Arguments

  • data: Numeric vector or list of vectors, seismic signal to be processed.
  • time: POSIX.ct vector with time values. If omitted, an artificial time vector will be created, based on dt. Only needed if data is no eseis object.
  • dt: Numeric value, sampling period. If omitted, either estimated from time or set to 0.01 s (i.e., f = 100 Hz). Only needed if data is no eseis object.
  • Welch: Logical value, option to use the Welch method for calculations.
  • window: Numeric value, time window length in seconds used to calculate individual spectra. Set to 1 percent of the time series length by default.
  • overlap: Numeric value, fraction of window overlap.
  • window_sub: Numeric value, length of the sub-window in seconds used to calculate spectra. Only relevant if Welch = TRUE. If omitted, the sub-window length is set to 10 percent of the main window length.
  • overlap_sub: Numeric value, fraction of sub-window overlap.
  • method: Character value, method to calculate the spectra. One out of "periodogram" and "autoregressive". Default is "periodogram".
  • cpu: Numeric value between 0 and 1, fraction of CPU cores to use. If omitted, only one CPU is used.
  • plot: Logical value, toggle plot output. Default is FALSE. For more customised plotting see plot_spectrogram.
  • ...: Additional arguments passed to the function.

Returns

List with spectrogram matrix, time and frequency vectors.

Details

Data containing NA values is replaced by zeros and set to NA in the output data set.

Examples

## load example data set data("earthquake") ## calculate and plot PSD straight away P <- signal_spectrogram(data = s$BHZ, time = t, dt = 1 / 200, plot = TRUE) ## calculate and plot PSD with defined window sizes and the Welch method P <- signal_spectrogram(data = s$BHZ, time = t, dt = 1 / 200, window = 5, overlap = 0.9, window_sub = 3, overlap_sub = 0.9, Welch = TRUE, plot = TRUE)

Author(s)

Michael Dietze

  • Maintainer: Michael Dietze
  • License: GPL-3
  • Last published: 2025-03-25

Useful links