Skip to content

Instantly share code, notes, and snippets.

@transientlunatic
Last active January 16, 2018 12:46
Show Gist options
  • Save transientlunatic/b22ddeaec426e58fdd2f19a531ca7c25 to your computer and use it in GitHub Desktop.
Save transientlunatic/b22ddeaec426e58fdd2f19a531ca7c25 to your computer and use it in GitHub Desktop.
Snippet for loading a gnuradio data file into python
import scipy
import re
data = scipy.fromfile(datafile, dtype=np.float32)
a = re.compile("ra(.*)dec(.*)time(.*).dat")
bandwidth = 4e6
centre = 1420.4e6
filepath = datafile.split('/')
s_ra = float(a.search(filepath[-1]).group(1))
s_dec = float(a.search(filepath[-1]).group(2))
s_time = a.search(filepath[-1]).group(3)
frequencies = np.linspace(centre - bandwidth/2, centre + bandwidth/2, 256)/1e6
data = np.reshape(data, [-1,256])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment