Skip to content

Commit 34008ed

Browse files
committed
Change setter for losses_model to allow it to set multiple loss functions, anticipating more complex loss models. Adds self._dc_losses
1 parent 3e25627 commit 34008ed

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pvlib/modelchain.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ class ModelChain:
327327
The ModelChain instance will be passed as the first argument to a
328328
user-defined function.
329329
330-
losses_model: str or function, default 'no_loss'
331-
Valid strings are 'pvwatts', 'no_loss'. The ModelChain instance
332-
will be passed as the first argument to a user-defined function.
330+
losses_model: str, default 'no_loss'
331+
Valid strings are 'pvwatts', 'no_loss'. The loss functions will
332+
be set according to this parameter.
333333
334334
name: None or str, default None
335335
Name of ModelChain instance.
@@ -935,13 +935,15 @@ def losses_model(self, model):
935935
elif isinstance(model, str):
936936
model = model.lower()
937937
if model == 'pvwatts':
938-
self._losses_model = self.pvwatts_losses
938+
self._losses_model = model
939+
self._dc_losses = self.pvwatts_losses
939940
elif model == 'no_loss':
940-
self._losses_model = self.no_extra_losses
941+
self._losses_model = model
942+
self._dc_losses = self.no_extra_losses
941943
else:
942944
raise ValueError(model + ' is not a valid losses model')
943945
else:
944-
self._losses_model = partial(model, self)
946+
raise ValueError('losses_model must be a string')
945947

946948
def infer_losses_model(self):
947949
raise NotImplementedError
@@ -1374,7 +1376,7 @@ def _run_from_effective_irrad(self, data=None):
13741376
"""
13751377
self._prepare_temperature(data)
13761378
self.dc_model()
1377-
self.losses_model()
1379+
self._dc_losses()
13781380
self.ac_model()
13791381

13801382
return self

0 commit comments

Comments
 (0)