Skip to content

Fix error message modelchain.infer_temperature_model error to be more informative #1977

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

Merged
merged 7 commits into from
Mar 11, 2024
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.10.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Bug fixes
``temperature_model_parameters`` are specified on the passed ``system`` instead of on its ``arrays``. (:issue:`1759`).
* :py:func:`pvlib.irradiance.ghi_from_poa_driesse_2023` now correctly makes use
of the ``xtol`` argument. Previously, it was ignored. (:issue:`1970`, :pull:`1971`)
* :py:class:`~pvlib.modelchain.ModelChain.infer_temperature_model` now raises a more useful error when
the temperature model cannot be inferred (:issue:`1946`)

Testing
~~~~~~~
Expand All @@ -33,5 +35,5 @@ Requirements
Contributors
~~~~~~~~~~~~
* Cliff Hansen (:ghuser:`cwhanse`)
* :ghuser:`matsuobasho`
* Roma Koulikov (:ghuser:`matsuobasho`)
* Adam R. Jensen (:ghuser:`AdamRJensen`)
14 changes: 9 additions & 5 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,11 +1128,15 @@ def infer_temperature_model(self):
elif {'noct', 'module_efficiency'} <= params:
return self.noct_sam_temp
else:
raise ValueError(f'could not infer temperature model from '
f'system.temperature_model_parameters. Check '
f'that all Arrays in system.arrays have '
f'parameters for the same temperature model. '
f'Common temperature model parameters: {params}.')
raise ValueError('could not infer temperature model from '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError('could not infer temperature model from '
raise ValueError('Could not infer temperature model from '

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matsuobasho this capitalization change will also require the tests to be updated. See the test failures here: https://github.com/pvlib/pvlib-python/actions/runs/8146219415/job/22264244062?pr=1977#step:9:134

'ModelChain.system. '
'If Arrays are used to construct the PVSystem, '
'check that all Arrays in '
'ModelChain.system.arrays '
'have parameers for the same temperature model. '
'If Arrays are not used, check that the PVSystem '
'attributes `racking_model` and `module_type` '
'are valid.')

def _set_celltemp(self, model):
"""Set self.results.cell_temperature using the given cell
Expand Down