-
Notifications
You must be signed in to change notification settings - Fork 1.1k
1759 resolve attrib error model chain #1947
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
Conversation
Any updates on this? |
@pvlib/pvlib-maintainer please take a look. The PR moves pvlib towards requiring the temperature model to be explicit, either by providing parameters or setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @matsuobasho!
Can we add a test? Something like this (please check that it makes sense) around line 1308 in test_modelchain.py
:
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')
pvlib/modelchain.py
Outdated
@@ -1118,9 +1118,7 @@ def infer_temperature_model(self): | |||
array.temperature_model_parameters for array in self.system.arrays) | |||
params = _common_keys(temperature_model_parameters) | |||
# remove or statement in v0.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's delete this comment as well, since we are now removing the specified or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do about removing the or
statement, nice catch.
Thanks for creating the test. I have 2 comments about it before implementing. The PVSystem
docstring states:
If `arrays` is
specified the following PVSystem parameters are ignored:
Having stepped away from this and looking at the error I realized that understanding why the temperature model parameter was ignored requires the user to dig through that long PVsystem
docstring.
I think it's worthwhile to update the error message to make it easier on the user:
ValueError: could not infer temperature model from system.temperature_model_parameters. Check that all Arrays in system.arrays have parameters for the same temperature model. Note that if arrays are passed, many system arguments are ignored. Common temperature model parameters: set().
Also, we need to update that last sentence in the error message, it's confusing. Not sure where this set()
is coming from, looking for guidance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that passing temperature_model_parameters
alongside arrays
is not a valid use for PVSystem. If a user did this, they should not expect it to work. But the intent of this test is to make sure that, when this incorrect usage occurs, the correct error is raised: ValueError: could not infer temperature...
instead of AttributeError: 'PVSystem' object has no attribute 'racking_model'
. What you suggest (do not specify temperature_model_parameters
at all) would be a verification of some other behavior, not that the issue from #1759 is resolved.
If you like, please clarify the explanation comment in the test for future readers :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was updating my comment while you were replying. I'm not proposing modifying the test by not specifying temperature_model_parameters
. I'm proposing updating the error message to make it more informative, as well as fixing the last sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this ValueError, what about
"Could not infer the temperature model. If Arrays are not used to construct the PVsystem, check the PVsystem attributes racking_model and module_type. If Arrays are used, check that all Arrays in ModelChain.system.arrays have parameters for the same temperature model. Common temperature model parameters: {params}."
The params
dict is what ModelChain found when it tries to infer the temperature model, and is provided here to (hopefully) help the user to diagnose and fix the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kandersolar, you are correct, makes sense, thanks. Will incorporate as per your suggestion and then after we finish probably tackle #1946 to address the error message. Thanks @cwhanse for the phrasing.
… in modelchain.py
…ture model is raised when not providing temperature model to arrays
Co-authored-by: Kevin Anderson <[email protected]>
Thanks again @matsuobasho! This is a good bug to have fixed. |
Glad to help! Thanks for your inputs @cwhanse and @kandersolar |
docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.