scdetect-cc for Dummiesο
This tutorial is intended to guide you, while getting started with scdetect-cc
. The most common usage scenarios are described step-by-step, i.e.:
Offline Playback which allows you to process historical waveform data.
Real-Time Playback which may be used to process historical data while simulating real-time processing. This approach is based on injecting historic data into the seedlink.
Real-Time Application which allows processing data in real-time.
Questions?
Send an email to maria.mesimeri [at] sed.ethz.ch πΊ
Offline Playbackο
Offline Playbacks allow you to process historical data without the need to run a seedlink server. Therefore, the processing is going to be mostly file based. This approach is ideal if you quickly want to process a chunk of data, dump the results to a file which may be used for further processing.
The following examples are provided:
Single detector - Single station - Multi-channel detection describes in detail how to reproduce the configuration and results from the Getting Started section.
Single detector - Multi-station - Multi-channel detection describes how to configure a single template using streams from multiple stations.
Multi-detector - Multi-station - Multi-channel detection describes how to configure multiple templates using streams from multiple stations.
Example: Single detector - Single station - Multi-channel detectionο
This tutorial will guide you to reproduce the configuration and data from the Getting Started section.
Setupο
In order keep things clean and tidy create your project directory and change into it:
mkdir -p $HOME/tmp/scdetect-cc/ex-01 && cd $HOME/tmp/scdetect-cc/ex-01
Template Configurationο
scdetect-cc
relies on a so-called template configuration (JSON formatted).
Although, in general, multiple templates may be configured, within this example
only a single template is set up.
[
{
"detectorId": "detector-01",
"createArrivals": true,
"createTemplateArrivals": true,
"createAmplitudes": true,
"createMagnitudes": true,
"gapInterpolation": true,
"gapThreshold": 0.1,
"gapTolerance": 1.5,
"triggerDuration": 0.5,
"triggerOnThreshold": 0.7,
"triggerOffThreshold": 0.0,
"arrivalOffsetThreshold": 0.2,
"originId": "smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990",
"filter": "BW_BP(2,1.5,15)",
"templateFilter": "BW_BP(2,1.5,15)",
"streams": [
{
"templateId": "template-01",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 1,
"waveformId": "CH.SENIN..HHZ",
"templateWaveformId": "CH.SENIN..HHZ",
"templatePhase": "Pg"
},
{
"templateId": "template-02",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHN",
"templateWaveformId": "CH.SENIN..HHN",
"templatePhase": "Sg"
},
{
"templateId": "template-03",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHE",
"templateWaveformId": "CH.SENIN..HHE",
"templatePhase": "Sg"
}
]
}
]
Above a template configuration based on the template event identified by
the originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990
covering the streams HHZ
, HHN
, and HHE
of the sensor location CH.SENIN..
. For the vertical instrument component (channel code HHZ
) the template
waveform is referring to the templatePhase
Pg
, while for the horizontal
instrument components (channel codes HHN
and HHE
) are referring to
the templatePhase
Sg
.
For a more detailed description of the available configuration options please refer to the Template configuration section.
Copy and paste the content from above into a file and save it as template.json
.
Inventoryο
Next, scdetect-cc
requires inventory data to be provided.
Simply download the required inventory data with the command below:
echo "http://eida.ethz.ch/fdsnws/station/1/query"\
"?net=CH&sta=SENIN&channel=HH?&level=response" | \
wget -i - -O stations.xml
Now, convert the station.xml
file
into SCML format:
$SEISCOMP_ROOT/bin/seiscomp exec fdsnxml2inv -f stations.xml > stations.scml
Template EventParametersο
Apart from the inventory data scdetect-cc
requires EventParameter
configuration (SCML formatted) describing the template events.
Depending on the use case this configuration file must include:
Picks
-P
StationMagnitudes
-M
Amplitudes
-A
For downloading the data from the database we use scxmldump:
$SEISCOMP_ROOT/bin/seiscomp exec scxmldump \
-d localhost \
-O smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990 \
-f \
-M \
-P \
-A \
-o template.scml
Note
-d localhost
refers to your database. It can be something like
postgresql://user:password@host/seiscompDbName
Here, template EventParameter configuration is downloaded for a single template
configuration (i.e. identified by the detectorId
detector-01
). The
corresponding template originId
is smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990
.
Note
At the time being you cannot download station magnitudes from
SeisComPβs fdsnws-event
service implementation. For the purpose of this
tutorial you can get the template EventParameter configuration from
here.
Of course, you can also modify this tutorial to match your needs.
Waveform dataο
Template waveform data
To make things run faster we will create template waveforms. Once you have the station inventory (
stations.scml
), the template EventParameter configuration (template.scml
), and the template configuration (template.json
) ready, invoke the following command:$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \ --offline \ --amplitudes-force=0 \ --debug \ --templates-json template.json \ --inventory-db stations.scml \ --event-db template.scml \ --record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query" \ --templates-prepare
The command above will download the required data for template waveform creation from
http://eida.ethz.ch/fdsnws/dataselect/1/query
, and store it in a local cache.Raw continuous waveform data
Next, download the waveform data to be processed. Here, we will download the data from a FDSN service by means of
wget
, and sort it on-the-fly:echo "http://eida.ethz.ch/fdsnws/dataselect/1/query"\ "?net=CH&sta=SENIN&channel=HH?&start=2019-11-05T04:00&end=2019-11-05T05:00" | \ wget -i - -O - | \ $SEISCOMP_ROOT/bin/seiscomp exec scmssort -u -E -v - > data.mseed
Note
When processing data from multiple streams in playback mode it is important to sort data by end time.
Configure Bindingsο
Bindings configuration allows you to provide dedicated configuration on station
granularity. In the context of scdetect-cc
bindings configuration is required
in order to successfully compute
both amplitudes and
estimate magnitudes.
Please refer to the official SeisComP documentation for further information on bindings configuration.
SeisComP Expertsο
If you have already configured the bindings then you simply need to export those with e.g.
$SEISCOMP_ROOT/bin/seiscomp exec bindings2cfg \
--key-dir $SEISCOMP_ROOT/etc/key \
-o bindings.scml
SeisComP Newbiesο
If youβre new to SeisComP you can follow this guide in order to create your SCML formatted bindings configuration file:
First of all, import the previously downloaded
station.xml
inventory file toSeisComP
:$SEISCOMP_ROOT/bin/seiscomp exec import_inv fdsnxml stations.xml
Next, synchronize the inventory with the following command:
$SEISCOMP_ROOT/bin/seiscomp exec scinv sync
Note
This operation may change possibly preexisting inventory data on your database.
Now, letβs create and assign the bindings configuration. For simplicity, open scconfig
$SEISCOMP_ROOT/bin/seiscomp exec scconfig &
Then navigate to the bindings panel [1] . In the module tree select scdetect-cc [2] in the upper area, right-click and select Add scdetect-cc profile.
A popup will appear which asks you to name the binding profile to be created. Name the binding profile
default
or whatever you like and set the configuration parameters. An example for computing MRelative magnitudes isThen, drag and drop the profile to the
CH
network. With that, the binding profile is going to be assigned to all stations which are part of theCH
network.Next, save the configuration bindings to the database. Navigate to scconfig βs system panel and press the Update configuration button in the toolbar on the top.
Finally, export the bindings configuration from the database to the
bindings.scml
file:$SEISCOMP_ROOT/bin/seiscomp exec bindings2cfg \ --key-dir $SEISCOMP_ROOT/etc/key \ -o bindings.scml
Lazy Usersο
Get the bindings configuration from here.
Executeο
Now, letβs detect earthquakes:
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \
--offline \
--playback \
--debug \
--templates-json template.json \
--inventory-db stations.scml \
--event-db template.scml \
--config-db bindings.scml \
--record-url data.mseed \
--ep=results.scml
The detection results will be output in
the SCML formatted results.scml
file.
Detectionsο
detectorId |
origin time |
score |
---|---|---|
|
2019-11-05T04:10:21.820487Z |
0.823434 |
2019-11-05T04:20:05.215489Z |
0.842091 |
|
2019-11-05T04:23:29.035489Z |
0.935279 |
|
2019-11-05T04:23:47.640489Z |
1.000000 |
Above the detections for the detector identified by the detectorId
detector-01
. The detection with the origin time 2019-11-05T04:23:47.640489Z
is the template and is detected with a score of 1.000000.
Post-processingο
Run scevent with the
following command in order to associate the origins from the results.scml
file
to events.
$SEISCOMP_ROOT/bin/seiscomp exec scevent \
--debug \
--disable-db \
--ep results.scml > event.catalog.scml
This will create a catalog which is stored in the event.catalog.scml
file.
Screen resultsο
To screen visualize the results launch scolv with
$SEISCOMP_ROOT/bin/seiscomp exec scolv \
--offline \
--db-disable \
--debug \
--inventory-db stations.scml \
--record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query" &
Once scolv is up and running
import the event.catalog.scml
file which was previously generated
with scevent.
Sort detections by CrossCorrelationCoefficient (CCC)ο
SeisComP allows the user to add a custom column, for example in scolv, to show origin or event comments. In the case of scdetect-cc in the comments the user can find the scdetectDetectorID, the earthquake template that detect the new earthquake, and the scdetectResultCCC, the cross correlation coefficient between the template and the new detection.
To add one custom column please go here and then edit either the scolv.cfg file or the scconfig GUI.
For more columns, and thus more comments, please choose the External Scripts and the Custom Information.
Example: Single detector - Multi-station - Multi-channel detectionο
While in the previous example the template configuration used only streams from a single station, this tutorial will guide you to detect earthquakes using two stations (each with three channels).
Setupο
Create an empty directory with
mkdir -p $HOME/tmp/scdetect-cc/ex-02 && cd $HOME/tmp/scdetect-cc/ex-02
Template Configurationο
[
{
"detectorId": "detector-01",
"createArrivals": true,
"createTemplateArrivals": true,
"createAmplitudes": true,
"createMagnitudes": true,
"gapInterpolation": true,
"gapThreshold": 0.1,
"gapTolerance": 1.5,
"triggerDuration": 0.5,
"triggerOnThreshold": 0.4,
"triggerOffThreshold": 0.0,
"arrivalOffsetThreshold": 1.0,
"minimumArrivals": 3,
"originId": "smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990",
"filter": "BW_BP(2,1.5,15)",
"templateFilter": "BW_BP(2,1.5,15)",
"streams": [
{
"templateId": "template-01",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 1,
"waveformId": "CH.SENIN..HHZ",
"templateWaveformId": "CH.SENIN..HHZ",
"templatePhase": "Pg"
},
{
"templateId": "template-02",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHN",
"templateWaveformId": "CH.SENIN..HHN",
"templatePhase": "Sg"
},
{
"templateId": "template-03",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHE",
"templateWaveformId": "CH.SENIN..HHE",
"templatePhase": "Sg"
},
{
"templateId": "template-04",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 1,
"waveformId": "CH.SAYF2..HGZ",
"templateWaveformId": "CH.SAYF2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-05",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGE",
"templateWaveformId": "CH.SAYF2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-06",
"initTime": 10,
"templateWaveformStart": -0.5,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGN",
"templateWaveformId": "CH.SAYF2..HGN",
"templatePhase": "Sg"
}
]
}
]
Above a template configuration based on the template event identified by
the originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990
covering 6 streams overall. While the streams HHZ
, HHN
, and HHE
refer to
the sensor location CH.SENIN..
, the sensor location CH.SAYF2..
is covered by
the streams HGZ
, HGN
, and HGE
. Again, the template waveforms of the
vertical instrument components refer to the templatePhase
Pg
, while the
template waveforms of the horizontal instrument components refer to
the templatePhase
Sg
.
Note
In contrast to the previous example <ex-01-label>, here, we introduce the
minimumArrivals
configuration option, which defines the minimum number
of phases required to declare a new detection. The default value is the
total number of phase templates, i.e. 6 in this case.
For a more detailed description of the available configuration options please refer to the Template configuration section.
Copy and paste the content from above into a file and save it as template.json
.
Inventoryο
Simply download the required inventory data with the command below:
echo "http://eida.ethz.ch/fdsnws/station/1/query"\
"?net=CH&sta=SENIN,SAYF2&channel=HH?,HG?&level=response" | \
wget -i - -O stations.xml
Then, convert the station.xml
file into
the SCML format:
$SEISCOMP_ROOT/bin/seiscomp exec fdsnxml2inv -f stations.xml > stations.scml
Template EventParametersο
Download the template EventParameter data for the
template originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990
from the database with scxmldump:
$SEISCOMP_ROOT/bin/seiscomp exec scxmldump \
-d localhost \
-O smi:ch.ethz.sed/sc3a/origin/NLL.20191105125505.255283.1897990 \
-f \
-M \
-P \
-A \
-o template.scml
For the purpose of this tutorial you can download the template EventParameter data from here, since you donβt have access to the database.
Waveform dataο
Template waveform data
To make things run faster we will create template waveforms. Once you have the inventory (
stations.scml
) , the template EventParameter configuration (template.scml
), and the template configuration (template.json
) ready, invoke the following command:$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \ --offline \ --templates-prepare \ --amplitudes-force=0 \ --debug \ --templates-json template.json \ --inventory-db stations.scml \ --event-db template.scml \ --record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query"
This will download the required data from
http://eida.ethz.ch/fdsnws/dataselect/1/query
and store it in a local cache.Raw continuous waveform data
The waveform data to be precessed may be downloaded and sorted on-the-fly with e.g.:
echo "http://eida.ethz.ch/fdsnws/dataselect/1/query"\ "?net=CH&sta=SENIN,SAYF2&cha=HH?,HG?"\ "&start=2019-11-05T04:00:00&end=2019-11-05T05:00:00" | \ wget -i - -O - | \ $SEISCOMP_ROOT/bin/seiscomp exec scmssort -u -E -v - > data.mseed
Configure Bindingsο
In order to successfully compute
both amplitudes and
estimate magnitudes
scdetect-cc
requires bindings configuration.
Please refer to the previous tutorial for a detailed description on how to create the bindings configuration file. Alternatively, download the bindings configuration file from here.
Executeο
Now, letβs detect earthquakes:
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \
--offline \
--playback \
--debug \
--templates-json template.json \
--inventory-db stations.scml \
--event-db template.scml \
--config-db bindings.scml \
--record-url data.mseed \
--ep=results.scml
Detectionsο
Below, the detections for the detector identified by detectorId
detector-01
. Overall, 17 detections were detected. In general, the score
is a good measure for the quality of the detection. Note also that in this
example the detectorβs minimumArrivals
configuration parameter was set to
3. As a consequence, there are detections which arenβt associated with the
complete set of streams configured. For further information on detector
specific configuration parameters, please refer to the
Detector configuration parameters section.
detectorId |
origin time |
score |
---|---|---|
|
2019-11-05T04:10:21.808488Z |
0.762944 |
2019-11-05T04:14:45.268488Z |
0.617774 |
|
2019-11-05T04:14:46.084489Z |
0.650515 |
|
2019-11-05T04:20:05.228489Z |
0.792890 |
|
2019-11-05T04:23:28.148489Z |
0.870368 |
|
2019-11-05T04:23:29.032487Z |
0.940671 |
|
2019-11-05T04:23:47.640489Z |
0.803577 |
|
2019-11-05T04:24:29.988489Z |
0.739678 |
|
2019-11-05T04:28:30.640488Z |
0.591616 |
|
2019-11-05T04:36:50.472488Z |
0.587906 |
|
2019-11-05T04:36:51.348489Z |
0.591454 |
|
2019-11-05T04:37:59.580488Z |
0.638732 |
|
2019-11-05T04:52:09.232489Z |
0.717425 |
|
2019-11-05T04:53:03.768489Z |
0.625758 |
|
2019-11-05T04:56:48.915489Z |
0.596608 |
|
2019-11-05T04:59:34.324489Z |
0.534814 |
|
2019-11-05T04:59:39.016489Z |
0.469078 |
Post-processingο
scdetect-cc
generates origins, picks, arrivals, amplitudes, and both station
magnitudes and network magnitudes. When using multiple detectors, the
resulting results.scml
file will, in theory at least, contain earthquakes
detected from different templates (i.e. detectors). An easy way to merge these
detections into events is to use scevent.
Before, make sure youβve set the desired eventAssociation
related module
configuration parameters, e.g.
Then, run scevent:
$SEISCOMP_ROOT/bin/seiscomp exec scevent \
--debug \
--disable-db \
--ep results.scml > event.catalog.scml
Screen resultsο
The last step is to visualize the results. First we need to launch scolv:
$SEISCOMP_ROOT/bin/seiscomp exec scolv \
--offline \
--debug \
--db-disable \
--inventory-db stations.scml \
--record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query" &
Here, we run scolv without using a database. Besides, waveform data is fetched from FDSN web services.
Once scolv is up and running
import the event.catalog.scml
file which was previously generated
with scevent.
Sort detections by CrossCorrelationCoefficient (CCC)ο
SeisComP allows the user to add a custom column, for example in scolv, to show origin or event comments. In the case of scdetect-cc in the comments the user can find the scdetectDetectorID, the earthquake template that detect the new earthquake, and the scdetectResultCCC, the cross correlation coefficient between the template and the new detection.
To add one custom column please go here and then edit either the scolv.cfg file or the scconfig GUI.
For more columns, and thus more comments, please choose the External Scripts and the Custom Information.
Example: Multi-detector - Multi-station - Multi-channel detectionο
This tutorial will guide you to detect earthquakes using three stations (i.e.
each with three channels), and multiple earthquake templates (i.e. detector-01
, detector-02
, etc).
Setupο
Create an empty directory with
mkdir -p $HOME/tmp/scdetect-cc/ex-03 && cd $HOME/tmp/scdetect-cc/ex-03
Template Configurationο
Copy and paste the following template configuration into a file and save it
as template.json
.
[
{
"detectorId": "detector-01",
"createArrivals": true,
"createTemplateArrivals": true,
"createAmplitudes": true,
"createMagnitudes": true,
"gapInterpolation": true,
"gapThreshold": 0.1,
"gapTolerance": 1.5,
"minimumArrivals": 5,
"triggerDuration": 0.5,
"triggerOnThreshold": 0.5,
"triggerOffThreshold": 0.0,
"arrivalOffsetThreshold": 0.5,
"originId": "smi:ch.ethz.sed/sc3a/origin/NLL.20191105141052.482388.186933",
"filter": "BW_BP(2,1.5,15)",
"templateFilter": "BW_BP(2,1.5,15)",
"streams": [
{
"templateId": "template-01",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SAYF2..HGZ",
"templateWaveformId": "CH.SAYF2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-02",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGE",
"templateWaveformId": "CH.SAYF2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-03",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGN",
"templateWaveformId": "CH.SAYF2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-04",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.STSW2..HGZ",
"templateWaveformId": "CH.STSW2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-05",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGE",
"templateWaveformId": "CH.STSW2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-06",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGN",
"templateWaveformId": "CH.STSW2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-07",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SENIN..HHZ",
"templateWaveformId": "CH.SENIN..HHZ",
"templatePhase": "Pg"
},
{
"templateId": "template-08",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHE",
"templateWaveformId": "CH.SENIN..HHE",
"templatePhase": "Sg"
},
{
"templateId": "template-09",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHN",
"templateWaveformId": "CH.SENIN..HHN",
"templatePhase": "Sg"
}
]
},
{
"detectorId": "detector-02",
"createArrivals": true,
"createTemplateArrivals": true,
"createAmplitudes": true,
"createMagnitudes": true,
"gapInterpolation": true,
"gapThreshold": 0.1,
"gapTolerance": 1.5,
"minimumArrivals": 8,
"triggerDuration": 0.5,
"triggerOnThreshold": 0.5,
"triggerOffThreshold": 0.0,
"arrivalOffsetThreshold": 0.3,
"originId": "smi:ch.ethz.sed/sc3a/origin/NLL.20191106214318.866617.258170",
"filter": "BW_BP(2,1.5,15)",
"templateFilter": "BW_BP(2,1.5,15)",
"streams": [
{
"templateId": "template-01",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SAYF2..HGZ",
"templateWaveformId": "CH.SAYF2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-02",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGE",
"templateWaveformId": "CH.SAYF2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-03",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGN",
"templateWaveformId": "CH.SAYF2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-04",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.STSW2..HGZ",
"templateWaveformId": "CH.STSW2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-05",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGE",
"templateWaveformId": "CH.STSW2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-06",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGN",
"templateWaveformId": "CH.STSW2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-07",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SENIN..HHZ",
"templateWaveformId": "CH.SENIN..HHZ",
"templatePhase": "Pg"
},
{
"templateId": "template-08",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHE",
"templateWaveformId": "CH.SENIN..HHE",
"templatePhase": "Sg"
},
{
"templateId": "template-09",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHN",
"templateWaveformId": "CH.SENIN..HHN",
"templatePhase": "Sg"
}
]
},
{
"detectorId": "detector-03",
"createArrivals": true,
"createTemplateArrivals": true,
"createAmplitudes": true,
"createMagnitudes": true,
"gapInterpolation": true,
"gapThreshold": 0.1,
"gapTolerance": 1.5,
"minimumArrivals": 8,
"triggerDuration": 0.5,
"triggerOnThreshold": 0.5,
"triggerOffThreshold": 0.0,
"arrivalOffsetThreshold": 0.3,
"originId": "smi:ch.ethz.sed/sc3a/origin/NLL.20191106214119.274905.257656",
"filter": "BW_BP(2,1.5,15)",
"templateFilter": "BW_BP(2,1.5,15)",
"streams": [
{
"templateId": "template-01",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SAYF2..HGZ",
"templateWaveformId": "CH.SAYF2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-02",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGE",
"templateWaveformId": "CH.SAYF2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-03",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SAYF2..HGN",
"templateWaveformId": "CH.SAYF2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-04",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.STSW2..HGZ",
"templateWaveformId": "CH.STSW2..HGZ",
"templatePhase": "Pg"
},
{
"templateId": "template-05",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGE",
"templateWaveformId": "CH.STSW2..HGE",
"templatePhase": "Sg"
},
{
"templateId": "template-06",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.STSW2..HGN",
"templateWaveformId": "CH.STSW2..HGN",
"templatePhase": "Sg"
},
{
"templateId": "template-07",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 1,
"waveformId": "CH.SENIN..HHZ",
"templateWaveformId": "CH.SENIN..HHZ",
"templatePhase": "Pg"
},
{
"templateId": "template-08",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHE",
"templateWaveformId": "CH.SENIN..HHE",
"templatePhase": "Sg"
},
{
"templateId": "template-09",
"initTime": 10,
"templateWaveformStart": -0.25,
"templateWaveformEnd": 2,
"waveformId": "CH.SENIN..HHN",
"templateWaveformId": "CH.SENIN..HHN",
"templatePhase": "Sg"
}
]
}
]
Above a template configuration for the multiple template events. The template
event identified by detectorId
detector-01
is based on
the originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191105141052.482388.186933
,
the template event identified by detectorId
detector-02
is based on
the originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191106214318.866617.258170
,
and the template identified by detectorId
detector-03
is based on
the originId
smi:ch.ethz.sed/sc3a/origin/NLL.20191106214119.274905.257656
.
All template event configurations use waveform data from the sensor
locations CH.SAYF2..
, CH.SENIN..
, and CH.STSW2..
.
Inventoryο
Download the inventory data with the following command:
echo "http://eida.ethz.ch/fdsnws/station/1/query"\
"?net=CH&sta=SENIN,SAYF2,STSW2&channel=H??&level=response" | \
wget -i - -O stations.xml
Now, convert the station.xml
file
into SCML format:
$SEISCOMP_ROOT/bin/seiscomp exec fdsnxml2inv -f stations.xml > stations.scml
Template EventParametersο
Download the template EventParameter data for the template originId
s smi:ch.ethz.sed/sc3a/origin/NLL.20191105141052.482388.186933
, smi:ch.ethz.sed/sc3a/origin/NLL.20191106214318.866617.258170
,
and smi:ch.ethz.sed/sc3a/origin/NLL.20191106214119.274905.257656
from the
database with scxmldump:
$SEISCOMP_ROOT/bin/seiscomp exec scxmldump \
-d localhost \
-O smi:ch.ethz.sed/sc3a/origin/NLL.20191105141052.482388.186933,smi:ch.ethz.sed/sc3a/origin/NLL.20191106214318.866617.258170,smi:ch.ethz.sed/sc3a/origin/NLL.20191106214119.274905.257656 \
-f \
-M \
-P \
-A \
-o template.scml
For the purpose of this tutorial you can download the template EventParameter data from here, since you donβt have access to the database.
Waveform dataο
Template waveform data
Download and prepare the template waveform data with the following command:
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \ --offline \ --templates-prepare \ --amplitudes-force=0 \ --debug \ --templates-json template.json \ --inventory-db stations.scml \ --event-db template.scml \ --record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query"
Note that
scdetect-cc
will store the downloaded waveform data within a local cache.Raw continuous waveform data
The waveform data to be precessed may be downloaded and sorted on-the-fly with e.g.:
echo "http://eida.ethz.ch/fdsnws/dataselect/1/query"\ "?net=CH&sta=SENIN,SAYF2,STSW2&cha=HH?,HG?"\ "&start=2019-11-05T04:00:00&end=2019-11-05T05:00:00" | \ wget -i - -O - | \ $SEISCOMP_ROOT/bin/seiscomp exec scmssort -u -E -v - > data.mseed
Configure Bindingsο
In order to successfully compute
both amplitudes and
estimate magnitudes
scdetect-cc
requires bindings configuration.
Please refer to the first tutorial for a detailed description on how to create the bindings configuration file. Alternatively, download the bindings configuration file from here.
Executeο
Now, letβs detect earthquakes:
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \
--offline \
--playback \
--debug \
--templates-json template.json \
--inventory-db stations.scml \
--event-db template.scml \
--config-db bindings.scml \
--record-url data.mseed \
--ep=results.scml
scdetect-cc
will dump the results to the results.scml
file.
Detectionsο
Below, a summary of the detections after executing scdetect-cc
. Overall, 9
detections were detected. The detector identified by detectorId
detector-03
did not contribute any detections.
detectorId |
origin time |
score |
---|---|---|
|
2019-11-05T04:10:21.924705Z |
0.562399 |
2019-11-05T04:23:29.006707Z |
0.578355 |
|
2019-11-05T04:23:47.611707Z |
0.650244 |
|
2019-11-05T04:24:30.104706Z |
0.561630 |
|
2019-11-05T04:36:51.460707Z |
0.604361 |
|
|
2019-11-05T04:10:21.904287Z |
0.757687 |
2019-11-05T04:23:47.736289Z |
0.660996 |
|
2019-11-05T04:36:51.440289Z |
0.707759 |
|
2019-11-05T04:37:59.676287Z |
0.772242 |
|
|
Post-processingο
Run scevent with the
following command in order to associate the origins from the results.scml
file
to events.
$SEISCOMP_ROOT/bin/seiscomp exec scevent \
--debug \
--disable-db \
--ep results.scml > event.catalog.scml
This will create a catalog which is stored in the event.catalog.scml
file.
Screen resultsο
To screen visualize the results launch scolv with
$SEISCOMP_ROOT/bin/seiscomp exec scolv \
--offline \
--db-disable \
--debug \
--inventory-db stations.scml \
--record-url "fdsnws://eida.ethz.ch/fdsnws/dataselect/1/query" &
Once scolv is up and running
import the event.catalog.scml
file which was previously generated
with scevent.
Sort detections by CrossCorrelationCoefficient (CCC)ο
SeisComP allows the user to add a custom column, for example in scolv, to show origin or event comments. In the case of scdetect-cc in the comments the user can find the scdetectDetectorID, the earthquake template that detect the new earthquake, and the scdetectResultCCC, the cross correlation coefficient between the template and the new detection.
To add one custom column please go here and then edit either the scolv.cfg file or the scconfig GUI.
For more columns, and thus more comments, please choose the External Scripts and the Custom Information.
Real-Time Playbackο
This example requires a bit more of experience
with SeisComP. If youβre not familiar with
the SeisComP, or scdetect-cc
, yet, we recommend
you to start with the Offline Playback tutorials, before.
This section will describe how to use scdetect-cc
in order to process data in
a real-time playback fashion.
For further information on playback archived waveform data in general, please refer to the SeisComP playback tutorial.
Inventoryο
We assume that
the inventory and bindings configuration
for the network of interest are configured. For example, if we want to work with
the Swiss Seismological Network (i.e. network code CH
) you need to
download the inventory data with, e.g.
wget "http://eida.ethz.ch/fdsnws/station/1/query?net=CH&sta=*&channel=H??&level=response" -O stations.xml
import the inventory into the SeisComP database
$SEISCOMP_ROOT/bin/seiscomp exec import_inv fdsnxml stations.xml && \ $SEISCOMP_ROOT/bin/seiscomp exec scinv sync
Bindings configurationο
Global bindings are required for each sensor in order to display the waveform data with scrttv.
Also, create seedlink bindings configuration and configure the mseedfifo - mseedfifo_plugin source.
Finally, create bindings configuration for
scdetect-cc
in order to be able to successfully compute both amplitudes and estimate magnitudes.
Template EventParametersο
Make sure that the template EventParameter data is available in your SeisComP database. Template EventParameter data may be imported to the SeisComP database with e.g. scdispatch.
Waveform dataο
Download both the waveform data the template waveforms are generated from and the data to be processed.
Note
It is imported that the data to be processed is sorted by end time.
SeisComP configurationο
Playbackο
Restart SeisComP with
$SEISCOMP_ROOT/bin/seiscomp restart
Open a few GUIs to monitor scmaster and events
$SEISCOMP_ROOT/bin/seiscomp exec scrttv & \
$SEISCOMP_ROOT/bin/seiscomp exec scmm & \
$SEISCOMP_ROOT/bin/seiscomp exec scesv & \
$SEISCOMP_ROOT/bin/seiscomp exec scolv &
Finally, start the playback:
$SEISCOMP_ROOT/bin/seiscomp exec msrtsimul \
-m historic \
-v data.mseed & \
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \
--playback \
--start-stop-msg=1 \
--debug
In practice, to process data with scdetect-cc
in real-time playback fashion
you need:
a miniseed file sorted by end time
a
template.json
configuration file which contains the information about the detectors and the templates, anda fully configured SeisComP system.
Optionally, in case youβd like to fetch the earthquake template EventParameter data from the database they must be imported, beforehand.
Real-Time Applicationο
We assume that youβre familiar with SeisComP and its underlying concepts.
This section will describe step-by-step the prerequisites to be fulfilled in
order to process waveform data with scdetect-cc
in real-time fashion.
Inventoryο
We assume that the inventory data of interest is available.
Bindings Configurationο
Bindings configuration for the stations of interest is required:
Global bindings are required for each sensor in order to display the waveform data with scrttv.
Also, create seedlink bindings configuration with the correct source plugin enabled.
Finally, create bindings configuration for
scdetect-cc
in order to be able to successfully compute both amplitudes and estimate magnitudes.
Template EventParameterο
Template EventParameter data needs to be available for scdetect-cc
.
SeisComP configurationο
Make sure the module configuration for the used modules is configured correctly.
Particularly, check the scdetect-cc
module configuration parameters.
Real-time monitoring and detectionο
Open a few GUIs to monitor scmaster and events
$SEISCOMP_ROOT/bin/seiscomp exec scrttv & \
$SEISCOMP_ROOT/bin/seiscomp exec scmm & \
$SEISCOMP_ROOT/bin/seiscomp exec scesv & \
$SEISCOMP_ROOT/bin/seiscomp exec scolv &
and invoke
$SEISCOMP_ROOT/bin/seiscomp exec scdetect-cc \
--start-stop-msg=1 \
--debug
to run scdetect-cc
. Alternatively, start scdetect-cc
in daemon mode.
Update Templates in Real Timeο
Here we briefly describe how to manage templates
traffic in real time.
Download earthquakes around the Mainshock / Earthquake of interest
We assume that an earthquake occurred in the are and we are interested in finding past [or new] earthquakes to use as
detectors
. Then using FDSN services and obspy we get the event catalog that contains arrival times:cat = client.get_events(latitude=latitude, longitude=longitude, minradius=0.001, maxradius=0.2, eventtype='earthquake', limit='30', contributor="SED", minmagnitude=1.0, includearrivals=True)
Create
JSON
file withdetectors
andtemplates
A python script is included in scdetect-cc. This script allows the user to convert the event file into
JSON
.Redirect the output to the path define in scconfig .
Cache
templates
waveforms
Folow the instructions from here to cache the template waveforms.
Run
scdetect-cc
The last step is to restart
scdetect-cc
$SEISCOMP_ROOT/bin/seiscomp restart scdetect-cc
All the above steps can be combined into a single script (e.g. bash
), and setup a cronjob
that will update the templates.json
file every few minutes or hours.
date
commnad in bash
can be useful to set up a time period.
scevent takes care of event association.