@@ -1805,31 +1805,37 @@ def test_psd_windowarray(self):
18051805
18061806 def test_psd_windowarray_scale_by_freq (self ):
18071807 freqs = self .freqs_density
1808+ win = mlab .window_hanning (np .ones (self .NFFT_density_real ))
1809+
18081810 spec , fsp = mlab .psd (x = self .y ,
18091811 NFFT = self .NFFT_density ,
18101812 Fs = self .Fs ,
18111813 noverlap = self .nover_density ,
18121814 pad_to = self .pad_to_density ,
1813- sides = self .sides )
1815+ sides = self .sides ,
1816+ window = mlab .window_hanning )
18141817 spec_s , fsp_s = mlab .psd (x = self .y ,
18151818 NFFT = self .NFFT_density ,
18161819 Fs = self .Fs ,
18171820 noverlap = self .nover_density ,
18181821 pad_to = self .pad_to_density ,
18191822 sides = self .sides ,
1823+ window = mlab .window_hanning ,
18201824 scale_by_freq = True )
18211825 spec_n , fsp_n = mlab .psd (x = self .y ,
18221826 NFFT = self .NFFT_density ,
18231827 Fs = self .Fs ,
18241828 noverlap = self .nover_density ,
18251829 pad_to = self .pad_to_density ,
18261830 sides = self .sides ,
1831+ window = mlab .window_hanning ,
18271832 scale_by_freq = False )
1828-
18291833 assert_array_equal (fsp , fsp_s )
18301834 assert_array_equal (fsp , fsp_n )
18311835 assert_array_equal (spec , spec_s )
1832- assert_allclose (spec_s , spec_n / self .Fs , atol = 1e-08 )
1836+ assert_allclose (spec_s * (win ** 2 ).sum (),
1837+ spec_n / self .Fs * win .sum ()** 2 ,
1838+ atol = 1e-08 )
18331839
18341840 def test_complex_spectrum (self ):
18351841 freqs = self .freqs_spectrum
0 commit comments