Ejemplo n.º 1
0
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')

# Plot the PSD
plt.grid(True)
plt.xlabel('Frequency (MHz)')
# 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
new_freqs, new_samples = clipping(freqs, samples)

print(new_freqs.shape, new_samples.shape)
Ejemplo n.º 3
0
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()