SourceSpec API

SourceSpec has a modular structure. Each module corresponds to a specific function or class of functions.

SourceSpec modules are presented below, following the logical order on which they’re used within source_spec.py.

ssp_setup

Setup functions for sourcespec.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>, Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_setup.configure(progname='source_spec')[source]

Parse command line arguments and read config file.

Returns a Config object.

ssp_setup.dprint(string)[source]

Print debug information.

ssp_setup.save_config(config)[source]

Save config file to output dir.

ssp_setup.setup_logging(config, basename=None, progname='source_spec')[source]

Setup the logging infrastructure.

This function is typically called twice: the first time without basename and a second time with a basename (typically the eventid). When called the second time, the previous logfile is renamed using the given basename.

ssp_read_traces

Read traces in multiple formats of data and metadata.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>,

Sophie Lambotte <sophie.lambotte@unistra.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_read_traces.read_traces(config)[source]

Read traces, store waveforms and metadata.

ssp_process_traces

Trace processing for sourcespec.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_process_traces.process_traces(config, st)[source]

Remove mean, deconvolve and ignore unwanted components.

ssp_build_spectra

Build spectral objects.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>, Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_build_spectra.build_spectra(config, st, noise_weight=False)[source]

Build spectra and the spec_st object.

Computes S-wave (displacement) spectra from accelerometers and velocimeters, uncorrected for attenuation, corrected for instrumental constants, normalized by hypocentral distance.

ssp_plot_traces

Trace plotting routine.

copyright:2015-2021 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)
ssp_plot_traces.plot_traces(config, st, spec_st=None, ncols=4, block=True, async_plotter=None)[source]

Plot displacement traces.

Display to screen and/or save to file.

ssp_local_magnitude

Local magnitude calculation for sourcespec.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_local_magnitude.local_magnitude(config, st, proc_st, sourcepar, sourcepar_err)[source]

Compute local magnitude from max absolute W-A amplitude.

ssp_inversion

Spectral inversion routines for sourcespec.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>, Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_inversion.spectral_inversion(config, spec_st, weight_st)[source]

Inversion of displacement spectra.

ssp_spectral_model

Spectral model and objective function.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>, Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_spectral_model.objective_func(xdata, ydata, weight)[source]

Objective function generator for bounded inversion.

ssp_spectral_model.spectral_model(freq, Mw, fc, t_star, alpha=1.0)[source]

Spectral model.

\[Y_{data} = M_w + \frac{2}{3} \left[ - \log_{10} \left( 1+\left(\frac{f}{f_c}\right)^2 \right) - \pi \, f t^* \log_{10} e \right]\]

see source_spec for a detailed derivation of this model.

ssp_residuals

Spectral residual routine for sourcespec.

copyright:
2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_residuals.spectral_residuals(config, spec_st, sourcepar_mean)[source]

Compute spectral residuals with respect to an average spectral model.

Saves a stream of residuals to disk using pickle.

ssp_correction

Spectral station correction calculated from ssp_residuals.

copyright:
2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Agnes Chounet <chounet@ipgp.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_correction.station_correction(spec_st, config)[source]

Correct spectra using station-average residuals.

Residuals are obtained from a previous run.

ssp_output

Output functions for source_spec.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_output.write_output(config, sourcepar, sourcepar_err)[source]

Write results to a plain text file and/or to a SQLite database file.

ssp_plot_spectra

Spectral plotting routine.

copyright:

2012 Claudio Satriano <satriano@ipgp.fr>

2013-2014 Claudio Satriano <satriano@ipgp.fr>,

Emanuela Matrullo <matrullo@geologie.ens.fr>

2015-2021 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)

ssp_plot_spectra.plot_spectra(config, spec_st, specnoise_st=None, ncols=4, stack_plots=False, plottype='regular', async_plotter=None)[source]

Plot spectra for signal and noise.

Display to screen and/or save to file.

ssp_util

Utility functions for sourcespec.

copyright:2012-2021 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)
ssp_util.calc_dist(lat1, lon1, lat2, lon2)[source]

Distance between two point on the earth, in kilometers.

Haversine formula: http://www.movable-type.co.uk/scripts/latlong.html

ssp_util.hypo_dist(trace)[source]

Compute hypocentral and epicentral distance (in km) for a trace.

ssp_util.mag_to_moment(magnitude)[source]

Convert magnitude to moment.

ssp_util.moment_to_mag(moment)[source]

Convert moment to magnitude.

ssp_util.select_trace(stream, traceid, instrtype)[source]

Select trace from stream using traceid and instrument type.

spectrum

A Spectrum() class defined as a modification of the ObsPy class Trace().

Provides the high-level function do_spectrum() and the low-level funciton do_fft().

copyright:2012-2021 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)
spectrum.do_fft(signal, delta)[source]

Compute the complex Fourier transform of a signal.

spectrum.do_spectrum(trace)[source]

Compute the spectrum of an ObsPy Trace object.

config

Config class for sourcespec.

copyright:2013-2021 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement, Version 2.1 (http://www.cecill.info/index.en.html)
class config.Config[source]

Config class for sourcespec.