[seiscomp, scanloc] Install, add .gitignore
This commit is contained in:
BIN
share/plugins/seedlink/caps_plugin
Executable file
BIN
share/plugins/seedlink/caps_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/chain_plugin
Executable file
BIN
share/plugins/seedlink/chain_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/echopro_plugin
Executable file
BIN
share/plugins/seedlink/echopro_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/ewexport_pasv_plugin
Executable file
BIN
share/plugins/seedlink/ewexport_pasv_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/ewexport_plugin
Executable file
BIN
share/plugins/seedlink/ewexport_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/fs_plugin
Executable file
BIN
share/plugins/seedlink/fs_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/gdrt_plugin
Executable file
BIN
share/plugins/seedlink/gdrt_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/minilogger_plugin
Executable file
BIN
share/plugins/seedlink/minilogger_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/mseedfifo_plugin
Executable file
BIN
share/plugins/seedlink/mseedfifo_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/mseedscan_plugin
Executable file
BIN
share/plugins/seedlink/mseedscan_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/naqs_plugin
Executable file
BIN
share/plugins/seedlink/naqs_plugin
Executable file
Binary file not shown.
155
share/plugins/seedlink/optodas_plugin
Executable file
155
share/plugins/seedlink/optodas_plugin
Executable file
@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
############################################################################
|
||||
# Copyright (C) GFZ Potsdam #
|
||||
# All rights reserved. #
|
||||
# #
|
||||
# GNU Affero General Public License Usage #
|
||||
# This file may be used under the terms of the GNU Affero #
|
||||
# Public License version 3.0 as published by the Free Software Foundation #
|
||||
# and appearing in the file LICENSE included in the packaging of this #
|
||||
# file. Please review the following information to ensure the GNU Affero #
|
||||
# Public License version 3.0 requirements will be met: #
|
||||
# https://www.gnu.org/licenses/agpl-3.0.html. #
|
||||
############################################################################
|
||||
|
||||
import sys
|
||||
import struct
|
||||
import json
|
||||
import datetime
|
||||
import argparse
|
||||
import zmq
|
||||
import numpy as np
|
||||
from plugin import Seedlink
|
||||
|
||||
|
||||
VERSION = "0.1 (2024.020)"
|
||||
|
||||
|
||||
def readHeader(text, stationTemplate):
|
||||
header = json.loads(text)
|
||||
unpackFormat = "%d%s" % (header["nChannels"] * header["nPackagesPerMessage"],
|
||||
"f" if header["dataType"] == "float" else "h")
|
||||
|
||||
stations = []
|
||||
|
||||
for roi in header["roiTable"]:
|
||||
for c in range(roi["roiStart"], roi["roiEnd"] + 1, roi["roiDec"]):
|
||||
stations.append(eval("f'''" + stationTemplate + "'''", {"channel": c}))
|
||||
|
||||
if len(stations) != header["nChannels"]:
|
||||
raise Exception("Invalid number of channels in roiTable: %d != %d" %
|
||||
(len(stations), header["nChannels"]))
|
||||
|
||||
return header, stations, unpackFormat
|
||||
|
||||
|
||||
def flushData(seedlink, header, network, stations, startTime, packageData):
|
||||
t = datetime.datetime.utcfromtimestamp(startTime)
|
||||
tq = 100 if header["trustedTimeSource"] else 10
|
||||
data = np.concatenate(packageData).astype(int)
|
||||
|
||||
for i, station in enumerate(stations):
|
||||
seedlink.send_raw3("%s.%s" % (network, station), "X", t, 0, tq, data[:, i])
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.set_defaults(
|
||||
address="tcp://localhost:3333",
|
||||
sample_rate=100,
|
||||
gain=1.0,
|
||||
network="XX",
|
||||
station="{channel:05d}"
|
||||
)
|
||||
|
||||
parser.add_argument("--version",
|
||||
action="version",
|
||||
version="%(prog)s " + VERSION
|
||||
)
|
||||
|
||||
parser.add_argument("-a", "--address",
|
||||
help="ZeroMQ address (default %(default)s)"
|
||||
)
|
||||
|
||||
parser.add_argument("-r", "--sample-rate",
|
||||
type = int,
|
||||
help = "sample rate (default %(default)s)"
|
||||
)
|
||||
|
||||
parser.add_argument("-g", "--gain",
|
||||
type=float,
|
||||
help="gain (default %(default)s)"
|
||||
)
|
||||
|
||||
parser.add_argument("-n", "--network",
|
||||
help="network code (default %(default)s)"
|
||||
)
|
||||
|
||||
parser.add_argument("-s", "--station",
|
||||
help="station code template (default %(default)s)"
|
||||
)
|
||||
|
||||
parser.add_argument("plugin_id",
|
||||
help="plugin ID"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
seedlink = Seedlink()
|
||||
sock = zmq.Context().socket(zmq.SUB)
|
||||
sock.connect(args.address)
|
||||
sock.setsockopt(zmq.SUBSCRIBE, b"")
|
||||
|
||||
header, stations, unpackFormat = readHeader(sock.recv().decode("utf-8"), args.station)
|
||||
packageData = []
|
||||
nPackages = 0
|
||||
startTime = None
|
||||
timestamp = None
|
||||
|
||||
while True:
|
||||
message = sock.recv()
|
||||
|
||||
if len(message) != header["bytesPerPackage"] * header["nPackagesPerMessage"] + 8:
|
||||
try:
|
||||
if nPackages > 0:
|
||||
flushData(seedlink, header, args.network, stations, startTime, packageData)
|
||||
packageData = []
|
||||
nPackages = 0
|
||||
|
||||
header, stations, unpackFormat = readHeader(message.decode("utf-8"))
|
||||
print("%s: Parameters Changed. Updated header, ROIs and format" %
|
||||
args.plugin_id, file=sys.stderr)
|
||||
|
||||
except:
|
||||
print("%s: Unknown msg. Size: %d" % (args.plugin_id, len(message)),
|
||||
file=sys.stderr)
|
||||
|
||||
continue
|
||||
|
||||
prevTimestamp = timestamp
|
||||
timestamp = struct.unpack("<Q", message[:8])[0] * 1e-9
|
||||
|
||||
if nPackages >= args.sample_rate or (nPackages > 0 and
|
||||
int(round(1 / (timestamp - prevTimestamp))) != args.sample_rate):
|
||||
flushData(seedlink, header, args.network, stations, startTime, packageData)
|
||||
packageData = []
|
||||
nPackages = 0
|
||||
|
||||
if nPackages == 0:
|
||||
startTime = timestamp
|
||||
|
||||
data = np.array(struct.unpack(unpackFormat, message[8:])) \
|
||||
.reshape((header["nPackagesPerMessage"], header["nChannels"]))
|
||||
|
||||
if args.gain != 1.0:
|
||||
data *= args.gain
|
||||
|
||||
packageData.append(data)
|
||||
nPackages += header["nPackagesPerMessage"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
72
share/plugins/seedlink/plugin.py
Normal file
72
share/plugins/seedlink/plugin.py
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
############################################################################
|
||||
# Copyright (C) GFZ Potsdam #
|
||||
# All rights reserved. #
|
||||
# #
|
||||
# GNU Affero General Public License Usage #
|
||||
# This file may be used under the terms of the GNU Affero #
|
||||
# Public License version 3.0 as published by the Free Software Foundation #
|
||||
# and appearing in the file LICENSE included in the packaging of this #
|
||||
# file. Please review the following information to ensure the GNU Affero #
|
||||
# Public License version 3.0 requirements will be met: #
|
||||
# https://www.gnu.org/licenses/agpl-3.0.html. #
|
||||
############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import struct
|
||||
|
||||
|
||||
_doy = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365)
|
||||
|
||||
|
||||
def _is_leap(y):
|
||||
"""True if y is a leap year."""
|
||||
return (y % 400 == 0) or (y % 4 == 0 and y % 100 != 0)
|
||||
|
||||
|
||||
def _ldoy(y, m):
|
||||
"""The day of the year of the first day of month m, in year y.
|
||||
|
||||
Note: for January, m=1; for December, m=12.
|
||||
Examples:
|
||||
_ldoy(1900, 4) = 90
|
||||
_ldoy(1900, 1) = 0
|
||||
_ldoy(1999, 4) = 90
|
||||
_ldoy(2004, 4) = 91
|
||||
_ldoy(2000, 4) = 91
|
||||
|
||||
"""
|
||||
return _doy[m - 1] + (_is_leap(y) and m >= 3)
|
||||
|
||||
|
||||
def _mdy2dy(month, day, year):
|
||||
return _ldoy(year, month) + day
|
||||
|
||||
|
||||
class Seedlink(object):
|
||||
def __init__(self):
|
||||
self.__fd = os.fdopen(63, "wb")
|
||||
|
||||
def send_raw3(self, sta, cha, t, usec_corr, tqual, data):
|
||||
packet = struct.pack(
|
||||
"@i10s10s9i%di" % len(data),
|
||||
8,
|
||||
sta.encode(),
|
||||
cha.encode(),
|
||||
t.year,
|
||||
_mdy2dy(t.month, t.day, t.year),
|
||||
t.hour,
|
||||
t.minute,
|
||||
t.second,
|
||||
t.microsecond,
|
||||
usec_corr,
|
||||
tqual,
|
||||
len(data),
|
||||
*data
|
||||
)
|
||||
|
||||
self.__fd.write(packet)
|
||||
self.__fd.flush()
|
||||
|
BIN
share/plugins/seedlink/q330_plugin
Executable file
BIN
share/plugins/seedlink/q330_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/reftek_plugin
Executable file
BIN
share/plugins/seedlink/reftek_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/scream_plugin
Executable file
BIN
share/plugins/seedlink/scream_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/scream_plugin_ring
Executable file
BIN
share/plugins/seedlink/scream_plugin_ring
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/serial_plugin
Executable file
BIN
share/plugins/seedlink/serial_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/sock_plugin
Executable file
BIN
share/plugins/seedlink/sock_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/wave24_plugin
Executable file
BIN
share/plugins/seedlink/wave24_plugin
Executable file
Binary file not shown.
BIN
share/plugins/seedlink/win_plugin
Executable file
BIN
share/plugins/seedlink/win_plugin
Executable file
Binary file not shown.
Reference in New Issue
Block a user