DSP.jl icon indicating copy to clipboard operation
DSP.jl copied to clipboard

Window Welch periodogram with Hann window by default.

Open c42f opened this issue 8 years ago • 6 comments
trafficstars

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.

c42f avatar Feb 17 '17 07:02 c42f

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 n != nfft and the window is not chosen carefully. As no particular care is taken to make sure that n = nfft by default, and the default window is a boxcar, it seems like the current defaults may not be the best.

In order to make the Welch function better behaved over a range of parameters, it may help to make sure n = nfft by default. Additionally, it may help to add an option to detrend each data segment, which would in turn require changes to ArraySplit which is used to split the input data into segments. Scipy seems to detrend each data segment as well.

galenlynch avatar Oct 27 '18 15:10 galenlynch

Agreed, all good suggestions.

c42f avatar Oct 28 '18 06:10 c42f

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.

JakeZw avatar Mar 10 '21 21:03 JakeZw