relmt.extra module#

relmt.extra.apparent_corner_frequency(sig, sampling_rate, fmin=None, fmax=None)[source]#

Find apparant corner frequency in velocity spectrum of 1D seismogram

Parameters:
  • sig (ndarray) – (samples,) velocity seismogram

  • sampling_rate (float) – in Hertz

  • fmin (float | None) – Minimum, maximum frequency to test (Hz)

  • fmax (float | None) – Minimum, maximum frequency to test (Hz)

Returns:

floatMaximum of the spectrum (Hz)

Attention

Depends on multitaper

relmt.extra.focal_mechanism_to_mt(strike, dip, rake, magnitude=None)[source]#

Convert focal mechanism to moment tensor

Parameters:
Return type:

MT | list[MT]

relmt.extra.geoconverter_latlon2utm(latitude, longitude, depth, utm_num, utm_let)[source]#

Convert geographic to local UTM coordinates

Parameters:
  • latitude (float) – Geographic coordinates (degree)

  • longitude (float) – Geographic coordinates (degree)

  • depth (float) – Positive down in kilometers

  • utm_num (int) – UTM zone number

  • utm_let (str) – UTM zone letter

Returns:

north, east, depth (float) – Local UTM coordinates in meters

Hint

Wrap into a custom function to use as a geoconverter when reading station or event tables

def geconverter_oslo(lat, lon, dep):
    return geoconverter_latlon2utm(lat, lon, dep, 32, "V")

Attention

Depends on utm

relmt.extra.geoconverter_utm2latlon(northing, easting, depth, utm_num, utm_let)[source]#

Convert geographic to local UTM coordinates

Parameters:
  • northing (float) – Cartesian coordinates (meters)

  • easting (float) – Cartesian coordinates (meters)

  • depth (float) – Positive down in meters

  • utm_num (int) – UTM zone number

  • utm_let (str) – UTM zone letter

Returns:

latitude, longitude, depth (float) – Geographical coordinates in degree and kilometers

Attention

Depends on utm

relmt.extra.get_utm_zone(latitudes, longitudes)[source]#

Get UTM zone number and letter from coordinates.

Parameters:
  • latitudes (Iterable[float]) – Geographical coordinates to include in estimate

  • longitudes (Iterable[float]) – Geographical coordinates to include in estimate

Returns:

  • num (int) – Consensus UTM zone number

  • let (str) – Consensus UTM zone letter

Raises:

LookupError: – If coordinates exceed one zone.

Attention

Depends on utm

relmt.extra.make_waveform_array(header, phase_dict, stream)[source]#

Isolate time windows around picks and write to waveform array

Parameters:
Returns:

Attention

Depends on obspy

relmt.extra.optimal_bandpass(wvarr, sampling_rate, data_window, phase_start, phase_end, fmin=None, fmax=None, min_snr=0)[source]#

Find bandpass with signal-to-noise ratio above threshold

Parameters:
  • wvarr (ndarray) – 1D or 2D array holding the velocity event waveform(s)

  • fmin (float | None) – Minimum, maximum frequency to consider

  • fmax (float | None) – Minimum, maximum frequency to consider

  • min_snr (float) – Minimum signal to noise ratio (dB) to include

Returns:

highpass, lowpass (float) – Optimal filter corners (Hz)

Attention

Depends on multitaper

Parameters:
relmt.extra.read_catalog_picks(catalog, event_dict, include_at=inf)[source]#

Read arrival times from ObsPy Catalog object

Parameters:
  • catalog (obspy.core.event.catalog.Catalog) – Must contain station codes, phases, and arrival times.

  • event_dict (dict[str, Event]) – The seismic event catalog

  • include_at (float) – Include picks within this time difference between event_dict and catalog origin times (seconds)

Returns:

dict[str, Phase]Phase dictionary

Attention

Depends on obspy

relmt.extra.read_obspy_inventory_files(filenames)[source]#

Read station files using obspy.core.inventory.inventory.read_inventory()

Parameters:

filenames (Iterable[str]) – Names of the compliant inventroy files

Returns:

obspy.core.inventory.inventory.Inventory

Attention

Depends on obspy

relmt.extra.read_station_inventory(inventory, geoconverter, strict=True)[source]#
Parameters:
  • inventory (obspy.core.inventory.inventory.Inventory) – Must contain network and station codes, and coordinates.

  • geoconverter (Callable) – Function that takes longitude, latitude and depth as arguments and returns local northing and easting and depth coordinates in meters. Depth conversion unused, solely required for compatibility with geoconverter argument in relmt.io.read_event_table().

  • strict (bool) – Raise a KeyError for repeated station codes with unequal coordinates. If False, last occurrence overwrites previous occurrences

Returns:

dict[str, Station]Station dictionary

Raises:
  • ValueError: – When station code contains the reserved character ‘_’

  • KeyError: – When repeated station codes are met and stict=True

Attention

Depends on obspy

relmt.extra.spectrum(sig, sampling_rate, nfft=0)[source]#

Retrun the spectrum of a 1D signal

Parameters:
  • sig (ndarray) – (samples,) array holding the waveform

  • sampling_rate (float) – in Hertz

  • nfft (int) – Number of points in the fft

Returns:

tuple[ndarray, ndarray]Frequency vector (Hz) and corresponding amplitudes (input units)

Attention

Depends on multitaper