Skip to content

Raise helpful exceptions for irradiance.gti_dirint#2347

Merged
kandersolar merged 11 commits into
pvlib:mainfrom
cwhanse:gti_dirint
Feb 12, 2025
Merged

Raise helpful exceptions for irradiance.gti_dirint#2347
kandersolar merged 11 commits into
pvlib:mainfrom
cwhanse:gti_dirint

Conversation

@cwhanse

@cwhanse cwhanse commented Dec 31, 2024

Copy link
Copy Markdown
Member

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
Comment thread docs/sphinx/source/whatsnew/v0.11.3.rst Outdated
Comment thread pvlib/irradiance.py Outdated
Comment thread pvlib/irradiance.py Outdated
Comment thread pvlib/irradiance.py
"""
# check input data and raise Exceptions where data will cause the
# algorithm to fail
_gti_dirint_check_input(aoi)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

cwhanse and others added 3 commits January 31, 2025 10:51
Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>

@kandersolar kandersolar left a comment

Copy link
Copy Markdown
Member

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
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 <anton.driesse@pvperformancelabs.com>

* update test

---------

Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>
@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