r""" Compute 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*. *noverlap* gives
(x, NFFT=None, Fs=None, detrend=None, window=None,
noverlap=None, pad_to=None, sides=None, scale_by_freq=None)
| 478 | |
| 479 | @_docstring.interpd |
| 480 | def psd(x, NFFT=None, Fs=None, detrend=None, window=None, |
| 481 | noverlap=None, pad_to=None, sides=None, scale_by_freq=None): |
| 482 | r""" |
| 483 | Compute the power spectral density. |
| 484 | |
| 485 | The power spectral density :math:`P_{xx}` by Welch's average |
| 486 | periodogram method. The vector *x* is divided into *NFFT* length |
| 487 | segments. Each segment is detrended by function *detrend* and |
| 488 | windowed by function *window*. *noverlap* gives the length of |
| 489 | the overlap between segments. The :math:`|\mathrm{fft}(i)|^2` |
| 490 | of each segment :math:`i` are averaged to compute :math:`P_{xx}`. |
| 491 | |
| 492 | If len(*x*) < *NFFT*, it will be zero padded to *NFFT*. |
| 493 | |
| 494 | Parameters |
| 495 | ---------- |
| 496 | x : 1-D array or sequence |
| 497 | Array or sequence containing the data |
| 498 | |
| 499 | %(Spectral)s |
| 500 | |
| 501 | %(PSD)s |
| 502 | |
| 503 | noverlap : int, default: 0 (no overlap) |
| 504 | The number of points of overlap between segments. |
| 505 | |
| 506 | Returns |
| 507 | ------- |
| 508 | Pxx : 1-D array |
| 509 | The values for the power spectrum :math:`P_{xx}` (real valued) |
| 510 | |
| 511 | freqs : 1-D array |
| 512 | The frequencies corresponding to the elements in *Pxx* |
| 513 | |
| 514 | References |
| 515 | ---------- |
| 516 | Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John |
| 517 | Wiley & Sons (1986) |
| 518 | |
| 519 | See Also |
| 520 | -------- |
| 521 | specgram |
| 522 | `specgram` differs in the default overlap; in not returning the mean of |
| 523 | the segment periodograms; and in returning the times of the segments. |
| 524 | |
| 525 | magnitude_spectrum : returns the magnitude spectrum. |
| 526 | |
| 527 | csd : returns the spectral density between two signals. |
| 528 | """ |
| 529 | Pxx, freqs = csd(x=x, y=None, NFFT=NFFT, Fs=Fs, detrend=detrend, |
| 530 | window=window, noverlap=noverlap, pad_to=pad_to, |
| 531 | sides=sides, scale_by_freq=scale_by_freq) |
| 532 | return Pxx.real, freqs |
| 533 | |
| 534 | |
| 535 | @_docstring.interpd |