21.8 SCPNOR, getting detections from SeisComp in real time or manually

SCPNOR The program SCPNOR has the purpose to extract event parameter data from SeisComP (SCP) and put them into Nordic format. The program can operate in two ways:

(1) Extract events at a given time interval and output the events in one file and/or in a SEISAN data base.

(2) Extract events from the current time and a given time back in time (instant-time), the instant option.

This option can be set up as a cron job and can therefore maintain a SEISAN data base of SCP events close to real time depending on the cron parameters set up. In this mode, the program can optionally also maintain a second SEISAN data base with only the events instant-time back. This option can be use to e.g. a web page which should only use data for a limited time back. In order to keep track of what already has been copied, a file scpnor.instant in the working directory will keep track of what already has been copied.

Requirements:

-  Linux computer
-  SEISAN
-  Acces to SeisComP program and data base

If operating close to real time like getting data every 2 minutes, SCP can make several solutions before the final solution. Within the time window defined as instant-time back, all duplicate solutions will be deleted.

Plotting waveforms and getting waveform files

The data from SCP available in a SEISAN data base can be plotted provided the SCP archive is available to SEISAN and the channel parameters are set up in SEISAN.DEF for plotting with or without the ARC line in the s-file. The ARC line can optionally be written in the S-file. If just a file of events has been obtained, the corresponding waveform files can be extracted with program GET_ARC and a new cat file is made with links to the extracted waveform files.

A more complete option for getting data files from SCP is the SC2SEI system found at https://www.geo.uib.no/seismo/SOFTWARE/SC2SEI/

Program operation

The program is first getting the event ID’s from SCP in the given time interval, using SCP command scevtls, and thus creating a file newids.txt. Using that list, parameter information is extracted to file ‘event’ using a modified version of SCP command scbulletin. The modified program is scbul4.py for SCP version 4 and 5 and scbul3.py for SCP version 3, both are included in PRO. These scripts must be executable. The SCP id is stored in the S-file.

The output from the bulletin program is then converted to Nordic format. The program uses a parameter file, see an example later. The program can only operate if there is access to SCP commands and the SCP relation data base data base of parameters.

Program operation The program is first getting the event ID’s from SCP in the given time interval, using SCP command scevtls, and thus creating a file newids.txt. Using that list, parameter information is extracted to file ‘event’ using a modified version of SCP command scbulletin. The modified program is scbul4.py for SCP version 4 and 5 and scbul3.py for SCP version 3, both are included in PRO. The SCP id is stored in the S-file. The output from the bulletin program is then converted to Nordic format. The program uses a parameter file, see an example later. The program can only operate if there is access to SCP commands and the SCP relation data base data base of parameters.

Example option 1

scpnor
seiscomp version   4
sql user:          seiscomp
sql pass:          xxx1922scmp
sql ip  :          localhost
sql data base      seiscomp
make s-file        T
insert ARC line    T
wa gain            2800.0
sfile data base    SCP
sfile 2. data base SCP2
agency operator    SCP sc
instant time back  1440.0

Give start time, at least year, yyymmddhhmmss
20230115
 Give end time, at least year, month and day, yyyymmddhhmmss
 or give number of hours from start like 2 or 0.2
24
begin: "2023-01-15 00:00:00"
end:   "2023-01-16 00:00:00"
scevtls -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp --begin "2023-01-15 00:00:00" --end "2023-01-16 00:00:00"  > newids.txt
 Number of event ids           5
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023azyq -3 -e -p > event                                  
  first sfile:   /home/seiscomp/seismo/REA/SCP__/2023/01/15-0404-21L.S202301
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023baau -3 -e -p > event                                  
  first sfile:   /home/seiscomp/seismo/REA/SCP__/2023/01/15-0505-49L.S202301
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023bbct -3 -e -p > event                                  
  first sfile:   /home/seiscomp/seismo/REA/SCP__/2023/01/15-2000-06L.S202301
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023bbfv -3 -e -p > event                                  
  first sfile:   /home/seiscomp/seismo/REA/SCP__/2023/01/15-2103-07L.S202301
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023bbhp -3 -e -p > event                                  
  first sfile:   /home/seiscomp/seismo/REA/SCP__/2023/01/15-2203-02L.S202301

In this example, data is collected for 24h and 5 events were found. The first output is a summary of the parameter file. Although a second data base is defined, no data is collected for the second data base since the instant option is not used. Output is in scpnor.out and data base SEISAN SCP.

Example option 2

scpnor instant
seiscomp version   4
sql user:          seiscomp
sql pass:          xxx1922scmp
sql ip  :          localhost
sql data base      seiscomp
make s-file        T
insert ARC line    T
wa gain            2800.0
sfile data base    SCP
sfile 2. data base SCP2
agency operator    SCP sc
instant time back  1440.0

 number of instant events           3
begin: "2023-02-15 13:19:00"
end:   "2023-02-16 13:24:00"
scevtls -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp --begin "2023-02-15 13:19:00" --end "2023-02-16 13:24:00"  > newids.txt
 Number of event ids           3
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023dgmv -3 -e -p > event                                  
 sfile already written
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023dgrj -3 -e -p > event                                  
 sfile already written
scbul4.py -d mysql://seiscomp:xxx1922scmp@localhost/seiscomp -E nsn2023dgun -3 -e -p > event                                  
 sfile already written

In this example, data will be collected for the last 24 h. There were already 3 events collected before and the 3 checked are the same so nothing is copied to the SEISAN data bases. However, the 3 events are listed in scpnor.out.

Data converted

SCPNOR reads most if the data in the SCP output file ‘event’. For magnitudes, only amplitudes for ML and Mb are transferred. For the IAML amplitudes, they are converted from mm Wood Anderson to nm. SCP by default uses the wrong Wood Anderson gain of 2800 (see SCP setup) but can also use the correct 2080 (Uhrhammer and Collins,1990) In the SCPNOR parameter file, the gain used by SCP can be set in the SCP configuration. SCP does not give a period for IAML and since SEISAN needs a period to judge if the reading is within a correct period range, a fixed period of 1.0 s is used.

Example of a script for the cron job. It could be started e.g. every 5 minutes.

#!/bin/bash
#
#   directory where scpnor is running
#
cd /home/seiscomp/seismo/scpnor
#
#
#   define env variables
#
source /home/seiscomp/.bashrc
#
#  start scpnor
#
/home/seiscomp/seismo/PRO/scpnor instant  >/dev/null
#
#  put info in log file
#
/usr/bin/date > /home/seiscomp/seismo/scpnor/scpnor.log
/usr/bin/echo "scpnor started:" >> /home/seiscomp/seismo/scpnor/scpnor.log

Parameter file scpnor.par

The parameter file is intended to be self-explanatory. It can be placed in working directory or DAT. An example is seen below:

#
#   parameter file for scpnor
#
#   KEYWORD identifies the parameter and up to 2 parameters
#   can be given. They are given in column 41 to 50 and
#   51 to 60 respectively. Numbers can be anywhere in the
#   fields but characters must start in 41 or 51
#   respectively. If blank, a default is used.
#
KEYWORD............Comments.............Par 1.....Par 2
#
#
#######################################
#......................................
#
#   SeisComp version, 3, 4 or 5
#   4 is default and also works with 5
#
#.......................................1.........2........
SEISCOMP VERSION                        4
#.......................................xxxxxxxxxxxxxxxxxxx
#
#   the network agency and operator,
#   3 chars, default SCP and sc
#
#.......................................1.........2........
AGENCY
#.......................................xxxxxxxxxxxxxxxxxxx
#
#
#######################################
#  parameter for sql data base
#######################################
#
#................................................
#
#  sql user name
#
#.......................................1.........
SQL USER                                seiscomp
#.......................................xxxxxxxxxx
#
# sql password
#
#.......................................1............................
SQL PASS                                xxx1922scmp
#.......................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# sql data base
#
#.......................................1.............................
SQL DATABASE                            seiscomp
#.......................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# sql ip number
#
#.......................................1............................
SQL IP                                  localhost
#.......................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# in instant mode, give number of
# minutes back from real time (UTC)
# from which to start data collection
#
#.......................................1........
INSTANT TIME BACK                       1440.0
#.......................................xxxxxxxx
#
# put 1.0 if making an S-file, else 0.0
#
#.......................................1.........
MAKE SFILE                              1.0
#.......................................xxxxxxxxxx
#
#  base for S-files.
#  blank     : def base
#  1-5 letter: data base
#  ,,        : local data base
#  this base is used with instant
#  operation  where data is added
#  INSTAT TIME BACK
#  or for normal operation when
#  instant is not selected. All
#  data collected is stored here.
#
#.......................................1.........
BASE SFILE                              SCP
#.......................................xxxxxxxxxx
#
# insert ARC line (1.0), default is no
# ARC line (blank or 0.0)
#
#.......................................1.........
INSERT ARC LINE                         1.0
#.......................................xxxxxxxxxx
#
# seiscomp wood anderson gain, default
# is 2800 (blank) or 2080 

#.......................................1.........
WOOD ANDERSON GAIN
#.......................................xxxxxxxxxx
#
#  for instant operation only:
#  second base for S-files where only
#  s-files for instant time back are
#  kept.
#
#  blank     : no second base
#  1-5 letter: data base
#  ,,        : local data base
#
#......................................1.........
SECOND BASE SFILE                       SCP2
#.......................................xxxxxxxxxx
#
#
#######################################
#  the end
########q###############################