Skip to content

Commit

Permalink
graceful handling if pipeline is not run
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeyers committed Mar 15, 2024
1 parent e8d5afc commit dd17e62
Showing 1 changed file with 60 additions and 57 deletions.
117 changes: 60 additions & 57 deletions solardatatools/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,63 +659,66 @@ def run_loss_factor_analysis(
:return:
"""
self.loss_analysis = LossFactorAnalysis(
self.daily_signals.energy,
capacity_change_labels=self.capacity_analysis.labels,
outage_flags=~self.daily_flags.no_errors,
tau=tau,
num_harmonics=num_harmonics,
deg_type=deg_type,
include_soiling=include_soiling,
weight_seasonal=weight_seasonal,
weight_soiling_stiffness=weight_soiling_stiffness,
weight_soiling_sparsity=weight_soiling_sparsity,
weight_deg_nonlinear=weight_deg_nonlinear,
deg_rate=deg_rate,
)
if deg_rate is None:
self.loss_analysis.estimate_degradation_rate(verbose=verbose)
elif verbose:
print("Loading user-provided degradation rate.")
if verbose:
print("Performing loss factor analysis...")
self.loss_analysis.estimate_losses()
if verbose:
lb = self.loss_analysis.degradation_rate_lb
ub = self.loss_analysis.degradation_rate_ub
if lb is not None and ub is not None:
print(
f"""
***************************************
* Solar Data Tools Loss Factor Report *
***************************************
degradation rate [%/yr]: {self.loss_analysis.degradation_rate:>6.3f}
deg. rate 95% confidence: [{lb:>6.3f}, {ub:>6.3f}]
total energy loss [kWh]: {self.loss_analysis.total_energy_loss:>13.1f}
bulk deg. energy loss (gain) [kWh]: {self.loss_analysis.degradation_energy_loss:>13.1f}
soiling energy loss [kWh]: {self.loss_analysis.soiling_energy_loss:>13.1f}
capacity change energy loss [kWh]: {self.loss_analysis.capacity_change_loss:>13.1f}
weather energy loss [kWh]: {self.loss_analysis.weather_energy_loss:>13.1f}
system outage loss [kWh]: {self.loss_analysis.outage_energy_loss:>13.1f}
"""
)
else:
print(
f"""
***************************************
* Solar Data Tools Loss Factor Report *
***************************************
degradation rate [%/yr]: {self.loss_analysis.degradation_rate:.3f}
total energy loss [kWh]: {self.loss_analysis.total_energy_loss:>13.1f}
bulk deg. energy loss (gain) [kWh]: {self.loss_analysis.degradation_energy_loss:>13.1f}
soiling energy loss [kWh]: {self.loss_analysis.soiling_energy_loss:>13.1f}
capacity change energy loss [kWh]: {self.loss_analysis.capacity_change_loss:>13.1f}
weather energy loss [kWh]: {self.loss_analysis.weather_energy_loss:>13.1f}
system outage loss [kWh]: {self.loss_analysis.outage_energy_loss:>13.1f}
"""
)
if self._ran_pipeline:
self.loss_analysis = LossFactorAnalysis(
self.daily_signals.energy,
capacity_change_labels=self.capacity_analysis.labels,
outage_flags=~self.daily_flags.no_errors,
tau=tau,
num_harmonics=num_harmonics,
deg_type=deg_type,
include_soiling=include_soiling,
weight_seasonal=weight_seasonal,
weight_soiling_stiffness=weight_soiling_stiffness,
weight_soiling_sparsity=weight_soiling_sparsity,
weight_deg_nonlinear=weight_deg_nonlinear,
deg_rate=deg_rate,
)
if deg_rate is None:
self.loss_analysis.estimate_degradation_rate(verbose=verbose)
elif verbose:
print("Loading user-provided degradation rate.")
if verbose:
print("Performing loss factor analysis...")
self.loss_analysis.estimate_losses()
if verbose:
lb = self.loss_analysis.degradation_rate_lb
ub = self.loss_analysis.degradation_rate_ub
if lb is not None and ub is not None:
print(
f"""
***************************************
* Solar Data Tools Loss Factor Report *
***************************************
degradation rate [%/yr]: {self.loss_analysis.degradation_rate:>6.3f}
deg. rate 95% confidence: [{lb:>6.3f}, {ub:>6.3f}]
total energy loss [kWh]: {self.loss_analysis.total_energy_loss:>13.1f}
bulk deg. energy loss (gain) [kWh]: {self.loss_analysis.degradation_energy_loss:>13.1f}
soiling energy loss [kWh]: {self.loss_analysis.soiling_energy_loss:>13.1f}
capacity change energy loss [kWh]: {self.loss_analysis.capacity_change_loss:>13.1f}
weather energy loss [kWh]: {self.loss_analysis.weather_energy_loss:>13.1f}
system outage loss [kWh]: {self.loss_analysis.outage_energy_loss:>13.1f}
"""
)
else:
print(
f"""
***************************************
* Solar Data Tools Loss Factor Report *
***************************************
degradation rate [%/yr]: {self.loss_analysis.degradation_rate:.3f}
total energy loss [kWh]: {self.loss_analysis.total_energy_loss:>13.1f}
bulk deg. energy loss (gain) [kWh]: {self.loss_analysis.degradation_energy_loss:>13.1f}
soiling energy loss [kWh]: {self.loss_analysis.soiling_energy_loss:>13.1f}
capacity change energy loss [kWh]: {self.loss_analysis.capacity_change_loss:>13.1f}
weather energy loss [kWh]: {self.loss_analysis.weather_energy_loss:>13.1f}
system outage loss [kWh]: {self.loss_analysis.outage_energy_loss:>13.1f}
"""
)
else:
print("Please run pipeline first.")

def fit_statistical_clear_sky_model(
self,
Expand Down

0 comments on commit dd17e62

Please sign in to comment.