Skip to content

Commit

Permalink
map rats, dict chain
Browse files Browse the repository at this point in the history
  • Loading branch information
alorenzo175 committed Mar 12, 2021
1 parent 9ced9f1 commit 03a0642
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions api/solarperformanceinsight_api/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]
)
Expand Down
22 changes: 8 additions & 14 deletions api/solarperformanceinsight_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 03a0642

Please sign in to comment.