You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iam.schlick_diffuse returns inf and nan at surface_tilt=180 #2939
Describe the bug pvlib.iam.schlick_diffuse(180) returns {'sky': inf, 'ground': nan} with a RuntimeWarning: divide by zero. Eq 4 for the sky term divides by 1 + cos(surface_tilt), which is 0/0 at 180. The ground term is already special-cased at tilt 0 (surface_tilt < 1e-6); the sky term has no equivalent at 180.
Expected behavior sky is 0 (a surface facing straight down sees no sky; the value tends to 0 as the tilt approaches 180) and ground is 20/21 = 0.9524, the same as sky at tilt 0. marion_diffuse('schlick', surface_tilt=180) gives 0 and 0.95236.
Versions:
pvlib.__version__: 0.16.2.dev19+gc5de586d7
pandas.__version__: 3.1.1
python: 3.12.12
Additional context
Found while reading the code. PVSystem.get_iam_diffuse(180, iam_model='schlick_diffuse') returns the same. I can open a PR that applies the same 1e-6 clamp to the sky term.
Activity
cwhanse commentedon Nov 8, 2026
Seems to me like a good idea. Please wait for other maintainers to comment.
kandersolar commentedon Nov 9, 2026
Thanks for the good bug report. A PR would be welcome, and please include test(s) as well.