Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1759 resolve attrib error model chain #1947

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/sphinx/source/whatsnew/v0.10.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Enhancements

Bug fixes
~~~~~~~~~

* :py:class:`~pvlib.modelchain.ModelChain` now raises a more useful error when
``temperature_model_parameters`` are specified on the passed ``system`` instead of on its ``arrays``. (:issue:`1759`).

Testing
~~~~~~~
Expand All @@ -27,4 +28,4 @@ Requirements

Contributors
~~~~~~~~~~~~

* :ghuser:`matsuobasho`
5 changes: 1 addition & 4 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,7 @@ def infer_temperature_model(self):
temperature_model_parameters = tuple(
array.temperature_model_parameters for array in self.system.arrays)
params = _common_keys(temperature_model_parameters)
# remove or statement in v0.9
if {'a', 'b', 'deltaT'} <= params or (
not params and self.system.racking_model is None
and self.system.module_type is None):
if {'a', 'b', 'deltaT'} <= params:
return self.sapm_temp
elif {'u_c', 'u_v'} <= params:
return self.pvsyst_temp
Expand Down
16 changes: 16 additions & 0 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,22 @@ def test_temperature_model_inconsistent(location, sapm_dc_snl_ac_system):
spectral_model='no_loss', temperature_model='pvsyst')


def test_temperature_model_not_specified():
# GH 1759 -- ensure correct error is raised when temperature model params
# are specified on the PVSystem instead of the Arrays
location = Location(latitude=32.2, longitude=-110.9)
arrays = [pvsystem.Array(pvsystem.FixedMount(),
module_parameters={'pdc0': 1, 'gamma_pdc': 0})]
system = pvsystem.PVSystem(arrays,
temperature_model_parameters={'u0': 1, 'u1': 1},
inverter_parameters={'pdc0': 1})
with pytest.raises(ValueError,
match='could not infer temperature model '
'from system.temperature_model_parameters'):
_ = ModelChain(system, location,
aoi_model='no_loss', spectral_model='no_loss')


def test_dc_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather,
mocker):
m = mocker.spy(sys.modules[__name__], 'poadc')
Expand Down
Loading