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

Raise helpful exceptions for irradiance.gti_dirint #2347

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

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
docs/sphinx/source/whatsnew/v0.11.3.rst Outdated Show resolved Hide resolved
pvlib/irradiance.py Outdated Show resolved Hide resolved
pvlib/irradiance.py Outdated Show resolved Hide resolved
@@ -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.

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