2929
3030# Optional keys to communicate temperature data. If provided,
3131# 'cell_temperature' overrides ModelChain.temperature_model and sets
32- # ModelChain.cell_temperature to the data. If 'module_temperature' is provdied ,
32+ # ModelChain.cell_temperature to the data. If 'module_temperature' is provided ,
3333# overrides ModelChain.temperature_model with
3434# pvlib.temperature.sapm_celL_from_module
3535TEMPERATURE_KEYS = ('module_temperature' , 'cell_temperature' )
@@ -253,7 +253,7 @@ def __repr__(self):
253253 def _head (obj ):
254254 try :
255255 return obj [:3 ]
256- except :
256+ except Exception :
257257 return obj
258258
259259 if type (self .dc ) is tuple :
@@ -269,7 +269,7 @@ def _head(obj):
269269 '\n ' )
270270 lines = []
271271 for attr in mc_attrs :
272- if not (attr .startswith ('_' ) or attr == 'times' ):
272+ if not (attr .startswith ('_' ) or attr == 'times' ):
273273 lines .append (f' { attr } : ' + _mcr_repr (getattr (self , attr )))
274274 desc4 = '\n ' .join (lines )
275275 return (desc1 + desc2 + desc3 + desc4 )
@@ -330,12 +330,15 @@ class ModelChain:
330330 'interp' and 'no_loss'. The ModelChain instance will be passed as the
331331 first argument to a user-defined function.
332332
333- spectral_model : str, or function, optional
334- If not specified, the model will be inferred from the parameters that
335- are common to all of system.arrays[i].module_parameters.
336- Valid strings are 'sapm', 'first_solar', 'no_loss'.
333+ spectral_model : str or function, optional
334+ Valid strings are:
335+
336+ - ``'sapm'``
337+ - ``'first_solar'``
338+ - ``'no_loss'``
339+
337340 The ModelChain instance will be passed as the first argument to
338- a user-defined function.
341+ a user-defined function. If not specified, ``'no_loss'`` is assumed.
339342
340343 temperature_model : str or function, optional
341344 Valid strings are: 'sapm', 'pvsyst', 'faiman', 'fuentes', 'noct_sam'.
@@ -386,7 +389,6 @@ def __init__(self, system, location,
386389
387390 self .results = ModelChainResult ()
388391
389-
390392 @classmethod
391393 def with_pvwatts (cls , system , location ,
392394 clearsky_model = 'ineichen' ,
@@ -855,9 +857,7 @@ def spectral_model(self):
855857
856858 @spectral_model .setter
857859 def spectral_model (self , model ):
858- if model is None :
859- self ._spectral_model = self .infer_spectral_model ()
860- elif isinstance (model , str ):
860+ if isinstance (model , str ):
861861 model = model .lower ()
862862 if model == 'first_solar' :
863863 self ._spectral_model = self .first_solar_spectral_loss
@@ -867,30 +867,12 @@ def spectral_model(self, model):
867867 self ._spectral_model = self .no_spectral_loss
868868 else :
869869 raise ValueError (model + ' is not a valid spectral loss model' )
870- else :
870+ elif model is None :
871+ # not setting a model is equivalent to setting no_loss
872+ self ._spectral_model = self .no_spectral_loss
873+ else : # assume model is callable with 1st argument = the MC instance
871874 self ._spectral_model = partial (model , self )
872875
873- def infer_spectral_model (self ):
874- """Infer spectral model from system attributes."""
875- module_parameters = tuple (
876- array .module_parameters for array in self .system .arrays )
877- params = _common_keys (module_parameters )
878- if {'A4' , 'A3' , 'A2' , 'A1' , 'A0' } <= params :
879- return self .sapm_spectral_loss
880- elif ((('Technology' in params or
881- 'Material' in params ) and
882- (self .system ._infer_cell_type () is not None )) or
883- 'first_solar_spectral_coefficients' in params ):
884- return self .first_solar_spectral_loss
885- else :
886- raise ValueError ('could not infer spectral model from '
887- 'system.arrays[i].module_parameters. Check that '
888- 'the module_parameters for all Arrays in '
889- 'system.arrays contain valid '
890- 'first_solar_spectral_coefficients, a valid '
891- 'Material or Technology value, or set '
892- 'spectral_model="no_loss".' )
893-
894876 def first_solar_spectral_loss (self ):
895877 self .results .spectral_modifier = self .system .first_solar_spectral_loss (
896878 _tuple_from_dfs (self .results .weather , 'precipitable_water' ),
@@ -1570,7 +1552,7 @@ def _prepare_temperature(self, data):
15701552 ----------
15711553 data : DataFrame
15721554 May contain columns ``'cell_temperature'`` or
1573- ``'module_temperaure '``.
1555+ ``'module_temperature '``.
15741556
15751557 Returns
15761558 -------
@@ -1679,6 +1661,7 @@ def run_model(self, weather):
16791661 self .prepare_inputs (weather )
16801662 self .aoi_model ()
16811663 self .spectral_model ()
1664+
16821665 self .effective_irradiance_model ()
16831666
16841667 self ._run_from_effective_irrad (weather )
0 commit comments