etna.analysis.plot_periodogram#

plot_periodogram(ts: TSDataset, period: float, amplitude_aggregation_mode: str | Literal['per-segment'] = AggregationMode.mean, periodogram_params: Dict[str, Any] | None = None, segments: List[str] | None = None, xticks: List[Any] | None = None, columns_num: int = 2, figsize: Tuple[int, int] = (10, 5))[source]#

Plot the periodogram using scipy.signal.periodogram().

It is useful to determine the optimal order parameter for FourierTransform.

Parameters:
  • ts (TSDataset) – TSDataset with timeseries data

  • period (float) – the period of the seasonality to capture in frequency units of time series, it should be >= 2; it is translated to the fs parameter of scipy.signal.periodogram()

  • amplitude_aggregation_mode (str | Literal['per-segment']) – aggregation strategy for obtained per segment periodograms; all the strategies can be examined at AggregationMode

  • periodogram_params (Dict[str, Any] | None) – additional keyword arguments for periodogram, scipy.signal.periodogram() is used

  • segments (List[str] | None) – segments to use

  • xticks (List[Any] | None) – list of tick locations of the x-axis, useful to highlight specific reference periodicities

  • columns_num (int) – if amplitude_aggregation_mode="per-segment" number of columns in subplots, otherwise the value is ignored

  • figsize (Tuple[int, int]) – size of the figure per subplot with one segment in inches

Raises:
  • ValueError: – if period < 2

  • ValueError: – if periodogram can’t be calculated on segment because of the NaNs inside it

Notes

In non per-segment mode all segments are cut to be the same length, the last values are taken.