Newer
Older
Wilbur, Spencer Franklin
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy
from obspy import Stream, UTCDateTime
from obspy.clients.neic.client import Client
from geomagio import TimeseriesUtility
from geomagio.edge import FDSNSNCL
class MockFDSNSeedClient(Client):
"""replaces default obspy miniseed client's get_waveforms method to return trace of ones
Note: includes 'return_empty' parameter to simulate situations where no data is received
"""
def __init__(self, return_empty: bool = False):
self.return_empty = return_empty
def get_waveforms(
self,
network: str,
station: str,
location: str,
channel: str,
starttime: UTCDateTime,
endtime: UTCDateTime,
):
if self.return_empty:
return Stream()
sncl = FDSNSNCL(
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])