* \section sec_foutra_hanning_PSD_scaling Scaling factor for Hanning taper when applied in PSD calculation * * Tapering stationary noise with a Hanning taper reduces total signal energy * an thus the signal power obtained through an FFT. In his tutorial Agnew * recommends to scale each sample \f$s_k\f$ of the series by \f$w_k/W\f$, * where \f$w_k\f$ is the \f$k\f$-th sample of the taper and * * \f[ * W^2 = \frac{1}{N} \sum\limits_0^{N-1} w_k^2 * \f] * * is a measure for the loss in total signal power due to application of the * taper. This applies only for staionary noise. * * From Walter's Matlab * scripts I took: * * If data is the time series vector and y is the Hanning taper of appropriate * length, Walter calculates * * \code * w = sqrt(sum(y.*y)/ndata); * \endcode * * and * * \code * y=y/w; * \endcode * * where ndata is the length of data and y. * * For a Hanning taper * \f[ * w_k = \sin^2(k \pi/(N-1)). * \f] * * Thus * * \f[ * W^2 = \frac{1}{N} \sum\limits_0^{N-1} \sin^4(k\pi/(N-1)) * \f] * * From Gradshteyn and Ryzhik (eq. 1.321 3) I find * * \f[ * \sin^4(k\pi/(N-1)) * * = \frac{1}{8} \left( \cos(4 k\pi/(N-1)) * - 4 \cos(2 k\pi/(N-1)) * + 3 \right). * \f] * * Within the sum the contribution of both cos-terms will vanish, since both * are averaged over one and two periods, respectively. Thus * * \f[ * W^2 = \frac{1}{N} \sum\limits_0^{N-1} \frac{3}{8} = \frac{3}{8}. * \f] * * Since foutra is not scaling the taper but scaling the power spectrum, we * have to apply the factor 8/3 to the result of power spectrum calculation. * * This factor 8/3=2.66667 was tested against the value for \f$W^2\f$, when * explicitely derived from a Hanning taper time series by the above formula. * * In the Makefile you will find a section with test code. * This offers instantaneous testing of PSD scaling in foutra. * \dontinclude Makefile * \skip # test foutra PSD scaling * \until #---------------------------------------------------------------------- * * \date 13/9/2007 \author thof * */ /*----------------------------------------------------------------------*/ /*! \page page_foutra *
* \section sec_foutra_scaling_harmonics Scaling for harmonic signals * * For harmonic signals the FFT normalized to the duration of the available * time window has an amplitude of the value of the maximum of the Fourier * transform of the window function times half the amplitude of the time domain * signal. To obtain a spectral representation with peaks of the amplitude of * the time domain signal, the FFT must be scaled accordingly. * * We understand * \f[ * \tilde{f}(\omega)=\int\limits_{-\infty}^{+\infty} * f(t) \,e^{-i\omega t} \textrm{d}{t}. * \f] * as the Fourier transformation of the time domain signal * \f[ * f(t)=\int\limits_{-\infty}^{+\infty} * \tilde{f}(\omega) \,e^{i\omega t} \frac{\textrm{d}{\omega}}{2\pi}. * \f] * If we apply a time domain window function \f$w(t)\f$ to the function * \f$f(t)\f$, we obtain the tapered function * \f[ * g(t)=f(t) w(t) * \f] * and its Fourier transform * \f[ * \tilde{g}(\omega)=\int\limits_{-\infty}^{+\infty} * \tilde{f}(\omega')\,\tilde{w}(\omega-\omega')\,\textrm{d}\omega. * \f] * * \subsection subsec_foutra_scaling_harmonics_harmsig Application to harmonic signals * * Let * \f[ * f(t)=A\,\cos(\omega_0 t+\phi) * \f] * be the harmonic signal under investigation. * Then * \f[ * f(t)=A\left\{\cos(\omega_0 t)\cos(\phi)- * \sin(\omega_0 t)\sin(\phi)\right\} * \f] * and * \f[ * \tilde{f}(\omega) = * \frac{A}{2}\left\{ * \cos(\phi) * \left[ * \delta(\omega-\omega_0) * + * \delta(\omega+\omega_0) * \right] * +i\sin(\phi) * \left[ * \delta(\omega-\omega_0) * - * \delta(\omega+\omega_0) * \right] * \right\}, * \f] * where \f$\delta(\omega)\f$ is Dirac's delta function with * \f[ * \delta(\omega)=\left\{ * \begin{array}{ll} * \infty & \textrm{if $\omega=0$ and}\\ * 0 & \textrm{otherwise} * \end{array} * \right. * \f] * and * \f[ * \int\limits_{-\infty}^{+\infty} * \delta(\omega)\,\textrm{d}\omega=1 * \f] * such that * \f[ * \tilde{f}(\omega)=\int\limits_{-\infty}^{+\infty} * \tilde{f}(\omega')\,\delta(\omega-\omega')\,\textrm{d}\omega. * \f] * This way I obtain * \f[ * \tilde{g}(\omega)= * \frac{A}{2}\left\{ * e^{i\phi}\tilde{w}(\omega-\omega_0) * + * e^{-i\phi}\tilde{w}(\omega+\omega_0) * \right\} * \f] * for the Fourier transform of the tapered function. * If we ignore interference with side-lobes from the negative frequency * \f$-\omega_0\f$ and side-lobes of potential other harmonics at nearby * frequencies, we can approximate * \f[ * \tilde{g}(\omega_0)\approx\frac{A}{2}e^{i\phi}\tilde{w}(0) * \f] * and * \f[ * \left|\tilde{g}(\omega_0)\right|\approx * \frac{A}{2}\left|\tilde{w}(0)\right|. * \f] * * \subsection subsec_foutra_scaling_harmonics_boxcar Boxcar taper function * * The boxcar taper is defined as * \f[ * w(t) = * \left\{ * \begin{array}{ll} * 1 & \textrm{if $|t|\leq T/2$ and}\\ * 0 & \textrm{otherwise} * \end{array} * \right. * \f] * with * \f[ * \tilde{w}(\omega) * = T \frac{\sin(\omega T/2)}{\omega T/2} * \f] * and * \f[ * w_{\textrm{max}}=w(0)=T. * \f] * * \subsection subsec_foutra_scaling_harmonics_hanning Hanning taper function * * The Hanning taper is defined as * \f[ * w(t) = * \left\{ * \begin{array}{ll} * \cos^2(\pi t / T)) * = \frac{1}{2}\left[ * 1 + \cos(2\pi t / T) * \right] * & \textrm{if $|t|\leq T/2$ and}\\ * 0 & \textrm{otherwise} * \end{array} * \right. * \f] * with * \f[ * \tilde{w}(\omega) * = T/2 \frac{\sin(\omega T/2)}{\omega T/2} * + T/4 \frac{\sin(\omega T/2+\pi)}{\omega T/2+\pi} * + T/4 \frac{\sin(\omega T/2-\pi)}{\omega T/2-\pi} * \f] * (see Blackman, R.B. and Tukey, J.W. 1958. * The measurement of power spectra. * Dover Publications, Inc., New York. * Section B.5) * and * \f[ * w_{\textrm{max}}=w(0)=\frac{T}{2}. * \f] * * \subsection subsec_foutra_scaling_harmonics_tests Instant tests * * In the Makefile you will find a section with test code. * This offers instantaneous testing of harmonic signal scaling in foutra. * \dontinclude Makefile * \skip # test foutra scaling for harmonic signals * \until #---------------------------------------------------------------------- * * \date 10.01.2011 \author thof */ /* ----- END OF foutra.cc ----- */