# pylint: disable-all import os, sys, inspect CURRENT_DIR = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) PARENT_DIR = os.path.dirname(CURRENT_DIR) sys.path.insert(0, PARENT_DIR) import matplotlib.animation as animation from filterbank.header import read_header from filterbank.filterbank import Filterbank from plot import waterfall import pylab as pyl from plot.plot import next_power_of_2 fb = Filterbank(filename='./pspm32.fil') wf = waterfall.Waterfall(fb=fb, fig=pyl.figure(), mode="stream") fig, update, frames, repeat = wf.animated_plotter() ani = animation.FuncAnimation(fig, update, frames=frames, repeat=repeat) pyl.show()
""" Example of clipping RFI from filterbank data """ # pylint: disable-all import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) import matplotlib.pyplot as plt from timeseries.timeseries import Timeseries from filterbank.filterbank import Filterbank from plot.static_waterfall import waterfall_plot from clipping.clipping import clipping # init filterbank object fil = Filterbank(filename='./pspm32.fil', read_all=True) # retrieve channels and samples from filterbank freqs, samples = fil.select_data() print(freqs.shape, samples.shape) # visualize data before clipping time_series = Timeseries() time_series.from_filterbank(fil) plt.subplot(2,1,1) plt.plot(time_series.timeseries) # perform clipping on the filterbank data
# pylint: disable-all import os, sys, inspect CURRENT_DIR = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) PARENT_DIR = os.path.dirname(CURRENT_DIR) sys.path.insert(0, PARENT_DIR) import matplotlib.animation as animation from filterbank.header import read_header from filterbank.filterbank import Filterbank from plot import waterfall import pylab as pyl from plot.plot import next_power_of_2 fb = Filterbank(filename='./pspm32.fil', read_all=True) wf = waterfall.Waterfall(filter_bank=fb, fig=pyl.figure(), mode="discrete") img = wf.get_image() pyl.show(img)
import os import sys import inspect # Volkswagened this example as it is just an example for educational purposes, no production code. # pylint: disable-all CURRENT_DIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) PARENT_DIR = os.path.dirname(CURRENT_DIR) sys.path.insert(0, PARENT_DIR) from timeseries.timeseries import Timeseries from filterbank.filterbank import Filterbank import matplotlib.pyplot as plt # Initialize filterbank based on the pspm32.fil file. This filterbank object can then be used for other actions. fb = Filterbank("./pspm32.fil") fb.read_filterbank() # Creating timeseries object from filterbank file which is initialized above. time_series = Timeseries().from_filterbank(fb) # Using the downsample method from the timeseries object. decimated_tv = time_series.downsample(3) # Plotting the downsampled result. plt.plot(decimated_tv) plt.show()
import sys import inspect import numpy as np import matplotlib.pyplot as plt CURRENT_DIR = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) PARENT_DIR = os.path.dirname(CURRENT_DIR) sys.path.insert(0, PARENT_DIR) from plot import opsd from filterbank.header import read_header from filterbank.filterbank import Filterbank # Instatiate the filterbank reader and point to the filterbank file fb = Filterbank(filename='./pspm32.fil', read_all=True) # read the data in the filterbank file f, samples = fb.select_data() # Assign the center frequency with the data in the header center_freq = fb.header[b'center_freq'] print(samples.shape) # Get the powerlevels and the frequencies print(samples[0]) power_levels, freqs, _ = opsd(samples[0], nfft=128, sample_rate=80, sides='twosided')
from filterbank.generate import generate_file header = { b'source_name': b'P: 80.0000 ms, DM: 200.000', b'machine_id': 10, b'telescope_id': 4, b'data_type': 1, b'fch1': 400, b'foff': -0.062, b'nchans': 128, b'tstart': 6000.0, b'tsamp': 8e-05, b'nifs': 1, b'nbits': 8 } filename = './examples/pspm.fil' # generate a fake filterbank file generate_file(filename, header) # read fake filterbank file fil = Filterbank(filename, read_all=True) # select data from fitlerbank _, data = fil.select_data() # plot one sample plt.plot(data[0]) plt.show()
from filterbank.filterbank import Filterbank fil = Filterbank('data/voyager_f1032192_t300_v2.fil')