Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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