def test_get_stream_gaps(): """geomag.TimeseriesUtility_test.test_get_stream_gaps confirms that gaps are found in a stream """ stream = Stream([ __create_trace('H', [numpy.nan, 1, 1, numpy.nan, numpy.nan]), __create_trace('Z', [0, 0, 0, 1, 1, 1]) ]) for trace in stream: # set time of first sample trace.stats.starttime = UTCDateTime('2015-01-01T00:00:00Z') # set sample rate to 1 second trace.stats.delta = 1 # find gaps gaps = TimeseriesUtility.get_stream_gaps(stream) assert_equals(len(gaps['H']), 2) # gap at start of H gap = gaps['H'][0] assert_equals(gap[0], UTCDateTime('2015-01-01T00:00:00Z')) assert_equals(gap[1], UTCDateTime('2015-01-01T00:00:00Z')) # gap at end of H gap = gaps['H'][1] assert_equals(gap[0], UTCDateTime('2015-01-01T00:00:03Z')) assert_equals(gap[1], UTCDateTime('2015-01-01T00:00:04Z')) # no gaps in Z channel assert_equals(len(gaps['Z']), 0)
def test_xyzalgorithm_process(): """XYZAlgorithm_test.test_xyzalgorithm_process() confirms that a converted stream contains the correct outputchannels. """ algorithm = XYZAlgorithm('obs', 'geo') timeseries = Stream() timeseries += __create_trace('H', [1, 1]) timeseries += __create_trace('E', [1, 1]) timeseries += __create_trace('Z', [1, 1]) timeseries += __create_trace('F', [1, 1]) outputstream = algorithm.process(timeseries) assert_is(outputstream[0].stats.channel, 'X')
def test_get_trace_gaps(): """geomag.TimeseriesUtility_test.test_get_trace_gaps confirm that gaps are found in a trace """ trace = __create_trace('H', [1, 1, numpy.nan, numpy.nan, 0, 1]) # set time of first sample trace.stats.starttime = UTCDateTime('2015-01-01T00:00:00Z') # set sample rate to 1 minute trace.stats.delta = 60 # find gap gaps = TimeseriesUtility.get_trace_gaps(trace) assert_equals(len(gaps), 1) gap = gaps[0] assert_equals(gap[0], UTCDateTime('2015-01-01T00:02:00Z')) assert_equals(gap[1], UTCDateTime('2015-01-01T00:03:00Z'))