MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / psd

Method psd

lib/matplotlib/axes/_axes.py:8006–8113  ·  view source on GitHub ↗

r""" Plot the power spectral density. The power spectral density :math:`P_{xx}` by Welch's average periodogram method. The vector *x* is divided into *NFFT* length segments. Each segment is detrended by function *detrend* and windowed by function *window*.

(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
            window=None, noverlap=None, pad_to=None,
            sides=None, scale_by_freq=None, return_line=None, **kwargs)

Source from the content-addressed store, hash-verified

8004 @_preprocess_data(replace_names=["x"])
8005 @_docstring.interpd
8006 def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
8007 window=None, noverlap=None, pad_to=None,
8008 sides=None, scale_by_freq=None, return_line=None, **kwargs):
8009 r"""
8010 Plot the power spectral density.
8011
8012 The power spectral density :math:`P_{xx}` by Welch's average
8013 periodogram method. The vector *x* is divided into *NFFT* length
8014 segments. Each segment is detrended by function *detrend* and
8015 windowed by function *window*. *noverlap* gives the length of
8016 the overlap between segments. The :math:`|\mathrm{fft}(i)|^2`
8017 of each segment :math:`i` are averaged to compute :math:`P_{xx}`,
8018 with a scaling to correct for power loss due to windowing.
8019
8020 If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.
8021
8022 Parameters
8023 ----------
8024 x : 1-D array or sequence
8025 Array or sequence containing the data
8026
8027 %(Spectral)s
8028
8029 %(PSD)s
8030
8031 noverlap : int, default: 0 (no overlap)
8032 The number of points of overlap between segments.
8033
8034 Fc : int, default: 0
8035 The center frequency of *x*, which offsets the x extents of the
8036 plot to reflect the frequency range used when a signal is acquired
8037 and then filtered and downsampled to baseband.
8038
8039 return_line : bool, default: False
8040 Whether to include the line object plotted in the returned values.
8041
8042 Returns
8043 -------
8044 Pxx : 1-D array
8045 The values for the power spectrum :math:`P_{xx}` before scaling
8046 (real valued).
8047
8048 freqs : 1-D array
8049 The frequencies corresponding to the elements in *Pxx*.
8050
8051 line : `~matplotlib.lines.Line2D`
8052 The line created by this function.
8053 Only returned if *return_line* is True.
8054
8055 Other Parameters
8056 ----------------
8057 data : indexable object, optional
8058 DATA_PARAMETER_PLACEHOLDER
8059
8060 **kwargs
8061 Keyword arguments control the `.Line2D` properties:
8062
8063 %(Line2D:kwdoc)s

Callers 15

psdFunction · 0.80
test_psdMethod · 0.80
test_psd_detrendMethod · 0.80
test_psd_windowarrayMethod · 0.80
test_psd_csd_equalMethod · 0.80
test_psd_onesided_normFunction · 0.80
test_psd_oversamplingFunction · 0.80

Calls 6

plotMethod · 0.95
gridMethod · 0.95
set_xlabelMethod · 0.80
set_ylabelMethod · 0.80
get_yboundMethod · 0.80
set_yticksMethod · 0.80

Tested by 13

test_psdMethod · 0.64
test_psd_detrendMethod · 0.64
test_psd_windowarrayMethod · 0.64
test_psd_csd_equalMethod · 0.64
test_psd_onesided_normFunction · 0.64
test_psd_oversamplingFunction · 0.64
test_psd_csdFunction · 0.64