8000 Fix clearsky Ineichen rounding by cedricleroy · Pull Request #808 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Fix clearsky Ineichen rounding #808

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filte 8000 r by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix clearsky Ineichen rounding
  • Loading branch information
cedricleroy committed Nov 3, 2019
commit 01e4769c8d76ded26a5cb93979d18074b87830ef
2 changes: 1 addition & 1 deletion pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def ineichen(apparent_zenith, airmass_absolute, linke_turbidity,
ghi = cg1 * dni_extra * cos_zenith * tl / tl * np.fmax(ghi, 0)

# BncI = "normal beam clear sky radiation"
b = 0.664 + 0.163/fh1
b = 0.664 + 0.16268/fh1
bnci = b * np.exp(-0.09 * airmass_absolute * (tl - 1))
bnci = dni_extra * np.fmax(bnci, 0)

Expand Down
70 changes: 36 additions & 34 deletions pvlib/test/test_clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def test_ineichen_series():
expected = pd.DataFrame(np.
array([[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 65.49426624, 321.16092181, 25.54562017],
[ 704.6968125 , 888.90147035, 87.73601277],
[1044.1230677 , 953.24925854, 107.03109696],
[ 853.02065704, 922.06124712, 96.42909484],
[ 251.99427693, 655.44925241, 53.9901349 ],
[ 65.49426624, 321.03665146, 25.56107792],
[ 704.6968125 , 888.55751839, 87.97474001],
[1044.1230677 , 952.88040806, 107.39369589],
[ 853.02065704, 921.70446345, 96.72185108],
[ 251.99427693, 655.19563211, 54.0667509 ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ]]),
columns=['ghi', 'dni', 'dhi'],
Expand All @@ -62,11 +62,11 @@ def test_ineichen_series_perez_enhancement():
expected = pd.DataFrame(np.
array([[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 91.1249279 , 321.16092171, 51.17628184],
[ 716.46580547, 888.9014706 , 99.50500553],
[1053.42066073, 953.24925905, 116.3286895 ],
[ 863.54692748, 922.06124652, 106.9553658 ],
[ 271.06382275, 655.44925213, 73.05968076],
[ 91.1249279 , 321.03665146, 51.1917396 ],
[ 716.46580547, 888.55751839, 99.7437328 ],
[1053.42066073, 952.88040806, 116.69128857],
[ 863.54692748, 921.70446345, 107.24812191],
[ 271.06382275, 655.1956321 , 73.13629663],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ]]),
columns=['ghi', 'dni', 'dhi'],
Expand All @@ -79,8 +79,8 @@ def test_ineichen_series_perez_enhancement():
def test_ineichen_scalar_input():
expected = OrderedDict()
expected['ghi'] = 1038.159219
expected['dni'] = 942.2081860378344
expected['dhi'] = 110.26529293612793
expected['dni'] = 941.843607
expected['dhi'] = 110.624333

out = clearsky.ineichen(10., 1., 3.)
for k, v in expected.items():
Expand All @@ -107,8 +107,8 @@ def test_ineichen_nans():
expected['dhi'] = np.full(length, np.nan)

expected['ghi'][length-1] = 1042.72590228
expected['dni'][length-1] = 946.35279683
expected['dhi'][length-1] = 110.75033088
expected['dni'][length-1] = 945.986614
expected['dhi'][length-1] = 111.11095

out = clearsky.ineichen(apparent_zenith, airmass_absolute,
linke_turbidity, dni_extra=dni_extra)
Expand All @@ -134,30 +134,30 @@ def test_ineichen_arrays():
[ 94.81136442, 64.38555328, 43.72365587]]]))

expected['dni'] = (np.
array([[[1014.38807396, 942.20818604, 861.11344424],
[1014.38807396, 942.20818604, 861.11344424],
[1014.38807396, 942.20818604, 861.11344424]],
array([[[1014.38807396, 941.8436073 , 860.78024436],
[1014.38807396, 941.8436073 , 860.78024436],
[1014.38807396, 941.8436073 , 860.78024436]],

[[ 687.61305142, 419.14891162, 255.50098235],
[ 687.61305142, 419.14891162, 255.50098235],
[ 687.61305142, 419.14891162, 255.50098235]],
[[ 687.34698591, 418.98672583, 255.40211861],
[ 687.34698591, 418.98672583, 255.40211861],
[ 687.34698591, 418.98672583, 255.40211861]],

[[ 458.62196014, 186.46177428, 75.80970012],
[ 458.62196014, 186.46177428, 75.80970012],
[ 458.62196014, 186.46177428, 75.80970012]]]))
[[ 458.44450061, 186.38962462, 75.78036626],
[ 458.44450061, 186.38962462, 75.78036626],
[ 458.44450061, 186.38962462, 75.78036626]]]))

expected['dhi'] = (np.
array([[[ 81.38267402, 111.96631281, 153.04382915],
[ 62.3427452 , 85.77117175, 117.23837487],
[ 14.13195304, 19.44274618, 26.57578203]],
array([[[ 81.38267402, 112.33089156, 153.37702903],
[ 62.3427452 , 86.05045527, 117.49362079],
[ 14.13195304, 19.50605461, 26.63364159]],

[[ 85.87736039, 206.04588395, 249.82982258],
[ 65.78587472, 157.84030442, 191.38074731],
[ 14.91244713, 35.77949226, 43.38249342]],
[[ 86.1434259 , 206.20806974, 249.92868632],
[ 65.98969272, 157.96454595, 191.45648133],
[ 14.95864893, 35.80765553, 43.39966093]],

[[ 87.37492676, 184.31984947, 175.98479873],
[ 66.93307711, 141.19719644, 134.81217714],
[ 15.17249681, 32.00680597, 30.5594396 ]]]))
[[ 87.55238629, 184.39199913, 176.01413259],
[ 67.069019 , 141.25246629, 134.83464818],
[ 15.20331233, 32.01933462, 30.56453337]]]))

apparent_zenith = np.linspace(0, 80, 3)
airmass_absolute = np.linspace(1, 10, 3)
Expand All @@ -169,12 +169,14 @@ def test_ineichen_arrays():
out = clearsky.ineichen(apparent_zenith, airmass_absolute, linke_turbidity)

for k, v in expected.items():
print(expected[k])
print(out[k])
assert_allclose(expected[k], out[k])


def test_ineichen_dni_extra():
expected = pd.DataFrame(
np.array([[1042.72590228, 946.35279683, 110.75033088]]),
np.array([[1042.72590228, 945.98661437, 111.11095021]]),
columns=['ghi', 'dni', 'dhi'])

out = clearsky.ineichen(10, 1, 3, dni_extra=pd.Series(1370))
Expand All @@ -183,7 +185,7 @@ def test_ineichen_dni_extra():

def test_ineichen_altitude():
expected = pd.DataFrame(
np.array([[1134.24312405, 994.95377835, 154.40492924]]),
np.array([[1134.24312405, 994.48564998, 154.86594569]]),
columns=['ghi', 'dni', 'dhi'])

out = clearsky.ineichen(10, 1, 3, altitude=pd.Series(2000))
Expand Down
0