Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] iam.physical returns nan for aoi > 90° when n = 1 (#1706) #1707

Merged
merged 5 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions pvlib/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ def physical(aoi, n=1.526, K=4.0, L=0.002, *, n_ar=None):
# incidence angle modifier
iam = (tau_s + tau_p) / 2 / tau_0

# for light coming from behind the plane, none can enter the module
# when n2 > 1, this is already the case
if np.isclose(n2, 1).any():
iam = np.where(aoi >= 90, 0, iam)
if isinstance(aoi, pd.Series):
iam = pd.Series(iam, index=aoi.index)

return iam


Expand Down
12 changes: 12 additions & 0 deletions pvlib/tests/test_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def test_physical():
assert_series_equal(iam, expected)


def test_physical_n1_L0():
aoi = np.array([0, 22.5, 45, 67.5, 90, 100, np.nan])
expected = np.array([1, 1, 1, 1, 0, 0, np.nan])
iam = _iam.physical(aoi, n=1, L=0)
assert_allclose(iam, expected, equal_nan=True)

aoi = pd.Series(aoi)
expected = pd.Series(expected)
iam = _iam.physical(aoi, n=1, L=0)
assert_series_equal(iam, expected)


def test_physical_ar():
aoi = np.array([0, 22.5, 45, 67.5, 90, 100, np.nan])
expected = np.array([1, 0.99944171, 0.9917463, 0.91506158, 0, 0, np.nan])
Expand Down