pownet.stochastic package

Submodules

pownet.stochastic.demand module

demand.py: Model for solar time series data

class pownet.stochastic.demand.DemandTSModel[source]

Bases: TimeSeriesModel

property monthly_models: dict
property pred_residuals: pandas.Series
property predictions: pandas.Series

pownet.stochastic.kirsch_nowak module

kirsch_nowak.py

pownet.stochastic.kirsch_nowak.KNN_identification(Z, Qtotals, month, k=None)[source]

Identifies K-nearest neighbors of Z in the historical annual data and computes the associated weights W.

Parameters:
  • Z – Synthetic datum (scalar)

  • Qtotals – Total monthly flows at all sites for all historical months within +/- 7 days of the month being disaggregated

  • month – Month being disaggregated

  • k – Number of nearest neighbors (by default k=n_year^0.5 according to Lall and Sharma (1996))

Returns:

Indices of the first K-nearest neighbors of Z in the

historical annual data z

W: Nearest neighbors weights, according to Lall and Sharma (1996):

W(i) = (1/i) / (sum(1/i))

Return type:

KNN_id

pownet.stochastic.kirsch_nowak.chol_corr(Z)[source]

Computes the Cholesky decomposition of the correlation matrix of the columns of Z. Attempts to repair non-positive-definite matrices.

pownet.stochastic.solar module

solar.py: Model for solar time series data

class pownet.stochastic.solar.SolarTSModel[source]

Bases: TimeSeriesModel

property monthly_models: dict
property pred_residuals: pandas.Series
property predictions: pandas.Series
pownet.stochastic.solar.process_solar_series(solar_ts, suntimes)[source]
Return type:

Series

pownet.stochastic.timeseries_model module

timeseries_model.py: Abstract class for time series models.

class pownet.stochastic.timeseries_model.TimeSeriesModel[source]

Bases: ABC

find_best_model(target_column, exog_vars=None, month_to_use=1, seed=None, suppress_warnings=False)[source]

Find the best model for the time series data

Parameters:
  • target_column (str) – Target column to fit the model

  • exog_vars (list[str], optional) – List of exogenous variables. Defaults to None.

  • month_to_use (int, optional) – Month to use for finding the best model. Defaults to 1.

  • seed (int, optional) – Random seed. Defaults to 112.

  • suppress_warnings (bool, optional) – Suppress warnings. Defaults to False.

Returns:

Best model SARIMA parameters

Return type:

tuple[tuple[int, int, int], tuple[int, int, int, int]]

Raises:

ValueError – If data is not loaded

fit(target_column, arima_order, seasonal_order=None, exog_vars=None)[source]

Fit the model to the data

Parameters:
  • target_column (str) – Target column to fit the model

  • arima_order (tuple[int, int, int]) – ARIMA order

  • seasonal_order (tuple[int, int, int, int]) – Seasonal order

  • exog_vars (list[str], optional) – List of exogenous variables. Defaults to None.

Return type:

None

get_synthetic(exog_data=None, seed=None)[source]

Create synthetic time series.

Parameters:
  • exog_data (pd.DataFrame, optional) – Exogenous variables. Defaults to None.

  • seed (int, optional) – Random seed. Defaults to None.

Returns:

Synthetic time series data.

Return type:

pd.Series

Raises:
  • ValueError – If the model is not fitted.

  • ValueError – If exogenous variables are not in the data.

  • ValueError – If exogenous data index is not equal to the time series data index.

load_data(data)[source]

Load the time series data

Return type:

None

abstract property monthly_models: dict
plot_residuals(bins, figure_file=None)[source]
Return type:

None

abstract property pred_residuals: pandas.Series
predict()[source]

Return the predictions

Return type:

Series

abstract property predictions: pandas.Series

pownet.stochastic.timeseries_utils module

timeseries_utils.py: Utility functions for timeseries data

pownet.stochastic.timeseries_utils.inverse_log1p(y_pred, B1_y)[source]
Return type:

Series

pownet.stochastic.timeseries_utils.inverse_yeojohnson(y_pred, B1_y, initial_value, power_transformer)[source]

Invert the Yeo-Johnson transformation

Return type:

Series

pownet.stochastic.timeseries_utils.post_process_solar(solar_data, value_cols, sunrise_time, sunset_time)[source]
pownet.stochastic.timeseries_utils.transform_log1p(y, B1_y)[source]
pownet.stochastic.timeseries_utils.transform_yeojohnson(y, B1_y)[source]

Differencing the data and apply the Yeo-Johnson transformation to the data

Return type:

tuple[Series, PowerTransformer]

Module contents

stochastic module.