relmt.main module#

Entry points for relMT command line interface.

relmt.main.admit_entry(config, directory=PosixPath('.'))[source]#

Admit amplitude measurements into the inversion

This function is called when executing ‘relmt admit’ from the command line.

Parameters:
  • config (Config) – Configuration object with admission parameters. Content of the file read by the ‘–config’ option.

  • directory (Path) – Root directory of the project, containing the ‘amplitude/’ subfolder. Path of the file referenced by the ‘–config’ option.

Return type:

None

relmt.main.align_entry(config, directory=PosixPath('.'), iteration=0, do_mccc=True, do_pca=True, overwrite=False)[source]#

Align waveform files and write results into next alignment directory.

This function is called when executing ‘relmt align’ from the command line.

Parameters:
  • config (Config) – Configuration object with alignment parameters. Content of the file read by the ‘–config’ option.

  • directory (Path) – Root directory of the project, containing the ‘data/’ and ‘align?/’ subfolders. Path of the file referenced by the ‘–config’ option.

  • iteration (int) – Current alignment iteration number. 0: read from ‘data/’, >0 read from alignment iteration folder. Number parsed to the ‘–alignment’ option.

  • do_mccc (bool) – Align by multi-channel cross-correlation. Activated by ‘–mccc’

  • do_pca (bool) – Align by principal component analysis. Activated by ‘–pca’

  • overwrite (bool) – Overwrite existing aligned waveform files. Activated by ‘–overwrite’

Return type:

None

relmt.main.amplitude_entry(config, directory=PosixPath('.'), iteration=0, overwrite=False)[source]#

Compute relative amplitude measurements and save to file.

This function is called when executing ‘relmt amplitude’ from the command line.

Parameters:
  • config (Config) – Configuration object with amplitude measurement parameters. Content of the file read by the ‘–config’ option.

  • directory (Path) – Root directory of the project, containing the ‘align?/’ and ‘amplitude/’ subfolders. Path of the file referenced by the ‘–config’ option.

  • iteration (int) – Read waveforms from this alignment iteration. 0: read from ‘data/’, >0 read from ‘align?’. Number parsed to the ‘–alignment’ option.

  • overwrite (bool) – Overwrite existing amplitude measurement and passband files. Activated by ‘–overwrite’

Return type:

None

relmt.main.exclude_entry(config, iteration=0, overwrite=False, directory=PosixPath('.'), do_nodata=False, do_snr=False, do_cc=False, do_ecn=False, cc_from_file=False)[source]#

Exclude phase observations based on waveform quality criteria.

Thresholds are read from the resective waveform header files and can be different for each phase. Default values from a default-hdr.yaml are respected. None thresholds are ignored.

This function is called when executing ‘relmt exclude’ from the command line.

Parameters:
  • config (Config) – Configuration object with station file. Content of the file read by the ‘–config’ option.

  • iteration (int) – Current alignment iteration number. 0: read from ‘data/’, >0 read from alignment iteration folder. Number parsed to the ‘–alignment’ option.

  • overwrite (bool) – Overwrite existing entry exclude file. Activated by ‘–overwrite’. If False, append to existing lists instead.

  • directory (Path) – Root directory of the project, containing the ‘data/’ and ‘align?/’ subfolders. Path of the file referenced by the ‘–config’ option.

  • do_nodata (bool) – Exclude traces with NaN data, null data or data with all values below absolute ‘null_threshold’. Activated by ‘–nodata’

  • do_snr (bool) – Exclude traces with signal-to-noise ratio below ‘min_signal_noise_ratio’. Activated by ‘–snr’

  • do_cc (bool) – Exclude traces with average cross-correlation below ‘min_correlation’. Activated by ‘–cc’

  • do_ecn (bool) – Exclude traces with expansion coefficient norm below ‘min_expansion_coefficient_norm’. Activated by ‘–ecn’

  • cc_from_file (bool) – Read cross-correlation values from alignment produre. Changes in time window and frequency band are then not considerd in the exclusion based on cc.

Return type:

None

relmt.main.get_arguments(args=None)[source]#

Collect the command line arguments.

Parameters:

args (list[str] | None) – List of command line arguments. If None, collect via ArgumentParser.

Returns:

NamespaceParsed arguments

relmt.main.main(args=None)[source]#

Entry point for the relMT command line interface

Parameters:

args – Optional list of command line arguments. If None, use sys.argv.

Returns:

None – Executes the selected subcommand and exits

relmt.main.make_parser()[source]#

Create the ArgumentParser for the relMT command line interface.

Return type:

ArgumentParser

relmt.main.plot_alignment_entry(arrf, config=None, do_exclude=False, sort='pci', highlight_events=[], cc_method='calculate', saveas=None, confirm=True)[source]#

Plot the waveform array and parameters relevant to judging the alignment

Parameters:
  • arrf (Path) – Path to the waveform array file to plot

  • config (Config | None) – Configuration object. If given, event and station tables are read from files specified in the configuration.

  • do_exclude (bool) – Read the exclude file and only plot events that are not excluded.

  • sort (str) – Sorting method for events. See plot.alignment for options.

  • highligh_events – List of event IDs to highlight in the plot.

  • cc_method (str) –

    Method to obtain the cross-correlation matrix:

    • ’calculate’: Re-calculate using current header values.

    • ’file’: Use cross-correlation values from alignment procedure. Faster, but cc values do not reflect changes in time window or filter band

    • ’none’: Do not show cc values.

  • saveas (str | None) – If given, save the figure to the given path instead of showing it

  • highlight_events (list[int])

  • confirm (bool)

Return type:

None

relmt.main.plot_amplitude_entry(ampfile, highlight=[], saveas=None)[source]#

Plot amlitude observations

Parameters:
  • ampfile (Path) – Path to the amplitude or amplitude-summary file to plot

  • highlight (list[int]) – List of event IDs to highlight in the plot.

  • saveas (Path | str | None) – If given, save the figure to this path instead of showing it interactively

Return type:

None

relmt.main.plot_connections_entry(ampfile, sfile=None, highlight=None, saveas=None)[source]#

Plot graph representation of amplitude-observation event connections.

Parameters:
  • ampfile (Path) – Path to the primary amplitude or amplitude-summary file to plot.

  • sfile (Path | None) – Optional second S-amplitude file to combine with the primary file.

  • highlight (list[int] | None) – Event IDs to highlight.

  • saveas (Path | str | None) – If given, save the figure to this path instead of showing it interactively.

Return type:

None

relmt.main.plot_mt_entry(mtfile, config, highlight=[], overlay_dc_at=1.0, sort_by=None, color_by=None, saveas=None)[source]#

Plot moment tensors

mtfile:

Path to the moment tensor file to plot

config:

Configuration object

highlight:

List of event IDs to highlight in the plot.

overlay_dc_at:

Overlay DC component at this fraction of the full moment

saveas:

If given, save the figure to this path instead of showing it interactively

sort_by:

Sorting method for MTs. One of:

  • None: as in file

  • ‘number’: Event ID

  • ‘name’: Event Name

  • ‘mag’: Input magnitude

  • ‘mw’: Relative moment magnitude

  • ‘gap’: Azimuthal gap (deg)

  • ‘links’: Total links

  • ‘p-links’: P links

  • ‘s-links’: S links

  • ‘moment-rms’: Moment RMS (scaled Nm)

  • ‘amplitude-rms’: Amplitude RMS

  • ‘boot-moment’: normalized Bootstrap Moment (Nm/M0)

  • ‘boot-kagan’: Bootstrap Kagan angle (deg)

color_by:

Color MTs by attribute. One of:

  • None: no coloring

  • ‘number’: Event ID

  • ‘name’: Event Name

  • ‘mag’: Input magnitude

  • ‘mw’: Relative moment magnitude

  • ‘gap’: Azimuthal gap (deg)

  • ‘links’: Total links

  • ‘p-links’: P links

  • ‘s-links’: S links

  • ‘moment-rms’: Moment RMS (scaled Nm)

  • ‘amplitude-rms’: Amplitude RMS

  • ‘boot-moment’: normalized Bootstrap Moment (Nm/M0)

  • ‘boot-kagan’: Bootstrap Kagan angle (deg)

Parameters:
Return type:

None

relmt.main.plot_spectra_entry(arrf, bandpf=None, highlight=[], integrate=False, saveas=None)[source]#

Plot spectra of the waveform array. Highlight events or filter bands

Parameters:
  • arrf (Path) – Path to the waveform array file to plot

  • bandpf (str | None) – Path to the bandpass filter file

  • highlight (list[int]) – List of event IDs to highlight in the plot.

  • integrate (bool) – Integrate waveforms

  • saveas (Path | str | None) – If given, save the figure to the given path instead of showing it

Return type:

None

relmt.main.solve_entry(config, directory=PosixPath('.'), do_predict=False, iteration=0)[source]#

Construct linear system ans solve for moment tensors.

This function is called when executing ‘relmt solve’ from the command line.

Parameters:
  • config (Config) – Configuration object with solver parameters. Content of the file read by the ‘–config’ option.

  • directory (Path) – Root directory of the project, containing the ‘amplitude/’ and ‘result/’ subfolders. Path of the file referenced by the ‘–config’ option.

  • do_predict – If True, additionaly predict amplitudes of the found solution. This option is slow.

  • iteration (int) – Current alignment iteration number. 0: read from ‘data/’, >0 read from alignment iteration folder. Number parsed to the ‘–alignment’ option. Only required when do_predict is True

Return type:

None