|
6 | 6 |
|
7 | 7 | from nose.tools import raises
|
8 | 8 | from nose.tools import assert_almost_equals
|
| 9 | +from numpy.testing import assert_allclose |
9 | 10 |
|
10 | 11 | from pvlib.location import Location
|
11 | 12 | from pvlib import solarposition
|
@@ -75,4 +76,44 @@ def test_gueymard94_pw():
|
75 | 76 | [ 0.1 , 0.33702061, 1.12340202, 0.1 ,
|
76 | 77 | 1.12040963, 3.73469877, 0.1 , 3.44859767, 11.49532557])
|
77 | 78 |
|
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