Skip to content

Instantly share code, notes, and snippets.

@francoisluus
Last active January 25, 2018 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francoisluus/d4e5d5884c66644c684a4662fb1d29ac to your computer and use it in GitHub Desktop.
Save francoisluus/d4e5d5884c66644c684a4662fb1d29ac to your computer and use it in GitHub Desktop.
line_waterfall()
def line_waterfall(compamp, width):
arr = compamp - compamp.mean() # set DC to zero
# Hanning window for smoothing sharp time series start/end in freq. dom.
arr = np.multiply(arr, np.hanning(compamp.shape[0]))
arr = fft.fftshift(fft.fft(arr)) # FFT timeslice
arr = np.abs(arr) # magnitude of FFT
arr = np.divide(arr, 0.5 * np.sqrt(arr.sum())) # normalize to 0.5*sqrt(sum(abs(FFT)))
arr = arr.reshape(width, arr.shape[0]/width).max(axis=(1)) # maxpool to width
arr = np.clip(arr * 255., 0, 255) # ready for grayscale image
return arr.astype(np.uint8)
def stats(compamp):
tmp = np.abs(compamp) ** 2
return tmp.mean(), tmp.std()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment