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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)

ssp_setup.configure(options, progname)[source]

Parse command line arguments and read config file.

Returns a Config object.

ssp_setup.dprint(string)[source]

Print debug information.

ssp_setup.move_outdir(config)[source]

Move outdir to a new dir named from evid.

ssp_setup.remove_old_outdir(config)[source]

Try to remove the old outdir.

ssp_setup.save_config(config)[source]

Save config file to output dir.

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

Set up 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-2022 Claudio Satriano <satriano@ipgp.fr>,

Sophie Lambotte <sophie.lambotte@unistra.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)

ssp_build_spectra.build_spectra(config, st)[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-2022 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)
ssp_plot_traces.plot_traces(config, st, spec_st=None, ncols=4, block=True, async_plotter=None)[source]

Plot traces in the original instrument unit (velocity or acceleration).

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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)

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

Compute local magnitude from max absolute W-A amplitude.

ssp_inversion

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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)

ssp_residuals.spectral_residuals(config, spec_st, sourcepar)[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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.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

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-2022 Claudio Satriano <satriano@ipgp.fr>

license:

CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)

ssp_plot_spectra.plot_spectra(config, spec_st, specnoise_st=None, ncols=4, stack_plots=False, plot_type='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-2022 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)
ssp_util.bsd(Mo_in_N_m, ra_in_m)[source]

Compute Brune stress drop in MPa.

Madariaga (2009), doi:10.1007/978-1-4419-7695-6_22, eq. 27

ssp_util.get_vel(lon, lat, depth, wave, config)[source]

Get velocity at a given point from NonLinLoc grid.

Fall back to config.vp or config.vs if no grid is defined.

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.quality_factor(hyp_dist_in_km, vs_in_km_per_s, t_star_in_s)[source]

Compute quality factor from t_star, distance and vs.

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

Select trace from stream using traceid and instrument type.

ssp_util.source_radius(fc_in_hz, vs_in_m_per_s)[source]

Compute source radius in meters.

Madariaga (2009), doi:10.1007/978-1-4419-7695-6_22, eq. 31

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-2022 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.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-2022 Claudio Satriano <satriano@ipgp.fr>
license:CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html)
class config.Config[source]

Config class for sourcespec.