relmt.qc module#
Functions for Quality Control
- relmt.qc.clean_by_equation_station_count_gap(p_amplitudes, s_amplitudes, phase_dict, min_equations=1, min_stations=1, max_gap=360.0, two_s_equations=True)[source]#
Remove observations below equation, station, gap thresholds iteratively
Counts the number of ocurrences of each event. Events that occur fewer than min_equations times, are observed on fewer stations than min_stations or have an azimuthal gap larger than max_gap are discarded, togther with the events they are connected to. This procedure is repeated until all remaining events are constrained by at least ‘min_equations` equations, min_stations stations and with a maximum azimuthal gap of max_gap.
- Parameters:
p_amplitudes (
list[P_Amplitude_Ratio]) – List of P amplitude observationsS_amplitudes – List of S amplitude observations
phase_dict (
dict[str,Phase]) – Phase dictionary with take-off azimuthsmin_equations (
int) – Minimum number of occurrences of each eventmin_stations (
int) – Minimum number of stations observing each eventmax_gap (
float) – Maximum allowed azimuthal gaptwo_s_equations (
bool) – Count each S observation twices_amplitudes (
list[S_Amplitude_Ratios])
- Returns:
tuple[list[P_Amplitude_Ratio],list[S_Amplitude_Ratios]] – Cleaned list of P- and S-amplitude observations
- relmt.qc.clean_by_event(amplitudes, exclude_events)[source]#
Remove amplitude readings made for certain events
- Parameters:
amplitdues – List of amplitude observations
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios])
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.clean_by_event_distance(amplitudes, event_dict, event_distance)[source]#
Remove amplitude readings of distant event combinations
Event pairs or triplets whose maximum distance is larger than event_distance will be removed.
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsevent_distance (
float) – Maximum distance between events
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.clean_by_kurtosis(amplitudes, event_list, max_kurtosis)[source]#
Remove amplitude readings until amplitude distribution has max kurtosis
Expected amplitude ratios are calculated from seismic moments, wich are derived from the magnitudes.
For P-waves, we investigate the distribution:
\[\log_{10}( A_{ab} M_0^b / M_0^a )\]For S-waves:
\[\log_{10}( (B_{abc} M_0^b + B_{acb} M_0^c) / M_0^a )\]and all equivalent event combinations.
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsevent_list (
list[Event]) – List of events with magnitude informationmax_kurtosis (
float) – Maximum allowed curtosis for distribution (0 is normal distribution)
- Returns:
list– Cleaned list of amplitude observations- Raises:
ValueError: – If amplitudes is not all P or S Amplitude Ratios
- relmt.qc.clean_by_magnitude_difference(amplitudes, event_dict, magnitude_difference)[source]#
Remove amplitude readings made for certain events
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsmagnitude_difference (
list[str] |None) – Maximum allowed difference in magnitude of participating events
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.clean_by_misfit(amplitudes, max_misfit)[source]#
Remove amplitude readings with a misfit larger max_misfit
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsmax_misfit (
float) – maximum misfit to keep
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
Remove amplitude readings of event combinations with small shared path
Event pairs or triplets whose shared path to the station smaller than min_shared_path will be removed. Shared path is
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsmin_shared_path (
float) – Minimum shared path fraction
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.clean_by_station(amplitudes, exclude_stations)[source]#
Remove amplitude readings made on certain stations
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observationsexclude_stations (
list[str]) – Station observations to exclude
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.clean_by_valid_takeoff_angle(amplitudes, phase_dictionary)[source]#
Remove amplitude readings with invalid corresponding take-off angle
- Parameters:
amplitudes (
list[P_Amplitude_Ratio|S_Amplitude_Ratios]) – List of amplitude observations
- Returns:
list[P_Amplitude_Ratio|S_Amplitude_Ratios] – Cleaned list of amplitude observations
- relmt.qc.connected_events(reference_mts, p_amplitudes=None, s_amplitudes=None)[source]#
Event connected to the reference MTs
Investigate the paired P- and triplet S-observations for connectivity. Only return those events that are connected to at least one reference MT.
- Parameters:
reference_mts (
list[int]) – List of indices to the reference eventsp_amplitudes (
list[P_Amplitude_Ratio] |None) – List of P-amplitude observationss_amplitudes (
list[S_Amplitude_Ratios] |None) – List of S-amplitude observations
- Returns:
dict[int,tuple[int,int]] – * Mapping of event indices of the connected events to number of P- and * S-connections- Raises:
ValueError: – If any reference MT has no amplitude observation
RuntimeError: – If reference MTs are not connected with each other
- relmt.qc.events_phases_above_misfit(amplitudes, misfit, subtract_below=0.0)[source]#
Count the phases that have a misfit larger than the given one
- Parameters:
amplitudes (
list[P_Amplitude_Ratio] |list[S_Amplitude_Ratios]) – List of amplitude observationsmisfit (
float) – Maximum misfit to considersubtract_below (
float) – Subtract the number of observations with a misfit below this value
- Returns:
events – Counter with events as keys and number of bad observations as values
phases – Counter with phase names as keys and number of bad observations as values
- relmt.qc.expansion_coefficient_norm(arr, phase)[source]#
Normalized expansion coefficient sum for each seismogram in matrix
Decompose seismogram matrix into principal seismograms. Return squared contribution of first (and second) principal seismogram to each original seismogram for P- (S-) waves.
1 (best) indicates principal seismogram(s) fully reconstruct the respective waveform
0 (worst) indicates the respective waveform cannot be represented by the principal seismogram(s)
- relmt.qc.included_events(exclude, station, phase, events_, return_not=False, return_bool=False)[source]#
Return events that are not excluded according to exclude dictionary
- Parameters:
exclude (
Exclude|None) – Dictionary holding exclusion criteria. If None, consider all events included.station (
str) – Station code to considerphase (
str) – Phase type to consider (P or S)events – Event IDs on that station
return_not (
bool) – Instead, return events that are excludedreturn_bool (
bool) – Return boolean array (not an index array)
- Returns:
ievs – Indices into events of included (or excluded if return_not=True) events
evns – Global event IDs of included (or excluded if return_not=True) events
- relmt.qc.index_high_value(values, threshold, return_not=False, return_bool=False)[source]#
Return indices of events with value above threshold
- Parameters:
- Returns:
ndarray– Indices where value is above threshold (or below or equal, if reutrn_not=True)
- relmt.qc.index_nonzero_events(array, null_threshold=None, return_not=False, return_bool=False)[source]#
Return indices of events with non-zero and finite data
- Parameters:
- Returns:
ndarray– Indices where array is non-zero (or all-zero if return_not=True)
- relmt.qc.reduce_equations(pamps, samps, phd, max_p_equations, max_s_equations, two_s, keep_ev, min_equations, min_stations, max_gap, max_amplitude_misfit, max_s_amplitude_misfit, max_s_sigma1, equation_batches=1)[source]#
Reduce the number of equations based on misfit, redundancy and station coverage
- Parameters:
pamps (
list[P_Amplitude_Ratio]) – List of P-amplitude observationssamps (
list[S_Amplitude_Ratios]) – List of S-amplitude observationsphd (
dict[slice(<class ‘str’>, <class ‘relmt.core.Phase’>, None)]) – Phase dictionary with take-off azimuthsmax_p_equations (
int) – Maximum number of P-equations to keepmax_s_equations (
int) – Maximum number of S-equations to keeptwo_s (
bool) – Count each S observation twice (for the two independent S-wave combinations)keep_ev (
list[str]) – List of event IDs to keep, even if they are redundantmin_equations (
int) – Minimum number of equations requied to keep eventmin_stations (
int) – Minimum number of stations required to keep eventmax_gap (
float) – Maximum allowed azimuthal gap allowed to keep eventmax_amplitude_misfit (
float) – Maximum allowed misfit to keep P-amplitude observationsmax_s_amplitude_misfit (
float) – Maximum allowed misfit to keep S-amplitude observationsmax_s_sigma1 (
float) – Maximum allowed sigma1 to keep S-amplitude observationsequation_batches (
int) – Reduce equations in batches. Larger number, reduces in smaller batches, which can lead to a more optimal selection of equations, but takes longer.
- Returns:
Reduced list of P- and S-amplitude observations