Skip to content

Commit

Permalink
Replace read_header references to support blimpy 2.0.0, update to v1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrzycki committed Apr 22, 2020
1 parent 4452b4c commit 7a6adba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
11 changes: 6 additions & 5 deletions setigen/split_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import errno
import numpy as np
from blimpy import read_header, Waterfall
from blimpy import Waterfall


def split_waterfall_generator(waterfall_fn, fchans, tchans=None, f_shift=None):
Expand Down Expand Up @@ -35,10 +35,11 @@ def split_waterfall_generator(waterfall_fn, fchans, tchans=None, f_shift=None):
A blimpy Waterfall object containing a smaller section of the data
"""

fch1 = read_header(waterfall_fn)[b'fch1']
nchans = read_header(waterfall_fn)[b'nchans']
df = abs(read_header(waterfall_fn)[b'foff'])
tchans_tot = Waterfall(waterfall_fn, load_data=False).container.selection_shape[0]
info_wf = Waterfall(waterfall_fn, load_data=False)
fch1 = info_wf.header[b'fch1']
nchans = info_wf.header[b'nchans']
df = abs(info_wf.header[b'foff'])
tchans_tot = info_wf.container.selection_shape[0]

if f_shift is None:
f_shift = fchans
Expand Down
39 changes: 12 additions & 27 deletions setigen/waterfall_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import numpy as np
from blimpy import read_header, Waterfall
from blimpy import Waterfall


def max_freq(waterfall):
Expand Down Expand Up @@ -90,16 +90,14 @@ def get_fs(waterfall):
Frequency values
"""
if isinstance(waterfall, str):
fch1 = read_header(waterfall)[b'fch1']
df = read_header(waterfall)[b'foff']
fchans = read_header(waterfall)[b'nchans']
elif isinstance(waterfall, Waterfall):
fch1 = waterfall.header[b'fch1']
df = waterfall.header[b'foff']
fchans = waterfall.header[b'nchans']
else:
waterfall = Waterfall(waterfall, load_data=False)
elif not isinstance(waterfall, Waterfall):
sys.exit('Invalid data file!')

fch1 = waterfall.header[b'fch1']
df = waterfall.header[b'foff']
fchans = waterfall.header[b'nchans']

return np.arange(fch1, fch1 + fchans * df, df)


Expand All @@ -118,24 +116,11 @@ def get_ts(waterfall):
Time values
"""
if isinstance(waterfall, str):
tsamp = read_header(waterfall)[b'tsamp']
elif isinstance(waterfall, Waterfall):
tsamp = waterfall.header[b'tsamp']
else:
sys.exit('Invalid fil file!')
waterfall = Waterfall(waterfall, load_data=False)
elif not isinstance(waterfall, Waterfall):
sys.exit('Invalid data file!')

if isinstance(waterfall, str):
fch1 = read_header(waterfall)[b'fch1']
df = read_header(waterfall)[b'foff']
else:
fch1 = waterfall.header[b'fch1']
df = waterfall.header[b'foff']

waterfall0 = Waterfall(waterfall, f_start=fch1, f_stop=fch1 + df)

try:
tchans = get_data(waterfall0).shape[0]
except Exception as e:
sys.exit('No data in filterbank file!')
tsamp = waterfall.header[b'tsamp']
tchans = waterfall.container.selection_shape[0]

return np.arange(0, tchans * tsamp, tsamp)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='setigen',
version='1.2.3',
version='1.2.4',
author='Bryan Brzycki',
author_email='[email protected]',
description='SETI radio signal generator',
Expand Down

0 comments on commit 7a6adba

Please sign in to comment.