iam.schlick_diffuse returns inf and nan at surface_tilt=180

未關閉 適合新手
#2,939 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

先閱讀 pvlib.iam.schlick_diffuse 及其測試,了解 surface_tilt=0 時現有的地面項特殊情況。接著在 surface_tilt=180 時重現回報的結果,再檢查端點和附近傾角下的兩個散射分量。完成標準是:函式在沒有除以零警告的情況下傳回預期的天空值和地面值,且回歸測試涵蓋此行為。

由索引模型根據 Issue 內容生成。

描述

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.

To Reproduce

import pvlib
pvlib.iam.schlick_diffuse(180)
# {'sky': inf, 'ground': nan}

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.

主要語言
Python
星號
1.7k
分支
1.2k
平均合併
3 天 4 小時
30 天內合併 PR
8

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

pvlib/pvlib-python 的其他 Issue

查看 pvlib/pvlib-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。