Expand description
Seismic PPSD (Probabilistic Power Spectral Density) computation.
A pure-Rust implementation of the McNamara & Buland (2004) PPSD algorithm,
matching ObsPy’s PPSD
output within 0.5 dB tolerance. Uses stationxml_rs::Response directly
for instrument response evaluation — no intermediate types needed.
§Algorithm
The PPSD pipeline for each time segment:
- Welch’s method — overlap-averaged periodogram with cosine taper and linear detrend
- Instrument response removal — evaluates PAZ, FIR, and Coefficients stages from
stationxml_rs::Response, then divides PSD by |H(f)|² - Velocity→acceleration correction — multiplies by ω² = (2πf)²
- dB conversion — 10 × log₁₀(PSD)
- Period binning — averages dB values into octave-spaced period bins
§Quick Start
use ppsd_rs::process_segment;
// Load inventory (FDSN StationXML or SC3ML — auto-detected)
let inv = stationxml_rs::read_from_file("IA.JAGI.xml").unwrap();
let channel = &inv.networks[0].stations[0].channels[0];
let response = channel.response.as_ref().unwrap();
let sample_rate = channel.sample_rate;
// Compute PSD for one segment
let result = process_segment(
&samples, sample_rate, nfft, nlap,
response, &psd_periods, &bin_left, &bin_right,
).unwrap();§Response Evaluation
eval_response walks all stages in a stationxml_rs::Response and computes
the combined |H(f)|²:
| Stage type | Type | Method |
|---|---|---|
| Sensor | stationxml_rs::PolesZeros | Laplace transfer function × gain |
| ADC | stationxml_rs::Coefficients (Digital) | DTFT of numerators × gain |
| FIR filter | stationxml_rs::FIR | DTFT with DC normalization × gain |
| Gain-only | (none of above) | gain² |
FIR coefficients are DC-normalized to match evalresp behavior.
stationxml_rs::Symmetry expansion is handled automatically
(None = all coefficients, Even = mirror, Odd = mirror with negation).
Enums§
- Ppsd
Error - Errors that can occur during PSD computation.
Functions§
- cosine_
taper - Cosine taper (Tukey window) matching ObsPy’s
cosine_taper(npts, p). - eval_
response - Evaluate full instrument response |H(f)|² at given frequencies.
- fft_
power - Compute one-sided power spectrum via real FFT.
- konno_
ohmachi_ smooth - Konno-Ohmachi log-frequency spectral smoothing.
- period_
bin_ average - Bin PSD values into period bins by averaging (ObsPy style).
- process_
segment - Process one PPSD segment, replicating ObsPy’s
PPSD.__processexactly. - setup_
period_ binning - Compute period binning edges matching ObsPy
PPSD._setup_period_binning. - welch_
psd - Compute PSD using Welch’s method matching ObsPy/matplotlib’s
mlab.psd.
Type Aliases§
- Result
- Result type for ppsd operations.