stats.spectral.compute_periodogram(
y,
*,
max_peaks=5,
scaling='spectrum',
fs=None,
)
Compute the periodogram of a time series.
Wraps scipy.signal.periodogram with a boxcar window to match the reference implementation.
Parameters
| y |
pd.Series |
Series to analyse. Must be a non-empty pandas Series without missing values (validated via check_y). |
required |
| max_peaks |
int |
Number of top peaks to surface. |
5 |
| scaling |
str |
Spectrum scaling forwarded to scipy. |
'spectrum' |
| fs |
Optional[float] |
Sampling frequency. Defaults to 1.0 (cycles per sample). |
None |
Examples
import numpy as np
import pandas as pd
from spotforecast2_safe.stats.spectral import compute_periodogram
t = np.arange(512)
y = pd.Series(np.sin(2 * np.pi * t / 32))
result = compute_periodogram(y, max_peaks=1)
print(int(round(result.top_periods.index[0])))