# apply log transform since specgram() returns linear array
arr2D = 10 * np.log10(arr2D)
arr2D[arr2D == -np.inf] = 0 # replace infs with zeros
0 is quite a high number here (it will be more significant than most of your data points and therefore introduce a lot of false peaks). In my own code I've been thresholding before the log, e.g.
data[data < 1e-8] = 1e-8
data = np.log10(data)
which gives more control where the cut-off is. It's hard to say what the threshold cutoff should be.
0 is quite a high number here (it will be more significant than most of your data points and therefore introduce a lot of false peaks). In my own code I've been thresholding before the log, e.g.
which gives more control where the cut-off is. It's hard to say what the threshold cutoff should be.