From af72dc0ff323eed8a1ce5ca87b0c76f223cd7050 Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Mon, 20 Mar 2023 16:39:31 -0600 Subject: [PATCH] Force traces in stream to first dtype before merge A Stream corresponding to a given network, station, location, and channel can (but probably shouldn't) have more than 1 trace returned from an ObsPy client.get_waveforms() function. This happens, for example, when the data type generated by a given station changes. This change forces the dtype of the data array for all Traces in the Stream to match the dtype of the data array in the first Trace of the Stream, thus allowing the Stream.merge() function to work as intended. --- geomagio/edge/MiniSeedFactory.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geomagio/edge/MiniSeedFactory.py b/geomagio/edge/MiniSeedFactory.py index ff03c0406..c9c3122c1 100644 --- a/geomagio/edge/MiniSeedFactory.py +++ b/geomagio/edge/MiniSeedFactory.py @@ -361,6 +361,8 @@ class MiniSeedFactory(TimeseriesFactory): data = self.client.get_waveforms( sncl.network, sncl.station, sncl.location, sncl.channel, starttime, endtime ) + for trace in data: + trace.data = trace.data.astype(data[0].data.dtype) data.merge() if data.count() == 0 and add_empty_channels: data += self._get_empty_trace( -- GitLab