Triggers¶
The trigger turns the detection function, the maximum semblance over all nodes, into detections. A peak of the detection function is a detection when its height and its prominence exceed the thresholds of the trigger. Peaks closer than the blinding, 1 s by default, count as one detection. See detection.
| Trigger | Threshold | Adapts to |
|---|---|---|
ThresholdTrigger (default) |
Fixed semblance threshold |
Nothing: the same threshold for all windows |
MADTrigger |
mad_factor times the median absolute deviation (MAD) of the window |
Each window |
ModZScoreTrigger |
z_score scaled MADs above the median of the window |
Each window, and its noise floor |
Qseek computes the thresholds of the adaptive triggers in every processed window of window_length, 5 minutes by default.
The default ThresholdTrigger has a single parameter: the minimum semblance of a detection, 0.3 by default. The semblance of your events depends on the network, the phase weights and the distance weighting, so treat 0.3 as a starting point and set the threshold from the semblance column of csv/detections.csv of a first run. The adaptive triggers find more small events, at the cost of more parameters and more weak detections. On one day of the 2024 Campi Flegrei swarm (18 INGV stations, 287 windows), the adaptive thresholds range from 0.03 in quiet windows to 0.25 in the busiest windows:
| Trigger | Detections | With ≥ 8 picks | Median picks | INGV events matched |
|---|---|---|---|---|
ThresholdTrigger, threshold 0.3 |
315 | 315 | 20 | 45 / 45 |
MADTrigger, mad_factor 10 |
732 | 521 | 12 | 45 / 45 |
ModZScoreTrigger, z_score 6 |
732 | 524 | 12 | 45 / 45 |
Both adaptive triggers find all detections of the fixed threshold, at the same locations. They add about 200 detections with at least 8 picks, smaller events in the same cluster (median ML 0.19 against 0.48), and about 200 poorly constrained detections with a median of 4 picks. The fixed threshold of 0.3 misses weak events in quiet windows, where the adaptive thresholds are six to ten times lower. On this data set, z_score 6 gives nearly the same detections as mad_factor 10: the noise floor of the detection function is low, about 0.01. The default z_score 7 is slightly stricter, with 642 detections.
Tip
The median absolute deviation rises with the seismicity rate: during a swarm, the events themselves raise the threshold of their window. Lower mad_factor or z_score to detect more events in busy windows. On Campi Flegrei, mad_factor 8 to 12 does not change the number of detections in windows with a threshold below 0.05.
Fixed threshold¶
ThresholdTrigger applies the same minimum semblance to all windows, for height and prominence. Set it from the semblance of the events you want to detect: the semblance column of csv/detections.csv of a first run shows it.
ThresholdTrigger
pydantic-model
¶
Bases: Trigger
Fixed semblance threshold for all windows.
Fields:
-
blinding(timedelta) -
trigger(Literal['ThresholdTrigger']) -
threshold(PositiveFloat)
blinding
pydantic-field
¶
Minimum time between two detections. Peaks of the detection function closer than this count as one detection. Prevents detecting the same event twice.
get_threshold
¶
get_subclasses
classmethod
¶
detect
async
¶
detect(detection_function: ndarray, sampling_rate: float, padding: int = 0) -> tuple[ndarray, ndarray]
Detect events in a window of the detection function.
Peaks in the padding are discarded. The padding gives the peaks at the edges of the window their prominence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_function
|
ndarray
|
Detection function of the window, with padding. |
required |
sampling_rate
|
float
|
Sampling rate of the detection function in Hz. |
required |
padding
|
int
|
Number of padding samples at both ends. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: Sample indices of the detections in the window without padding, and the detection function at the detections. |
MAD trigger¶
The threshold is mad_factor times the median absolute deviation (MAD) of the detection function in each window, 10 by default. It is the minimum height and the minimum prominence of a detection.
{
"trigger": "MADTrigger",
"blinding": "PT1S",
"mad_factor": 10.0,
"threshold_range": null
}
MADTrigger
pydantic-model
¶
Bases: Trigger
Threshold that adapts to the noise level of each window.
Fields:
-
blinding(timedelta) -
trigger(Literal['MADTrigger']) -
mad_factor(PositiveFloat) -
threshold_range(RangeType | None)
mad_factor
pydantic-field
¶
mad_factor: PositiveFloat = 10.0
The threshold is this factor times the median absolute deviation (MAD) of the detection function in each processed window.
blinding
pydantic-field
¶
Minimum time between two detections. Peaks of the detection function closer than this count as one detection. Prevents detecting the same event twice.
get_threshold
¶
Get the thresholds from the MAD of the detection function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_function
|
ndarray
|
Detection function of the window, without padding. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: Minimum height and minimum prominence of a
detection, both the MAD times |
get_subclasses
classmethod
¶
detect
async
¶
detect(detection_function: ndarray, sampling_rate: float, padding: int = 0) -> tuple[ndarray, ndarray]
Detect events in a window of the detection function.
Peaks in the padding are discarded. The padding gives the peaks at the edges of the window their prominence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_function
|
ndarray
|
Detection function of the window, with padding. |
required |
sampling_rate
|
float
|
Sampling rate of the detection function in Hz. |
required |
padding
|
int
|
Number of padding samples at both ends. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: Sample indices of the detections in the window without padding, and the detection function at the detections. |
Modified z-score trigger¶
The modified z-score of Iglewicz and Hoaglin (1993) measures how far a peak stands above the median \(\tilde{x}\) of the detection function, in units of the MAD scaled to a standard deviation:
A detection needs a height of at least the median plus z_score scaled MADs, and a prominence of at least z_score scaled MADs, 7 by default. Unlike the MADTrigger, the threshold rises with the noise floor of the detection function.
Citation
Iglewicz, B., and Hoaglin, D. C. (1993). How to Detect and Handle Outliers. ASQC Quality Press, Milwaukee.
{
"trigger": "ModZScoreTrigger",
"blinding": "PT1S",
"z_score": 7.0,
"threshold_range": null
}
ModZScoreTrigger
pydantic-model
¶
Bases: Trigger
Threshold on the modified z-score of the detection function in each window.
Fields:
-
blinding(timedelta) -
trigger(Literal['ModZScoreTrigger']) -
z_score(PositiveFloat) -
threshold_range(RangeType | None)
z_score
pydantic-field
¶
z_score: PositiveFloat = 7.0
Minimum modified z-score of a detection. The modified z-score is the distance from the median of the detection function in each processed window, in units of the MAD scaled to a standard deviation (MAD / 0.6745).
blinding
pydantic-field
¶
Minimum time between two detections. Peaks of the detection function closer than this count as one detection. Prevents detecting the same event twice.
get_threshold
¶
Get the thresholds from the median and the MAD of the detection function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_function
|
ndarray
|
Detection function of the window, without padding. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: Minimum height and minimum prominence of a
detection. The height is the median plus |
get_subclasses
classmethod
¶
detect
async
¶
detect(detection_function: ndarray, sampling_rate: float, padding: int = 0) -> tuple[ndarray, ndarray]
Detect events in a window of the detection function.
Peaks in the padding are discarded. The padding gives the peaks at the edges of the window their prominence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_function
|
ndarray
|
Detection function of the window, with padding. |
required |
sampling_rate
|
float
|
Sampling rate of the detection function in Hz. |
required |
padding
|
int
|
Number of padding samples at both ends. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: Sample indices of the detections in the window without padding, and the detection function at the detections. |
Limit the adaptive threshold¶
threshold_range clips the thresholds of the adaptive triggers to [min, max] semblance in every window. The minimum keeps noise peaks out of quiet windows, and windows where the detection function is flat: there the MAD is close to zero, and so is the threshold. The maximum keeps a busy window from raising its own threshold during a swarm.
"trigger": {
"trigger": "MADTrigger",
"mad_factor": 10.0,
"threshold_range": [0.05, 0.12]
}
On the Campi Flegrei day, with mad_factor 10:
threshold_range |
Detections | With ≥ 8 picks | Lost | New |
|---|---|---|---|---|
| none | 732 | 521 | ||
[0, 0.08] |
876 | 595 | 0 | 74 |
[0, 0.12] |
786 | 556 | 0 | 35 |
[0.05, 10] |
705 | 521 | 0 | 0 |
[0.05, 0.12] |
759 | 556 | 0 | 35 |
Lost and new count the detections with at least 8 picks, against no range. The maximum adds well-constrained detections in busy windows without losing any. The minimum of 0.05 removes 27 detections, all with fewer than 8 picks.