Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76c4d84

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

File tree

Expand file treeCollapse file tree

6 files changed

+3
-4
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+3
-4
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1-2Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/mlab.py
+2-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.