CVXPY Signal Decompositions#
Signal Decompositions Module for CVXPY
This module contains standardized signal decomposition models for use in the SDT algorithms using CVXPY and the MOSEK solver. The defined signal decompositions are:
_cvx_l2_l1d1_l2d2p365: Separating a piecewise constant component from a smooth and seasonal component, with Gaussian noise - l2: Gaussian noise, sum-of-squares small or l2-norm squared - l1d1: Piecewise constant heuristic, l1-norm of first-order differences - l2d2p365: Small second-order differences (smooth) and 365-periodic
_cvx_tl1_l2d2p365: Similar to (2), estimating a smooth, seasonal component with an asymmetric Laplacian noise model, fitting a local quantile instead of a local average - tl1: ‘Tilted l1-norm,’ also known as quantile cost function - l2d2p365: Small second-order differences (smooth) and 365-periodic
_cvx_l1_l1d1_l2d2p365: Like (1) but with an asymmetric residual cost instead of Gaussian residuals - l1: l1-norm - l1d1: Piecewise constant heuristic, l1-norm of first-order differences - l2d2p365: Small second-order differences (smooth) and 365-periodic
_cvx_l2_l1d2_constrained: - l2: Gaussian noise, sum-of-squares small or l2-norm squared - l1d2: Piecewise linear heuristic - Constrained to have first value at 0 and last value at 1
- solardatatools._cvx_signal_decompositions._cvx_l1_l1d1_l2d2p365(signal, use_ixs=None, w0=3, w1=18, w2=6000, w3=300, return_all=False, solver='MOSEK', verbose=False)#
Used in solardatatools/algorithms/capacity_change.py
- Parameters:
signal – A 1d numpy array (must support boolean indexing) containing the signal of interest
use_ixs – List of booleans indicating indices to use in signal. None is default (uses the entire signal).
w0 – Weight on the residual component
w1 – The regularization parameter to control the total variation in the final output signal
w2 – The regularization parameter to control the smoothness of the seasonal signal
return_all – Returns all components and the objective value. Used for tests.
solver – Solver to use for the decomposition
verbose – Sets verbosity
- Returns:
A tuple with three 1d numpy arrays containing the three signal component estimates
- solardatatools._cvx_signal_decompositions._cvx_l2_l1d1_l2d2p365(signal, use_ixs=None, w0=10, w1=50, w2=100000.0, yearly_periodic=False, return_all=False, solver='MOSEK', transition_locs=None, verbose=False)#
Used in: solardatatools/algorithms/time_shifts.py
This performs total variation filtering with the addition of a seasonal baseline fit. This introduces a new signal to the model that is smooth and periodic on a yearly time frame. This does a better job of describing real, multi-year solar PV power data sets, and therefore does an improved job of estimating the discretely changing signal.
- Parameters:
signal (array_like) – A 1d numpy array (must support boolean indexing) containing the signal of interest.
w0 (float) – Weight on the residual component.
w1 (float) – The regularization parameter to control the total variation in the final output signal.
w2 (float) – The regularization parameter to control the smoothness of the seasonal signal.
yearly_periodic (bool, optional) – Adds periodicity constraint to signal decomposition.
return_all (bool, optional) – Returns all components and the objective value. Used for tests.
solver (str, optional) – Solver to use for the decomposition.
transition_locs (list of int, optional) – List of indices where transitions are located.
verbose (bool, optional) – Sets verbosity.
- Returns:
A tuple with two 1d numpy arrays containing the two signal component estimates.
- Return type:
tuple of array_like
- solardatatools._cvx_signal_decompositions._cvx_l2_l1d2_constrained(signal, w1=10.0, return_all=False, solver='MOSEK', verbose=False)#
Used in solardatatools/algorithms/clipping.py
This is a convex problem and the default solver across SDT is OSQP.
- Parameters:
signal – A 1d numpy array (must support boolean indexing) containing the signal of interest
w0 – Weight on the residual component
w1 – The regularization parameter on l1d2 component
return_all – Returns all components and the objective value. Used for tests.
solver – Solver to use for the decomposition
verbose – Sets verbosity
- Returns:
A tuple with returning the signal, the l1d2 component estimate, and the weight
- solardatatools._cvx_signal_decompositions._cvx_tl1_l2d2p365(signal, use_ixs=None, tau=0.75, w0=1, w1=500, yearly_periodic=True, return_all=False, solver='MOSEK', verbose=False)#
- Used in:
solardatatools/algorithms/sunrise_sunset_estimation.py solardatatools/clear_day_detection.py solardatatools/data_quality.py solardatatools/sunrise_sunset.py
- Parameters:
signal – A 1d numpy array (must support boolean indexing) containing the signal of interest
use_ixs – List of booleans indicating indices to use in signal. None is default (uses the entire signal).
tau – Quantile regression parameter,between zero and one, and it sets the approximate quantile of the residual distribution that the model is fit to See: https://colab.research.google.com/github/cvxgrp/cvx_short_course/blob/master/applications/quantile_regression.ipynb
w0 – Weight on the residual component
w1 – The regularization parameter to control the smoothness of the seasonal signal
yearly_periodic – Adds periodicity constraint to signal decomposition
return_all – Returns all components and the objective value. Used for tests.
solver – Solver to use for the decomposition
verbose – Sets verbosity
- Returns:
A tuple with three 1d numpy arrays containing the three signal component estimates