From c7a942db45d05aab6833030dfe01d006defda911 Mon Sep 17 00:00:00 2001 From: pcain <pcain@usgs.gov> Date: Wed, 8 Sep 2021 16:27:37 +0000 Subject: [PATCH] Define mock client in separate file --- test/edge_test/MockMiniSeedClient.py | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/edge_test/MockMiniSeedClient.py diff --git a/test/edge_test/MockMiniSeedClient.py b/test/edge_test/MockMiniSeedClient.py new file mode 100644 index 000000000..88c6a4b61 --- /dev/null +++ b/test/edge_test/MockMiniSeedClient.py @@ -0,0 +1,39 @@ +import numpy +from obspy import Stream, UTCDateTime +from obspy.clients.neic.client import Client + +from geomagio import TimeseriesUtility +from geomagio.edge import SNCL + + +class MockMiniSeedClient(Client): + """replaces default obspy miniseed client's get_waveforms method to return trace of ones""" + + def get_waveforms( + self, + network: str, + station: str, + location: str, + channel: str, + starttime: UTCDateTime, + endtime: UTCDateTime, + ): + sncl = SNCL( + station=station, + network=network, + channel=channel, + location=location, + ) + trace = TimeseriesUtility.create_empty_trace( + starttime=starttime, + endtime=endtime, + observatory=station, + channel=channel, + type=sncl.data_type, + interval=sncl.interval, + network=network, + station=station, + location=location, + ) + trace.data = numpy.ones(trace.stats.npts) + return Stream([trace]) -- GitLab