def test_begin_averaging(self): ts = timeseries.Timeseries() delta = datetime.timedelta(minutes=1) ts.set_averaging_period(delta) dt = datetime.datetime(2019, 1, 1, 12, 43, 42) ts.add(0.0, dt) dt = datetime.datetime(2019, 1, 1, 12, 43, 0) self.assertEqual(ts.begin(), dt)
def test_averaging(self): ts = timeseries.Timeseries() ts.set_averaging_period(datetime.timedelta(minutes=1)) dt = datetime.datetime(2019, 1, 1, 12, 0, 0) delta = datetime.timedelta(seconds=15) ts.add(0.0, dt) dt += delta ts.add(1.0, dt) dt += delta ts.add(2.0, dt) dt = datetime.datetime(2019, 1, 1, 12, 1, 5) ts.add(1.0, dt) self.assertEqual(len(ts.time), 2)
def test_no_averaging(self): ts = timeseries.Timeseries() dt = datetime.datetime(2019, 1, 1, 12, 0, 0) delta = datetime.timedelta(seconds=15) ts.add(0.0, dt) dt += delta ts.add(1.0, dt) dt += delta ts.add(2.0, dt) dt = datetime.datetime(2019, 1, 1, 12, 1, 0) ts.add(1.0, dt) self.assertEqual(len(ts.time), 4) self.assertEqual(len(ts), 4)
def measure_methods(self, stopwatch, fil_data, freqs, DM, scale): """ Run and time all methods/modules """ # clipping time_clipping = timer() _, _ = clipping.clipping(freqs, fil_data) stopwatch['time_clipping'] = timer() - time_clipping # dedisperse time_dedisp = timer() fil_data = dedisperse.dedisperse(fil_data, disperion_measure=DM) stopwatch['time_dedisp'] = timer() - time_dedisp # timeseries time_t_series = timer() time_series = timeseries.Timeseries(fil_data) stopwatch['time_t_series'] = timer() - time_t_series # downsample time_downsamp = timer() time_series = time_series.downsample(scale) stopwatch['time_downsample'] = timer() - time_downsamp # fft vect time_fft_vect = timer() fourier.fft_vectorized(time_series) stopwatch['time_fft_vect'] = timer() - time_fft_vect # dft time_dft = timer() fourier.dft_slow(time_series) stopwatch['time_dft'] = timer() - time_dft # ifft time_ifft = timer() fourier.ifft(time_series) stopwatch['time_ifft'] = timer() - time_ifft # fft freq time_fft_freq = timer() fourier.fft_freq(10) stopwatch['time_fft_freq'] = timer() - time_fft_freq return stopwatch
def test_constructor_basic(self): ts = timeseries.Timeseries() self.assertEqual(str(ts), "[][]")
def test_begin_no_averaging(self): ts = timeseries.Timeseries() dt = datetime.datetime(2019, 1, 1, 12, 0, 0) ts.add(0.0, dt) self.assertEqual(ts.begin(), dt)