10000 Changed normalization in _spectral_helper() to obtain conistent scali… · matplotlib/matplotlib@76c4d84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 76c4d84

Browse files
committed
Changed normalization in _spectral_helper() to obtain conistent scaling in magnitude_spectrum() and fixed doc string.
1 parent 7d6b0c8 commit 76c4d84

File tree

6 files changed

+3
-4
lines changed

6 files changed

+3
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6665,8 +6665,7 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None,
66656665
66666666
scale : [ 'default' | 'linear' | 'dB' ]
66676667
The scaling of the values in the *spec*. 'linear' is no scaling.
6668-
'dB' returns the values in dB scale. When *mode* is 'density',
6669-
this is dB power (10 * log10). Otherwise this is dB amplitude
6668+
'dB' returns the values in dB scale, i.e., the dB amplitude
66706669
(20 * log10). 'default' is 'linear'.
66716670
66726671
Fc : integer

lib/matplotlib/mlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,12 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None,
727727
elif mode == 'psd':
728728
result = np.conj(result) * result
729729
elif mode == 'magnitude':
730-
result = np.abs(result)
730+
result = np.abs(result) / np.abs(windowVals).sum()
731731
elif mode == 'angle' or mode == 'phase':
732732
# we unwrap the phase later to handle the onesided vs. twosided case
733733
result = np.angle(result)
734734
elif mode == 'complex':
735-
pass
735+
result /= np.abs(windowVals).sum()
736736

737737
if mode == 'psd':
738738

Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)
0