6.9.2

# sh2proc

Convert SeismicHandler event files to SCML.

## Description

sh2proc converts Seismic Handler event data to SeisComP XML format. Data is read from input file or stdin if no input file is specified. The result is available on stdout.

## Code mapping

Since Seismic Handler only specifies station and component codes, a mapping to SeisComP network, location and channel codes is necessary. The script assumes that the same station code is not used in different networks. In case an ambiguous id is found a warning is printed and the first network code is used. The channel and stream code is extracted from the dectecStream and detecLocid configured in the global bindings. In case no configuration module is available the first location and stream is used.

## Event parameters

- Event types given in Seismic Handler files are mapped to SeisComP event types:

  Seismic Handler | SeisComP
  --- | ---
  teleseismic quake | earthquake
  regional quake | earthquake
  local quake | earthquake
  quarry blast | quarry blast
  nuclear explosion | nuclear explosion
  mining event | mining explosion

- The EventID given in Seismic Handler files is mapped as a comment to the event.

## Magnitudes

- Magnitude types given in Seismic Handler files are mapped to SeisComP magnitudes:

  Seismic Handler | SeisComP
  --- | ---
  m | M
  ml | ML
  mb | mb
  ms | Ms(BB)
  mw | Mw
  bb | mB

- ML magnitudes in Seismic Handler files have no corresponding measured amplitudes. Therefore the ML station magnitudes are converted without referencing the amplitude.

- Seismic Handler uses the phase name “L” for referring to surface waves without further specification. The phase name is kept unchanged.

## Distance calculations

In Seismic Handler files distances can be given in units of km or degree but in SeisComP only degree is used. Both representations are considered for conversion. In case of double posting preference is given to the Seismic Handler values given in km due to their higher precision.

## Beam parameters

Seismic Handler files provide the phase picks with theoretical, measured and corrected slowness and (back) azimuth but the pick in SeisComP knows only one value. During conversion highest preference is given to corrected values. The theoretical values are ignored.

## Limitations

The following parameters from Seismic Handler files are not considered:

- Phase Flag

- Location Input Params

- Reference Location Name

- Quality Number

- Ampl&Period Source

- Location Quality

- Reference Latitude

- Reference Longitude

- Amplitude Time

## Further processing in SeisComP

The created XML files can be used in multiple ways, e.g.:

1. By other modules in an XML-base playback

2. Inject into the messaging system by scdispatch

3. Integrate into the database by scdb

## Examples

1. Convert the Seismic Handler file shm.evt and writes SCML into the file sc.xml. The database connection to read inventory and configuration information is fetched from the default messaging connection.

       sh2proc shm.evt > sc.xml

2. Read Seismic Handler data from stdin. Inventory and configuration information is provided through files.

       cat shm.evt | sh2proc --inventory-db=inventory.xml --config-db=config.xml > sc.xml

## shm.evt file format

The list of parameters supported by sh2proc may be incomplete. Read the original format and parameter description of the SeismicHandler .evt files for providing correct input files.

Example of a SeismicHandler shm.evt file with supported parameters:

    Event ID               : 1170102002
    Station code           : VITZ
    Onset time             : 2-JAN-2017_12:25:40.415
    Onset type             : emergent
    Phase name             : Pg
    Event Type             : mining event
    Applied filter         : SHM_BP_1HZ_25HZ_3
    Component              : Z
    Quality number         : 2
    Pick Type              : manual
    Weight                 : 4
    Theo. Azimuth (deg)    :   27.29
    Theo. Backazimuth (deg):  207.36
    Distance (deg)         :  0.122
    Distance (km)          : 13.572
    Magnitude ml           : 1.0
    Phase Flags            : L
    --- End of Phase ---

    Event ID               : 1170102002
    Station code           : WESF
    Onset time             : 2-JAN-2017_12:25:53.714
    Onset type             : emergent
    Phase name             : Pg
    Event Type             : mining event
    Applied filter         : SHM_BP_1HZ_25HZ_3
    Component              : Z
    Quality number         : 2
    Pick Type              : manual
    Weight                 : 4
    Theo. Azimuth (deg)    :  106.98
    Theo. Backazimuth (deg):  287.91
    Distance (deg)         :  0.807
    Distance (km)          : 89.708
    Magnitude ml           : 1.8
    Mean Magnitude ml      : 1.1
    Latitude               : +50.779
    Longitude              :  +10.003
    Depth (km)             :   0.0
    Depth type             : (g) estimated
    Origin time            :  2-JAN-2017_12:25:38.273
    Region Table           : GEO_REG
    Region ID              : 5326
    Source region          : Tann, E of Fulda
    Velocity Model         : deu
    Location Input Params  : 20
    Reference Location Name: CENTRE
    --- End of Phase ---

## Module Configuration

`etc/defaults/global.cfg`
`etc/defaults/sh2proc.cfg`
`etc/global.cfg`
`etc/sh2proc.cfg`
`~/.seiscomp/global.cfg`
`~/.seiscomp/sh2proc.cfg`

sh2proc inherits global options.

## Command-Line Options

sh2proc [options]

### Generic

-h, --help

  Show help message.

-V, --version

  Show version information.

--config-file arg

  Use alternative configuration file. When this option is used the loading of all stages is disabled. Only the given configuration file is parsed and used. To use another name for the configuration create a symbolic link of the application or copy it. Example: scautopick -> scautopick2.

--plugins arg

  Load given plugins.

-D, --daemon

  Run as daemon. This means the application will fork itself and doesn’t need to be started with &.

--auto-shutdown arg

  Enable/disable self-shutdown because a master module shutdown. This only works when messaging is enabled and the master module sends a shutdown message (enabled with --start-stop-msg for the master module).

--shutdown-master-module arg

  Set the name of the master-module used for auto-shutdown. This is the application name of the module actually started. If symlinks are used, then it is the name of the symlinked application.

--shutdown-master-username arg

  Set the name of the master-username of the messaging used for auto-shutdown. If "shutdown-master-module" is given as well, this parameter is ignored.

### Verbosity

--verbosity arg

  Verbosity level [0..4]. 0:quiet, 1:error, 2:warning, 3:info, 4:debug.

-v, --v

  Increase verbosity level (may be repeated, eg. -vv).

-q, --quiet

  Quiet mode: no logging output.

--component arg

  Limit the logging to a certain component. This option can be given more than once.

-s, --syslog

  Use syslog logging backend. The output usually goes to /var/lib/messages.

-l, --lockfile arg

  Path to lock file.

--console arg

  Send log output to stdout.

--debug

  Execute in debug mode. Equivalent to --verbosity=4 --console=1 .

--log-file arg

  Use alternative log file.

### Messaging

-u, --user arg

  Overrides configuration parameter `connection.username`.

-H, --host arg

  Overrides configuration parameter `connection.server`.

-t, --timeout arg

  Overrides configuration parameter `connection.timeout`.

-g, --primary-group arg

  Overrides configuration parameter `connection.primaryGroup`.

-S, --subscribe-group arg

  A group to subscribe to. This option can be given more than once.

--content-type arg

  Overrides configuration parameter `connection.contentType`.

--start-stop-msg arg

  Set sending of a start and a stop message.

### Database

--db-driver-list

  List all supported database drivers.

-d, --database arg

  The database connection string, format: service://user:pwd@host/database. "service" is the name of the database driver which can be queried with "--db-driver-list".

--config-module arg

  The config module to use.

--inventory-db arg

  Load the inventory from the given database or file, format: [service://]location .

--db-disable

  Do not use the database at all