SpecMod

A Python toolbox for processing and modelling seismic spectra: cut a window, estimate its spectrum, decide which part of it is above the noise, and fit a source model to that band.

import specmod.preprocess as pre
from specmod.pipeline import spectrum_set_from_streams
from specmod.fitting import FitSpectra

stream = pre.with_picks(stream, "event.xml")
signal = pre.s_window(stream, rafp=0.8, tafs=20)
noise = pre.get_noise_p(stream, signal)

spectra = spectrum_set_from_streams(signal, noise)
fits = FitSpectra(spectra)
fits.fit_spectra()
print(fits.table[["id", "llpsp", "fc", "ts"]])

Where to go

Getting started

Install it, run one event end to end with the tutorial, and — if you have code written against 0.1 — find out what moved.

Guides

What each stage does and why, and where the conventions are stated: the amplitude convention, the Parseval contract, and the moment and magnitude equations.

API reference

Every public object. specmod.api is the narrower, more stable subset to import from if you are building on this.

Working on SpecMod

The roadmap, the developer guide, how this site is built, and how a merged commit becomes a release.

Two things worth knowing early

Units are typed. A spectrum carries its ground-motion domain and amplitude convention as attributes. Converting between them is a method that returns a new spectrum, so a moment computed from the wrong domain is a type error rather than a wrong number.

Fit in the units the sensor recorded. Integrating to displacement implicitly low-passes and differentiating to acceleration amplifies high-frequency noise, so the record to fit is the one that was measured. The model carries a motion factor, so the plateau it reports is the displacement one either way.