def test_create_empty_trace(): """TimeseriesUtility_test.test_create_empty_trace() """ trace1 = _create_trace([1, 1, 1, 1, 1], "H", UTCDateTime("2018-01-01")) trace2 = _create_trace([2, 2], "E", UTCDateTime("2018-01-01")) observatory = "Test" interval = "minute" network = "NT" location = "R0" trace3 = TimeseriesUtility.create_empty_trace( starttime=trace1.stats.starttime, endtime=trace1.stats.endtime, observatory=observatory, channel="F", type="variation", interval=interval, network=network, station=trace1.stats.station, location=location, ) timeseries = Stream(traces=[trace1, trace2]) # For continuity set stats to be same for all traces for trace in timeseries: trace.stats.observatory = observatory trace.stats.type = "variation" trace.stats.interval = interval trace.stats.network = network trace.stats.station = trace1.stats.station trace.stats.location = location timeseries += trace3 assert_equal(len(trace3.data), trace3.stats.npts) assert_equal(timeseries[0].stats.starttime, timeseries[2].stats.starttime) TimeseriesUtility.pad_timeseries( timeseries=timeseries, starttime=trace1.stats.starttime, endtime=trace1.stats.endtime, ) assert_equal(len(trace3.data), trace3.stats.npts) assert_equal(timeseries[0].stats.starttime, timeseries[2].stats.starttime) # Change starttime by more than 1 delta starttime = trace1.stats.starttime endtime = trace1.stats.endtime TimeseriesUtility.pad_timeseries(timeseries, starttime - 90, endtime + 90) assert_equal(len(trace3.data), trace3.stats.npts) assert_equal(timeseries[0].stats.starttime, timeseries[2].stats.starttime)
def test_create_empty_trace(): """TimeseriesUtility_test.test_create_empty_trace() """ trace1 = _create_trace([1, 1, 1, 1, 1], 'H', UTCDateTime("2018-01-01")) trace2 = _create_trace([2, 2], 'E', UTCDateTime("2018-01-01")) observatory = 'Test' interval = 'minute' network = 'NT' location = 'R0' trace3 = TimeseriesUtility.create_empty_trace( starttime=trace1.stats.starttime, endtime=trace1.stats.endtime, observatory=observatory, channel='F', type='variation', interval=interval, network=network, station=trace1.stats.station, location=location) timeseries = Stream(traces=[trace1, trace2]) # For continuity set stats to be same for all traces for trace in timeseries: trace.stats.observatory = observatory trace.stats.type = 'variation' trace.stats.interval = interval trace.stats.network = network trace.stats.station = trace1.stats.station trace.stats.location = location timeseries += trace3 assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime) TimeseriesUtility.pad_timeseries( timeseries=timeseries, starttime=trace1.stats.starttime, endtime=trace1.stats.endtime) assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime) # Change starttime by more than 1 delta starttime = trace1.stats.starttime endtime = trace1.stats.endtime TimeseriesUtility.pad_timeseries(timeseries, starttime - 90, endtime + 90) assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime)
def test_create_empty_trace(): """TimeseriesUtility_test.test_create_empty_trace() """ trace1 = _create_trace([1, 1, 1, 1, 1], 'H', UTCDateTime("2018-01-01")) trace2 = _create_trace([2, 2], 'E', UTCDateTime("2018-01-01")) observatory = 'Test' interval = 'minute' network = 'NT' location = 'R0' trace3 = TimeseriesUtility.create_empty_trace( starttime=trace1.stats.starttime, endtime=trace1.stats.endtime, observatory=observatory, channel='F', type='variation', interval=interval, network=network, station=trace1.stats.station, location=location) timeseries = Stream(traces=[trace1, trace2]) # For continuity set stats to be same for all traces for trace in timeseries: trace.stats.observatory = observatory trace.stats.type = 'variation' trace.stats.interval = interval trace.stats.network = network trace.stats.station = trace1.stats.station trace.stats.location = location timeseries += trace3 assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime) TimeseriesUtility.pad_timeseries(timeseries=timeseries, starttime=trace1.stats.starttime, endtime=trace1.stats.endtime) assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime) # Change starttime by more than 1 delta starttime = trace1.stats.starttime endtime = trace1.stats.endtime TimeseriesUtility.pad_timeseries(timeseries, starttime - 90, endtime + 90) assert_equals(len(trace3.data), trace3.stats.npts) assert_equals(timeseries[0].stats.starttime, timeseries[2].stats.starttime)