|
8 | 8 |
|
9 | 9 | SPECTRL2_TEST_DATA = DATA_DIR / 'spectrl2_example_spectra.csv' |
10 | 10 |
|
| 11 | + |
11 | 12 | @pytest.fixture |
12 | 13 | def spectrl2_data(): |
13 | 14 | # reference spectra generated with solar_utils==0.3 |
@@ -175,25 +176,25 @@ def test_calc_spectral_mismatch_field(spectrl2_data): |
175 | 176 |
|
176 | 177 | @pytest.mark.parametrize("module_type,expect", [ |
177 | 178 | ('cdte', np.array( |
178 | | - [[ 0.99051020, 0.97640320, 0.93975028], |
179 | | - [ 1.02928735, 1.01881074, 0.98578821], |
180 | | - [ 1.04750335, 1.03814456, 1.00623986]])), |
| 179 | + [[0.99051020, 0.97640320, 0.93975028], |
| 180 | + [1.02928735, 1.01881074, 0.98578821], |
| 181 | + [1.04750335, 1.03814456, 1.00623986]])), |
181 | 182 | ('monosi', np.array( |
182 | | - [[ 0.97769770, 1.02043409, 1.03574032], |
183 | | - [ 0.98630905, 1.03055092, 1.04736262], |
184 | | - [ 0.98828494, 1.03299036, 1.05026561]])), |
| 183 | + [[0.97769770, 1.02043409, 1.03574032], |
| 184 | + [0.98630905, 1.03055092, 1.04736262], |
| 185 | + [0.98828494, 1.03299036, 1.05026561]])), |
185 | 186 | ('polysi', np.array( |
186 | | - [[ 0.97704080, 1.01705849, 1.02613202], |
187 | | - [ 0.98992828, 1.03173953, 1.04260662], |
188 | | - [ 0.99352435, 1.03588785, 1.04730718]])), |
| 187 | + [[0.97704080, 1.01705849, 1.02613202], |
| 188 | + [0.98992828, 1.03173953, 1.04260662], |
| 189 | + [0.99352435, 1.03588785, 1.04730718]])), |
189 | 190 | ('cigs', np.array( |
190 | | - [[ 0.97459190, 1.02821696, 1.05067895], |
191 | | - [ 0.97529378, 1.02967497, 1.05289307], |
192 | | - [ 0.97269159, 1.02730558, 1.05075651]])), |
| 191 | + [[0.97459190, 1.02821696, 1.05067895], |
| 192 | + [0.97529378, 1.02967497, 1.05289307], |
| 193 | + [0.97269159, 1.02730558, 1.05075651]])), |
193 | 194 | ('asi', np.array( |
194 | | - [[ 1.05552750, 0.87707583, 0.72243772], |
195 | | - [ 1.11225204, 0.93665901, 0.78487953], |
196 | | - [ 1.14555295, 0.97084011, 0.81994083]])) |
| 195 | + [[1.05552750, 0.87707583, 0.72243772], |
| 196 | + [1.11225204, 0.93665901, 0.78487953], |
| 197 | + [1.14555295, 0.97084011, 0.81994083]])) |
197 | 198 | ]) |
198 | 199 | def test_spectral_factor_firstsolar(module_type, expect): |
199 | 200 | ams = np.array([1, 3, 5]) |
@@ -317,6 +318,62 @@ def test_spectral_factor_caballero_supplied_ambiguous(): |
317 | 318 | coefficients=None) |
318 | 319 |
|
319 | 320 |
|
| 321 | +@pytest.mark.parametrize("module_type,expected", [ |
| 322 | + ('asi', np.array([1.15534029, 1.1123772, 1.08286684, 1.01915462])), |
| 323 | + ('fs-2', np.array([1.0694323, 1.04948777, 1.03556288, 0.9881471])), |
| 324 | + ('fs-4', np.array([1.05234725, 1.037771, 1.0275516, 0.98820533])), |
| 325 | + ('multisi', np.array([1.03310403, 1.02391703, 1.01744833, 0.97947605])), |
| 326 | + ('monosi', np.array([1.03225083, 1.02335353, 1.01708734, 0.97950110])), |
| 327 | + ('cigs', np.array([1.01475834, 1.01143927, 1.00909094, 0.97852966])), |
| 328 | +]) |
| 329 | +def test_spectral_factor_pvspec(module_type, expected): |
| 330 | + ams = np.array([1.0, 1.5, 2.0, 1.5]) |
| 331 | + kcs = np.array([0.4, 0.6, 0.8, 1.4]) |
| 332 | + out = spectrum.spectral_factor_pvspec(ams, kcs, |
| 333 | + module_type=module_type) |
| 334 | + assert np.allclose(expected, out, atol=1e-8) |
| 335 | + |
| 336 | + |
| 337 | +@pytest.mark.parametrize("module_type,expected", [ |
| 338 | + ('asi', pd.Series([1.15534029, 1.1123772, 1.08286684, 1.01915462])), |
| 339 | + ('fs-2', pd.Series([1.0694323, 1.04948777, 1.03556288, 0.9881471])), |
| 340 | + ('fs-4', pd.Series([1.05234725, 1.037771, 1.0275516, 0.98820533])), |
| 341 | + ('multisi', pd.Series([1.03310403, 1.02391703, 1.01744833, 0.97947605])), |
| 342 | + ('monosi', pd.Series([1.03225083, 1.02335353, 1.01708734, 0.97950110])), |
| 343 | + ('cigs', pd.Series([1.01475834, 1.01143927, 1.00909094, 0.97852966])), |
| 344 | +]) |
| 345 | +def test_spectral_factor_pvspec_series(module_type, expected): |
| 346 | + ams = pd.Series([1.0, 1.5, 2.0, 1.5]) |
| 347 | + kcs = pd.Series([0.4, 0.6, 0.8, 1.4]) |
| 348 | + out = spectrum.spectral_factor_pvspec(ams, kcs, |
| 349 | + module_type=module_type) |
| 350 | + assert isinstance(out, pd.Series) |
| 351 | + assert np.allclose(expected, out, atol=1e-8) |
| 352 | + |
| 353 | + |
| 354 | +def test_spectral_factor_pvspec_supplied(): |
| 355 | + # use the multisi coeffs |
| 356 | + coeffs = (0.9847, -0.05237, 0.03034) |
| 357 | + out = spectrum.spectral_factor_pvspec(1.5, 0.8, coefficients=coeffs) |
| 358 | + expected = 1.00860641 |
| 359 | + assert_allclose(out, expected, atol=1e-8) |
| 360 | + |
| 361 | + |
| 362 | +def test_spectral_factor_pvspec_supplied_redundant(): |
| 363 | + # Error when specifying both module_type and coefficients |
| 364 | + coeffs = (0.9847, -0.05237, 0.03034) |
| 365 | + with pytest.raises(ValueError, match='supply only one of'): |
| 366 | + spectrum.spectral_factor_pvspec(1.5, 0.8, module_type='multisi', |
| 367 | + coefficients=coeffs) |
| 368 | + |
| 369 | + |
| 370 | +def test_spectral_factor_pvspec_supplied_ambiguous(): |
| 371 | + # Error when specifying neither module_type nor coefficients |
| 372 | + with pytest.raises(ValueError, match='No valid input provided'): |
| 373 | + spectrum.spectral_factor_pvspec(1.5, 0.8, module_type=None, |
| 374 | + coefficients=None) |
| 375 | + |
| 376 | + |
320 | 377 | @pytest.fixture |
321 | 378 | def sr_and_eqe_fixture(): |
322 | 379 | # Just some arbitrary data for testing the conversion functions |
|
0 commit comments