plot_periodogram

plot_periodogram(ts: TSDataset, period: float, amplitude_aggregation_mode: Union[str, Literal['per-segment']] = AggregationMode.mean, periodogram_params: Optional[Dict[str, Any]] = None, segments: Optional[List[str]] = None, xticks: Optional[List[Any]] = 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 (Union[str, Literal['per-segment']]) – aggregation strategy for obtained per segment periodograms; all the strategies can be examined at AggregationMode

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

  • segments (Optional[List[str]]) – segments to use

  • xticks (Optional[List[Any]]) – 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.