Last active
January 25, 2018 09:33
-
-
Save francoisluus/d4e5d5884c66644c684a4662fb1d29ac to your computer and use it in GitHub Desktop.
line_waterfall()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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