Skip to content

Commit 477c923

Browse files
1759 resolve attrib error model chain (#1947)
* Remove or clause from if clause in infer_temperature_model in ModelChain * Updated what's new * Remove comment about removing or statement in infer_temperature_model in modelchain.py * Added test to verify that error indicating inability to infer temperature model is raised when not providing temperature model to arrays * Update docs/sphinx/source/whatsnew/v0.10.4.rst Co-authored-by: Kevin Anderson <[email protected]> * Update pvlib/tests/test_modelchain.py --------- Co-authored-by: Kevin Anderson <[email protected]>
1 parent b67a668 commit 477c923

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

docs/sphinx/source/whatsnew/v0.10.4.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Enhancements
1111

1212
Bug fixes
1313
~~~~~~~~~
14-
14+
* :py:class:`~pvlib.modelchain.ModelChain` now raises a more useful error when
15+
``temperature_model_parameters`` are specified on the passed ``system`` instead of on its ``arrays``. (:issue:`1759`).
1516

1617
Testing
1718
~~~~~~~
@@ -27,4 +28,4 @@ Requirements
2728

2829
Contributors
2930
~~~~~~~~~~~~
30-
31+
* :ghuser:`matsuobasho`

pvlib/modelchain.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,10 +1117,7 @@ def infer_temperature_model(self):
11171117
temperature_model_parameters = tuple(
11181118
array.temperature_model_parameters for array in self.system.arrays)
11191119
params = _common_keys(temperature_model_parameters)
1120-
# remove or statement in v0.9
1121-
if {'a', 'b', 'deltaT'} <= params or (
1122-
not params and self.system.racking_model is None
1123-
and self.system.module_type is None):
1120+
if {'a', 'b', 'deltaT'} <= params:
11241121
return self.sapm_temp
11251122
elif {'u_c', 'u_v'} <= params:
11261123
return self.pvsyst_temp

pvlib/tests/test_modelchain.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,22 @@ def test_temperature_model_inconsistent(location, sapm_dc_snl_ac_system):
13051305
spectral_model='no_loss', temperature_model='pvsyst')
13061306

13071307

1308+
def test_temperature_model_not_specified():
1309+
# GH 1759 -- ensure correct error is raised when temperature model params
1310+
# are specified on the PVSystem instead of the Arrays
1311+
location = Location(latitude=32.2, longitude=-110.9)
1312+
arrays = [pvsystem.Array(pvsystem.FixedMount(),
1313+
module_parameters={'pdc0': 1, 'gamma_pdc': 0})]
1314+
system = pvsystem.PVSystem(arrays,
1315+
temperature_model_parameters={'u0': 1, 'u1': 1},
1316+
inverter_parameters={'pdc0': 1})
1317+
with pytest.raises(ValueError,
1318+
match='could not infer temperature model '
1319+
'from system.temperature_model_parameters'):
1320+
_ = ModelChain(system, location,
1321+
aoi_model='no_loss', spectral_model='no_loss')
1322+
1323+
13081324
def test_dc_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather,
13091325
mocker):
13101326
m = mocker.spy(sys.modules[__name__], 'poadc')

0 commit comments

Comments
 (0)