Skip to content

Clip kt_prime in DIRINT coefficient lookup so gti_dirint no longer returns NaN for kt_prime > 1 - #2936

Open
DresdenGman wants to merge 2 commits into
pvlib:mainfrom
DresdenGman:fix-1815-dirint-kt-clip
Open

DresdenGman wants to merge 2 commits into
pvlib:mainfrom
DresdenGman:fix-1815-dirint-kt-clip

Conversation

@DresdenGman

Copy link
Copy Markdown

Closes #1815.

As agreed in #1815, this clips the kt′ value used for the DIRINT coefficient lookup to the coefficient table boundary (1.0), inside _dirint_coeffs so that all callers are covered. Previously, kt′ > 1 found no bin in the coefficient table and produced NaN coefficients, and therefore NaN irradiances from gti_dirint, cascading into the AOI ≥ 90 estimates as well — in the reported configuration, 4 NaN values at 2× poa_global and 7 at 4×, including an entire AOI ≥ 90 row. Only the lookup value is clipped: kt′ itself and delta_kt_prime remain unchanged everywhere else, and results for kt′ ≤ 1 are identical to before.

Tests: two regression tests in tests/test_irradiance.py (module result: 131 passed / 10 skipped). The coefficients for kt′ = 1.2 and 2.0 now equal the kt′ = 1.0 boundary coefficients exactly, and the end-to-end gti_dirint case that previously returned NaNs now returns finite values throughout — the test also asserts that the coefficient lookup received kt′ up to ≈1.54, so the case cannot silently stop exercising this path.

  • Closes #xxxx
  • I am familiar with the contributing guidelines
  • I attest that all AI-generated material has been vetted for accuracy and is in compliance with the pvlib license
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in 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`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

The DIRINT coefficient table only covers kt_prime up to 1, so
gti_dirint returned NaN DNI/DHI whenever the iteration produced
kt_prime above 1, including at AOI >= 90 timestamps.  Clip the
value at the entrance of _dirint_coeffs, as agreed in the issue
discussion, so out-of-range values use the boundary coefficients
instead.  The kt_prime series itself is left unchanged everywhere
else, and dirint is unaffected because it already limits kt_prime
to 1.
- whats-new: only claim the NaN cause this fix removes (kt_prime
  exceeding the DIRINT coefficient table)
- test_dirint_coeffs_kt_prime_gt_one: compare against a manually
  capped reference lookup, and cover non-sentinel w/delta_kt_prime
- test_gti_dirint_kt_prime_gt_one: spy on _dirint_coeffs to prove
  kt_prime > 1 is exercised, and assert the full expected frame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nan irradiances produced by gti_dirint

1 participant