Skip to content

Instantly share code, notes, and snippets.

@alexer
Created October 25, 2018 04:57
Show Gist options
  • Save alexer/9efe768411cf6c68325cac750717b44b to your computer and use it in GitHub Desktop.
Save alexer/9efe768411cf6c68325cac750717b44b to your computer and use it in GitHub Desktop.
Convert rtl-sdr uint8-complex output file to a memory-mapped numpy complex128 array
import numpy as np
def rtlsdr2numpy(datafilename, tempfilename):
real = np.memmap(datafilename, mode='r', dtype='uint8')
temp = np.memmap(tempfilename, mode='w+', dtype='float64', shape=real.shape)
temp[:] = real
temp /= 127.5
temp -= 1
return temp.view('complex128')
A = rtlsdr2numpy('data.dat', 'temp.dat')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment