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

Horizon coefficient should be allowed to go negative in the Perez transposition model #1239

Conversation

cpr-chas
Copy link
Contributor

@cpr-chas cpr-chas commented May 21, 2021

Horizon coefficient should be allowed to go negative in the Perez transposition model

Link to the original paper: https://www.osti.gov/servlets/purl/7024029
Section III.2 states this explicitly for the horizon component:
"(2) The horizon brightening coefficient, F2, is negative for overcast and low E occurrences -- indicative of brightening of the zenithal region of the sky for these conditions. This becomes positive past intermediate conditions and increases substantially with clearness."

Note that this change also impacts results from the DIRINT model (used to generate DNI from GHI).

… in the Perez transposition model

Horizon coefficient should be allowed to go negative in the Perez transposition model

Link to the original paper: https://www.osti.gov/servlets/purl/7024029
Section III.2 states this explicitly for the horizon component:
"(2) The horizon brightening coefficient, F2, is negative for overcast and low E occurrences -- indicative of brightening of the zenithal region of the sky for these conditions. This becomes positive past intermediate conditions and increases substantially with clearness."

Note that this change also impacts results from the DIRINT model (used to generate DNI from GHI).

This change corresponds to revision 8 of the SAM vs PVLib comparison, found here:
https://cleanpower1.sharepoint.com/sites/SolarAnywhere/Shared%20Documents/Power%20Model%20Discussions/PVLib_Comparison_Rev8_FixPvLibPerezModelF2Bound.zip
@cpr-chas
Copy link
Contributor Author

It appears that I have violated a number of formatting requirements, so I'll work on getting those addressed.

@wholmgren
Copy link
Member

Thanks @cpr-chas! We're not too strict about these particular formatting requirements in the test files when they occur in array input:

E203 whitespace before ','
E231 missing whitespace after ','
E202 whitespace before ']'

It's already a pain to add comprehensive array values to test against and we don't want to make it too much of a burden. Other requirements like trailing whitespace at the end of a line, indents, and space around = are still important for long term readability.

Fix reported Stickler issues

This is an attempt to fix all formatting requirement failures reported by Stickler CI for PR 1239 to the pvlib-python project.

Related work items: #18784
@cpr-chas
Copy link
Contributor Author

Thanks Will. I already had a lot of those changes in progress so went ahead and finished it up, but it looks like I just ended up creating (or revealing) others. Is there any way to run this manually on my local clone?

@wholmgren
Copy link
Member

pip install flake8 then git diff upstream/master -u -- "*.py" | flake8 --diff. This assumes that you have a git remote named upstream that points to pvlib/pvlib-python. If your local master branch is up to date then you can delete the upstream/.

@cpr-chas
Copy link
Contributor Author

Perfect. Thanks Will!

I was shown how to validate this locally and fixed all issues, so this should be the last round.  I couldn't cherry pick due to conflicts. but this shouldn't include any other changes.

Related work items: #18784
@cwhanse cwhanse added the bug label May 23, 2021
@cwhanse cwhanse added this to the 0.9.0 milestone May 23, 2021
@cwhanse
Copy link
Member

cwhanse commented May 23, 2021

I have checked the new test against the Matlab code. The results agree.

@mikofski
Copy link
Member

Do we need a note to explain how this will affect existing results? Is it only during sunrise, low irradiance?

@cpr-chas
Copy link
Contributor Author

cpr-chas commented May 24, 2021

I expect it to affect primarily low irradiance, overcast conditions, but is not limited to sunrise/sunset.
Any recommendations on what to put into "what's new"? I assume that's the last piece I'm missing and that I don't need to update any api or code documentation.

@cwhanse
Copy link
Member

cwhanse commented May 24, 2021

I expect it to affect primarily low irradiance, overcast conditions, but is not limited to sunrise/sunset.
Any recommendations on what to put into "what's new"? I assume that's the last piece I'm missing and that I don't need to update any api or code documentation.

Correct, just add a note to whatsnew under "Bug fixes".

Suggestion: "Corrected an error in :py:func:~pvlib.irradiance.perez where the horizon irradiance component was prevented from taking negative values. Negative values are intentional according to the original publication. Changes in output are
expected to be small and primarily occur at low irradiance conditions."

@cpr-chas
Copy link
Contributor Author

I expect it to affect primarily low irradiance, overcast conditions, but is not limited to sunrise/sunset.
Any recommendations on what to put into "what's new"? I assume that's the last piece I'm missing and that I don't need to update any api or code documentation.

Correct, just add a note to whatsnew under "Bug fixes".

Suggestion: "Corrected an error in :py:func:~pvlib.irradiance.perez where the horizon irradiance component was prevented from taking negative values. Negative values are intentional according to the original publication. Changes in output are
expected to be small and primarily occur at low irradiance conditions."

Done. I didn't see anything after the 0.9.0 release so I added it there under the assumption that this release isn't closed yet. Let me know if that's not the right place. Thanks!

@cpr-chas
Copy link
Contributor Author

@pvlib/maintainer - does this still need to be assigned official reviewers? I'm not sure what the process is here since several people have obviously looked at the change already, but I do see that other PRs have explicit reviewers listed and I wasn't sure if I had to specifically request a review.

@mikofski
Copy link
Member

Hi @cpr-chas I'll try to look through for syntax today asap unless someone else beats me to it. I believe @cwhanse has already approved it verbally for consistency with pvlib-MATLAB and Perez's original intent based on the literature. thanks for your patience, bringing the issue up, and the fix! 😄

Copy link
Member

@mikofski mikofski left a comment

Choose a reason for hiding this comment

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

Syntax all looks great. Thanks! @cwhanse I vote to merge. Please do the honors if you agree.

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

thanks @cpr-chas

@cwhanse
Copy link
Member

cwhanse commented May 26, 2021

@wholmgren in case you have projects that depend on the perez function, I'll wait to merge until you approve.

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

looks good to me. Thanks @cpr-chas!

@cwhanse cwhanse merged commit 01a23e3 into pvlib:master May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Perez diffuse model should not be forcing the horizon coefficient up to zero
4 participants