-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window Welch periodogram with Hann window by default. #153
base: master
Are you sure you want to change the base?
Conversation
This choice is used by scipy, and seems less likely than the square window to produce completely wrong results for novice users. matlab and octave use the Hamming window, but this works very poorly for signals with a nontrivial DC component when `n != nfft`.
tradeoff between high spectral resolution (the square window) and | ||
sensitivity to signals near the noise floor. A window which falls to zero | ||
also reduces the spurious ringing which occurs when ``n!=nfft`` for signals | ||
with large mean. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems misleading - unless I'm misunderstanding something, using a rectangular window should give poor spectral resolution (lots of spectral leakage between bins) vs. the hanning, which should have less leakage. I suppose it depends on whether you mean main lobe width or energy in the sidelobes, but the sidelobes of the rectangular window fall off slowly enough that I definitely wouldn't consider it to have high spectral resolution.
a rectangular window will give you the same sort of ringing if the beginning of the windowed signal differs from the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I honestly can't remember quite what I was thinking at the time I wrote this, or even the precise detail of what I was doing with this code.
I do know that the default caused me some confusion, and that some discussion of the inherent tradeoffs between different windows would be useful.
Feel free to reword it as you please, or close the PR.
I like the idea of using beginner friendly default parameters, and as you mention in #152 it seems equivalent functions in scipy/octave use friendlier defaults than DSP.jl. The issues your described in #152 may also stem from this function not detrending each data segment, which will cause artifacts when In order to make the Welch function better behaved over a range of parameters, it may help to make sure |
Agreed, all good suggestions. |
Regarding the comment on high spectral resolution quoted above. If high spectral resolution means high frequency resolution, as seems reasonable, then this statement is accurate. As you can see in http://papers.vibetech.com/Paper64-CompilationofTimeWindowsandLineShapesRPotter.pdf, the main lobe of this window has a width of 1. However its amplitude accuracy in general is very poor. When used for a completely contained transient signal or a signal periodic within the window it is the best window to use. https://d3i5bpxkxvwmz.cloudfront.net/articles/2011/02/27/fundamentals-of-signal-analysis-1298867011.pdf gives a reasonable intuitive understanding. This is the window of choice for burst random modal analysis because the signal is (should be) zero outside the window so is a completely contained transient. Traditional dynamic signal analysers, DSA's, typically have the rectangular, hanning, and Flattop window. Rectangular gives the best frequency resolution and very poor amplitude resolution, Flattop gives excellent amplitude resolution but poor frequency resolution, and hanning is a computationally efficient compromise. The paper by Potter, referred to above gives a number of other windows that are interesting as does the paper by Nutall, https://pdfs.semanticscholar.org/a1fa/3f3bdcb92e17b01d982e660841630991e868.pdf. |
This choice is used by scipy, and seems less likely than the square
window to produce completely wrong results for novice users. matlab and
octave use the Hamming window, but this works very poorly for signals
with a nontrivial DC component when
n != nfft
.Fixes #152, at least for me, but review by someone with a lot more signal processing experience would be most useful.
The tests against reference data will fail here, but can be fixed up if this change is desired.