Skip to content

Commit e08b759

Browse files
committed
update fs coeffs, add fs tests
1 parent cdd2d5d commit e08b759

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

pvlib/atmosphere.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
406406

407407
_coefficients = {}
408408
_coefficients['cdte'] = (
409-
0.8752, -0.04588, -0.01559, 0.08751, 0.09158, -0.002295)
409+
0.87102, -0.040543, -0.00929202, 0.10052, 0.073062, -0.0034187)
410410
_coefficients['monosi'] = (
411-
0.8478, -0.03326, -0.0022953, 0.1565, 0.01566, -0.001712)
411+
0.86588, -0.021637, -0.0030218, 0.12081, 0.017514, -0.0012610)
412412
_coefficients['xsi'] = _coefficients['monosi']
413413
_coefficients['polysi'] = (
414-
0.83019, -0.04063, -0.005281, 0.1695, 0.02974, -0.001676)
414+
0.84674, -0.028568, -0.0051832, 0.13669, 0.029234, -0.0014207)
415415
_coefficients['multisi'] = _coefficients['polysi']
416416

417417
if module_type is not None and coefficients is None:

pvlib/test/test_atmosphere.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from nose.tools import raises
88
from nose.tools import assert_almost_equals
9+
from numpy.testing import assert_allclose
910

1011
from pvlib.location import Location
1112
from pvlib import solarposition
@@ -75,4 +76,44 @@ def test_gueymard94_pw():
7576
[ 0.1 , 0.33702061, 1.12340202, 0.1 ,
7677
1.12040963, 3.73469877, 0.1 , 3.44859767, 11.49532557])
7778

78-
np.testing.assert_allclose(pws, expected, atol=0.01)
79+
assert_allclose(pws, expected, atol=0.01)
80+
81+
82+
def test_first_solar_spectral_correction():
83+
ams = np.array([1, 3, 5])
84+
pws = np.array([1, 3, 5])
85+
ams, pws = np.meshgrid(ams, pws)
86+
87+
expect = {}
88+
expect['cdte'] = np.array(
89+
[[ 0.99134828, 0.97701063, 0.93975103],
90+
[ 1.02852847, 1.01874908, 0.98604776],
91+
[ 1.04722476, 1.03835703, 1.00656735]])
92+
expect['monosi'] = np.array(
93+
[[ 0.9782842 , 1.02092726, 1.03602157],
94+
[ 0.9859024 , 1.0302268 , 1.04700244],
95+
[ 0.98885429, 1.03351495, 1.05062687]])
96+
expect['polysi'] = np.array(
97+
[[ 0.9774921 , 1.01757872, 1.02649543],
98+
[ 0.98947361, 1.0314545 , 1.04226547],
99+
[ 0.99403107, 1.03639082, 1.04758064]])
100+
101+
def run_fs_test(module_type):
102+
out = atmosphere.first_solar_spectral_correction(pws, ams, module_type)
103+
assert_allclose(out, expect[module_type], atol=0.001)
104+
105+
for module_type in expect.keys():
106+
yield run_fs_test, module_type
107+
108+
109+
def test_first_solar_spectral_correction_supplied():
110+
# use the cdte coeffs
111+
coeffs = (0.87102, -0.040543, -0.00929202, 0.10052, 0.073062, -0.0034187)
112+
out = atmosphere.first_solar_spectral_correction(1, 1, coefficients=coeffs)
113+
expected = 0.99134828
114+
assert_allclose(out, expected, atol=1e-3)
115+
116+
117+
@raises(TypeError)
118+
def test_first_solar_spectral_correction_ambiguous():
119+
atmosphere.first_solar_spectral_correction(1, 1)

0 commit comments

Comments
 (0)