From 64c1940dac2159fb5d6c733c8049c2fbaf736ab9 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Thu, 8 Apr 2021 13:00:23 -0600 Subject: [PATCH] enforce encoding in _pre_process --- geomagio/edge/MiniSeedInputClient.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/geomagio/edge/MiniSeedInputClient.py b/geomagio/edge/MiniSeedInputClient.py index 9d8370187..f89f336b3 100644 --- a/geomagio/edge/MiniSeedInputClient.py +++ b/geomagio/edge/MiniSeedInputClient.py @@ -20,7 +20,7 @@ class MiniSeedInputClient(object): Floating point precision for output data """ - def __init__(self, host, port=2061, encoding="FLOAT32"): + def __init__(self, host, port=2061, encoding="float32"): self.host = host self.port = port self.encoding = encoding @@ -74,6 +74,13 @@ class MiniSeedInputClient(object): self.connect() # convert stream to miniseed buf = io.BytesIO() + stream = self._pre_process(stream) stream.write(buf, encoding=self.encoding, format="MSEED", reclen=512) # send data self.socket.sendall(buf.getvalue()) + + def _pre_process(self, stream): + for trace in stream: + if trace.data.dtype != self.encoding: + trace.data = trace.data.astype(self.encoding) + return stream -- GitLab