iam.schlick_diffuse returns inf and nan at surface_tilt=180

オープン 初心者向け
#2,939 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pvlib/pvlib-python のほかの issue

pvlib/pvlib-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。