environmentaltools.temporal.stationary_analysis

environmentaltools.temporal.stationary_analysis(df: DataFrame, param: dict)[source]

Fit stationary probability distribution models to time series data.

Performs stationary analysis by fitting simple or mixed probability distribution models to time series data. Supports single distributions, piecewise models, and mixed models with multiple distribution functions.

Parameters:
  • df (pd.DataFrame) – Time series data containing the variable to analyze

  • param (dict) –

    Configuration parameters for the analysis including:

    • ’var’str

      Name of the variable column to analyze

    • ’basis_function’dict

      Contains ‘order’ key specifying Fourier expansion order (0 for stationary)

    • ’reduction’bool

      Whether to use reduced parameter space

    • ’no_fun’int

      Number of distribution functions to use

    • ’fun’dict

      Dictionary of scipy.stats distribution objects

    • ’ws_ps’array-like

      Weights or percentiles for mixed/piecewise models

    • ’piecewise’bool

      Whether to fit piecewise distributions

    • ’fix_percentiles’bool

      Whether percentile boundaries are fixed

Returns:

(par0, mode) where:

  • par0list

    Fitted parameters for the distribution(s)

  • modenp.ndarray

    Mode identifiers for the fit (zeros for stationary)

Return type:

tuple

Notes

This function handles three types of fits:

  1. Simple stationary: Single distribution fitted to entire dataset

  2. Mixed models: Multiple distributions weighted by percentiles

  3. Piecewise models: Different distributions for data segments

For mixed and piecewise models, parameters are concatenated in order.

Examples

>>> import pandas as pd
>>> import scipy.stats as st
>>> df = pd.DataFrame({'Hs': [1.2, 2.3, 1.8, 3.1, 2.5]})
>>> param = {
...     'var': 'Hs',
...     'basis_function': {'order': 0},
...     'reduction': False,
...     'no_fun': 1,
...     'fun': {0: st.weibull_min}
... }
>>> params, mode = stationary_analysis(df, param)