Skip to content

Raise helpful exceptions for irradiance.gti_dirint #2347

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 11 commits into from
Feb 12, 2025

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Dec 31, 2024

gti_dirint could fail for a number of not-well-defined conditions. One known condition is reported in #1342, where all inputs have AOI >= 90.

I could not determine exactly how much data is "required" by gti_dirint. For instance, if there are insufficient daily data with 60 < AOI < 85 (see these lines), the function will proceed with kt_prime_gte_90= np.nan and will basically assume that the day is entirely clear at this line. I can't say that's a failure of the code, but I'm skeptical that gti_dirint will return anything meaningful. I don't know if we want to check, or what exception or warning to raise.

In any case, the check added in this PR closes the issue reported in #1342, and sets up gti_dirint to have additional checks added, should that be desired.

@cwhanse cwhanse added this to the v0.11.3 milestone Jan 28, 2025
@@ -2368,6 +2368,9 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
irradiance, Solar Energy 122, 1037-1046.
:doi:`10.1016/j.solener.2015.10.024`
"""
# check input data and raise Exceptions where data will cause the
# algorithm to fail
_gti_dirint_check_input(aoi)
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with a function for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't either if this was the only condition to check. But I'm certain there are other data requirements which we haven't deduced yet and thought it helpful to put the function in place to collect checks.

Copy link
Member

Choose a reason for hiding this comment

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

There's probably some pythonic aphorism for these situations.

Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

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

@cwhanse there is a merge conflict to resolve

@kandersolar kandersolar merged commit 22364d8 into pvlib:main Feb 12, 2025
26 checks passed
echedey-ls pushed a commit to echedey-ls/pvlib-python that referenced this pull request Feb 19, 2025
* add a function to test inputs for gti_dirint

* linter

* linter

* linter

* whatsnew

* review

* Update pvlib/irradiance.py

Co-authored-by: Anton Driesse <[email protected]>

* update test

---------

Co-authored-by: Anton Driesse <[email protected]>
@kandersolar kandersolar modified the milestones: v0.11.3, v0.12.0 Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gti_dirint raises 'UnboundLocalError: local variable 'best_ghi' referenced before assignment'
4 participants