diff --git a/api/solarperformanceinsight_api/compute.py b/api/solarperformanceinsight_api/compute.py index 204b2421..88224325 100644 --- a/api/solarperformanceinsight_api/compute.py +++ b/api/solarperformanceinsight_api/compute.py @@ -648,7 +648,7 @@ def _calculate_weather_adjusted_predicted_performance( # could make more sense to use weighted mean with weights set # by array power percentage # another alternative, calculate average POArat and TempFactor separately - poa_rat = [_zero_div(pa, pr) for pa, pr in zip(poa_actual, poa_ref)] + poa_rat = list(map(_zero_div, poa_actual, poa_ref)) tempfactor = list(map(_temp_factor, gammas, t_ref, t_actual)) poa_rat_x_temp_factor = adjust( # modelchain outputs are all shifted sum([p * t for p, t in zip(poa_rat, tempfactor)]) / num_arrays @@ -739,9 +739,9 @@ def compare_monthly_predicted_and_actual( "PVsyst specified arrays." ) - avg_gamma = mean( + avg_gamma: float = mean( [ - mean([arr.module_parameters._gamma for arr in inv.arrays]) + mean([arr.module_parameters._gamma for arr in inv.arrays]) # type: ignore for inv in inverters ] ) diff --git a/api/solarperformanceinsight_api/models.py b/api/solarperformanceinsight_api/models.py index 84366f94..0ca55565 100644 --- a/api/solarperformanceinsight_api/models.py +++ b/api/solarperformanceinsight_api/models.py @@ -1013,17 +1013,11 @@ class CalculateWeatherAdjustedPRJobParameters(CompareMixin, JobParametersBase): _performance_types = PrivateAttr((JobDataTypeEnum.actual_performance,)) -def _get_model_chain_method( - irradiance_type: Optional[IrradianceTypeEnum], -) -> Union[str, None]: - if irradiance_type == IrradianceTypeEnum.effective: - return "run_model_from_effective_irradiance" - elif irradiance_type == IrradianceTypeEnum.poa: - return "run_model_from_poa" - elif irradiance_type == IrradianceTypeEnum.standard: - return "run_model" - else: - return None +MODEL_CHAIN_METHOD_MAP = { + IrradianceTypeEnum.effective: "run_model_from_effective_irradiance", + IrradianceTypeEnum.poa: "run_model_from_poa", + IrradianceTypeEnum.standard: "run_model", +} class ActualDataParams(CompareMixin): @@ -1035,7 +1029,7 @@ class ActualDataParams(CompareMixin): def __init__(self, **data): super().__init__(**data) - self._model_chain_method = _get_model_chain_method(self.irradiance_type) + self._model_chain_method = MODEL_CHAIN_METHOD_MAP[self.irradiance_type] class PredictedDataEnum(str, Enum): @@ -1063,7 +1057,7 @@ def __init__(self, **data): ) else: self._performance_types = () - self._model_chain_method = _get_model_chain_method(self.irradiance_type) + self._model_chain_method = MODEL_CHAIN_METHOD_MAP[self.irradiance_type] @root_validator def check_performance_granularity(cls, values): @@ -1185,7 +1179,7 @@ def __init__(self, **data): self._data_items = self.parameters._construct_data_items(self.system_definition) # determine what columns to expect in uploads irradiance_type = getattr(self.parameters, "irradiance_type", None) - self._model_chain_method = _get_model_chain_method(irradiance_type) + self._model_chain_method = MODEL_CHAIN_METHOD_MAP.get(irradiance_type, None) class JobStatusEnum(str, Enum):