Algorithms#

class solardatatools.algorithms.CapacityChange#

Bases: object

optimize_weight(metric, filter, weights, solver=None)#
plot_weight_optimization(figsize=(10, 5))#

A function for plotting plotting the three weight selection criteria

Parameters:

figsize – a 2-tuple of the figure size to plot

Returns:

matplotlib figure

run(data, metric=None, weight=None, filter=None, quantile=1.0, solver=None)#
solve_sd(metric, filter, weight, w3=1, w4=10.0, solver=None, verbose=False)#
class solardatatools.algorithms.ClearSkyDetection(sig, quantile_estimate, threshold_low=0.75, threshold_high=1.2, stickiness_low=4, stickiness_high=0.1)#

Bases: object

compute_hinge_losses(values, q98_row)#
find_optimal_path(L)#
get_clearsky_sig()#
hinge0(val, q98)#
hinge1(val, q98)#
run()#
class solardatatools.algorithms.ClippingDetection#

Bases: object

calculate_cdf(data)#
check_clipping(data_matrix, no_error_flag=None, threshold=-0.35, solver=None, verbose=False, weight=5)#
find_clipped_times()#
get_l2_l1d2(y, weight=5, solver=None)#
plot_both(figsize=(8, 6))#
plot_cdf(figsize=(8, 6))#
plot_diffs(figsize=(8, 6))#
plot_pdf(figsize=(8, 6))#
pointmass_detection(data, threshold=-0.35, solver=None, verbose=False, weight=5)#
class solardatatools.algorithms.Dilation(data_handler, nvals_dil=101, matrix='raw')#

Bases: object

plot_heatmap(space='original', figsize=(12, 6), scale_to_kw=True, year_lines=True, units=None)#
run()#
class solardatatools.algorithms.LossFactorAnalysis(energy_data, capacity_change_labels=None, outage_flags=None, **kwargs)#

Bases: object

estimate_degradation_rate(max_samples=500, median_tol=0.005, confidence_tol=0.01, fraction_hold=0.2, method='median_unbiased', verbose=False)#

This function runs a Monte Carlo simulation to estimate the uncertainty in the estimation of the degrdation rate based on the loss model. This will randomly sample problem parameters (quantile level and soiling stiffness weight), while randomly holding out 20% of the days each time. The algorithm exits when the estimates of the median, 2.5 percentile, and 97.5 percentile have stabilized. Results are stored in the following class .. attribute:: self.degradation_rate

self.degradation_rate_lb#
self.degradation_rate_ub#
self.MC_results#
Parameters:
  • max_samples – maximimum number of MC samples to generate (typically exits before this)

  • median_tol – tolerance for median estimate stability

  • confidence_tol – tolerance for outer percentile estimate stability

  • fraction_hold – fraction of values to holdout in each sample

  • method – quantile estimation method (see: https://numpy.org/doc/stable/reference/generated/numpy.quantile.html)

  • verbose – control print statements

Returns:

None

estimate_losses(solver='CLARABEL', verbose=False)#
holdout_validate(seed=None, solver='CLARABEL')#
make_problem(tau=0.9, num_harmonics=4, deg_type='linear', include_soiling=True, weight_seasonal=0.1, weight_soiling_stiffness=0.5, weight_soiling_sparsity=0.01, weight_deg_nonlinear=100000.0, deg_rate=None, use_capacity_change_labels=True)#

Constuct the signal decomposition problem for estimation of loss factors in PV energy data.

Parameters:
  • tau (float) – the quantile level to fit

  • num_harmonics (int) – the number of harmonics to include in model for yearly periodicity

  • deg_type (str) – the type of degradation to model (“linear”, “nonlinear”, or “none”)

  • include_soiling (bool) – whether to include a soiling term

  • weight_seasonal (float) – the weight on the seasonal penalty term (higher is stiffer)

  • weight_soiling_stiffness (float) – the weight on the soiling stiffness (higher is stiffer)

  • weight_soiling_sparsity (float) – the weight on the soiling stiffness (higher is sparser)

  • weight_deg_nonlinear (float) – only used if ‘nonlinear’ degradation model is selected

  • deg_rate (None or float [%/yr]) – pass to set a known degradation rate rather than have the SD problem estimate it

Returns:

a gfosd.Problem instance

plot_decomposition(plot_capacity_component=True, figsize=(16, 8.5))#

Creates a figure with subplots illustrating the estimated signal components found through decomposition

Parameters:

figsize – size of figure (tuple)

Returns:

matplotlib figure

plot_mc_by_tau(figsize=None, title=None)#

Creates a scatterplot of the Monte Carlo samples versus tau (quantile level) and colors the points by the weight of the soiling stiffness term

Parameters:
  • figsize – size of figure (tuple)

  • title – title for figure (string)

Returns:

matplotlib figure

plot_mc_by_weight(figsize=None, title=None)#

Creates a scatterplot of the Monte Carlo samples versus weight (soiling stiffness) and colors the points by the tau (quantile level)

Parameters:
  • figsize – size of figure (tuple)

  • title – title for figure (string)

Returns:

matplotlib figure

plot_mc_histogram(figsize=None, title=None)#

Creates a historgram of the Monte Carlo samples and annotates the chart with mean, median, mode, and confidence intervals.

Parameters:
  • figsize – size of figure (tuple)

  • title – title for figure (string)

Returns:

matplotlib figure

plot_pie(figsize=None)#

Create a pie plot of losses

Returns:

matplotlib figure

plot_waterfall(plot_capacity_component=True, figsize=(10, 4))#

Create a waterfall plot of losses

Returns:

matplotlib figure

report()#

Creates a machine-readable dictionary of result from the loss factor analysis :return: dictionary

class solardatatools.algorithms.PVQuantiles(data_handler, nvals_dil=101, num_harmonics=[10, 3], regularization=0.1, solver='CLARABEL', verbose=False)#

Bases: object

estimate_quantiles(quantile_levels=[0.02, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.98])#
plot_all_quantiles(dilated=True)#
plot_quantile_bundt(quantile)#
class solardatatools.algorithms.ShadeAnalysis(data_handler, matrix=None)#

Bases: object

analyze_yearly_energy()#
property has_run#
make_osd_problem(w1=20, w2=1.0, w3=500.0, w4=0.3, mu=None, lambd=None, q_mat=None)#
plot_annotated_heatmap(t=0.25, figsize=(12, 6))#
plot_annotated_polar(lat, lon, tz_offset, elevation_round=1, azimuth_round=2, t=0.25, figsize=(10, 6))#
plot_component(component, figsize=(10, 4), ax=None, cmap='plasma')#
plot_transformed_data(yticks=True, figsize=(10, 4), cmap='plasma', interpolation='none', aspect='auto')#
plot_yearly_energy_analysis(figsize=None)#
run(power=8, solver='MOSEK', w1=20, w2=1.0, w3=500.0, w4=0.3, verbose=False, mu=None, lambd=None, q_mat=None)#
transform_data(power=8)#
class solardatatools.algorithms.SoilingAnalysis(data_handler)#

Bases: object

plot_analysis(figsize=None)#
run(**config)#
class solardatatools.algorithms.SunriseSunset#

Bases: object

calculate_errors()#
calculate_times(data, threshold=None, plot=False, figsize=(12, 10), zoom_fit=False, solver='OSQP')#
calculate_true(dh, lat, lon, tz_offset)#
run_optimizer(data, random_seed=None, search_pts=21, plot=False, figsize=(8, 6), solver='OSQP')#
class solardatatools.algorithms.TimeShift#

Bases: object

apply_corrections(data)#
estimate_components(metric, w1, w2, use_ixs, periodic_detector, solver=None, sum_card=False, transition_locs=None)#
invert_corrections(data)#
optimize_w1(metric, w1s, use_ixs, w2, periodic_detector, solver=None, sum_card=False)#
plot_analysis(figsize=None)#
plot_optimization(figsize=(8, 8))#
run(data, use_ixs=None, w1=None, w2=0.001, solar_noon_estimator='com', threshold=0.005, periodic_detector=False, solver=None, sum_card=False, round_shifts_to_hour=True)#
solardatatools.algorithms.soiling_seperation(observed, index_set=None, degradation_term=True, tau=0.85, w1=2, w2=0.03, w3=0.2, w4=500.0, iterations=5, solver=None, period=365, verbose=False)#

Apply signal decomposition framework to Performance Index soiling estimation problem. The PI signal is a daily performance index, typically daily energy normalized by modeled or expected energy. PI signal assumed to contain components corresponding to

  1. a soiling loss trend (sparse 1st-order differences)

  2. a seasonal term (smooth, yearly periodic)

  3. linear degradation

  4. residual

Parameters:
  • observed

  • index_set

  • degradation_term

  • tau

  • w1 – PWL weight - soiling term

  • w2 – sparseness weight - soiling term

  • w3 – asymmetric slopes - soiling term

  • w4 – smoothness weight - seasonal term

  • iterations

solardatatools.algorithms.soiling_seperation_old(observed, index_set=None, degradation_term=False, period=365, tau=0.85, w1=2, w2=0.01, w3=100, iterations=5, soiling_max=1.0, solver='MOSEK')#

Apply signal decomposition framework to Performance Index soiling estimation problem. The PI signal is a daily performance index, typically daily energy normalized by modeled or expected energy. PI signal assumed to contain components corresponding to

  1. a soiling loss trend (sparse 1st-order differences)

  2. a seasonal term (smooth, yearly periodic)

  3. linear degradation

  4. residual

Parameters:
  • observed

  • index_set

  • degradation_term

  • tau

  • w1 – PWL weight - soiling term

  • w2 – sparseness weight - soiling term

  • w3 – smoothness weight - seasonal term

  • iterations

Submodules#