def read_rows(self, filename): """ Read the filterbank data as stream and measure the time """ # init filterbank as stream fil = filterbank.Filterbank(filename) time_start = timer() while True: fil_data = fil.next_row() if isinstance(fil_data, bool): break time_stop = timer() - time_start return time_stop
def read_static(self, filename, DM, scale, size): """ Read the filterbank data at once and measure the time per function/class """ stopwatch = dict.fromkeys([ 'time_read', 'time_select', 'time_clipping', 'time_dedisp', 'time_t_series', 'time_downsample', 'time_fft_vect', 'time_dft', 'time_ifft', 'time_fft_freq' ]) time_start = timer() # init filterbank fil = filterbank.Filterbank(filename, read_all=True, time_range=(0, size)) stopwatch['time_read'] = timer() - time_start # select data time_select = timer() freqs, fil_data = fil.select_data() stopwatch['time_select'] = timer() - time_select # run methods stopwatch = self.measure_methods(stopwatch, fil_data, freqs, DM, scale) return stopwatch
def read_n_rows(self, n, filename, DM, scale): """ Read the filterbank data as stream and measure the time """ fil = filterbank.Filterbank(filename) stopwatch_list = list() while True: stopwatch = dict.fromkeys([ 'time_read', 'time_select', 'time_clipping', 'time_dedisp', 'time_t_series', 'time_downsample', 'time_fft_vect', 'time_dft', 'time_ifft', 'time_fft_freq' ]) time_start = timer() fil_data = fil.next_n_rows(n) # break if EOF if isinstance(fil_data, bool): break stopwatch['time_read'] = timer() - time_start # run methods stopwatch = self.measure_methods(stopwatch, fil_data, fil.freqs, DM, scale) stopwatch_list.append(stopwatch) return stopwatch_list
def _8bit(freq_start, freq_stop): fb1 = fb.Filterbank(filename="../data/pspm8.fil") test1 = fb1.select_data(freq_start, freq_stop) return test1
def _32bit(freq_start, freq_stop): fb3 = fb.Filterbank(filename='../data/pspm32.fil') test3 = fb3.select_data(freq_start, freq_stop) return test3
def _16bit(freq_start, freq_stop): fb2 = fb.Filterbank(filename='../data/pspm16.fil') test2 = fb2.select_data(freq_start, freq_stop) return test2
parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) import numpy as np import matplotlib.pyplot as plt import filterbank.filterbank as fb import dedisperse as dedisperse from plot.static_waterfall import waterfall_plot from clipping import clipping # Read filterbank data, # Standard file special_pspm = fb.Filterbank(filename = "./my_special_pspm.fil") highest_x=10 max_delay=10 special_pspm.read_filterbank() frequencies, samples = special_pspm.select_data() # Plot the original data plt.subplot(2,1,1) data, extent = waterfall_plot(samples, frequencies) img = plt.imshow(data.T, aspect='auto', origin='lower', rasterized=True,