@@ -176,7 +176,7 @@ def test_calc_spectral_mismatch_field(spectrl2_data):
176
176
177
177
@pytest .fixture
178
178
def martin_ruiz_mismatch_data ():
179
- # Data to run tests of martin_ruiz_spectral_modifier
179
+ # Data to run tests of spectrum.martin_ruiz
180
180
kwargs = {
181
181
'clearness_index' : [0.56 , 0.612 , 0.664 , 0.716 , 0.768 , 0.82 ],
182
182
'airmass_absolute' : [2 , 1.8 , 1.6 , 1.4 , 1.2 , 1 ],
@@ -205,12 +205,12 @@ def martin_ruiz_mismatch_data():
205
205
206
206
207
207
def test_martin_ruiz_mm_scalar (martin_ruiz_mismatch_data ):
208
- # test scalar input ; only cell_type given
208
+ # test scalar input ; only module_type given
209
209
clearness_index = martin_ruiz_mismatch_data ['clearness_index' ][0 ]
210
210
airmass_absolute = martin_ruiz_mismatch_data ['airmass_absolute' ][0 ]
211
- result = spectrum .martin_ruiz_spectral_modifier (clearness_index ,
212
- airmass_absolute ,
213
- cell_type = 'asi' )
211
+ result = spectrum .martin_ruiz (clearness_index ,
212
+ airmass_absolute ,
213
+ module_type = 'asi' )
214
214
215
215
assert_approx_equal (result ['poa_direct' ],
216
216
martin_ruiz_mismatch_data ['asi_expected' ]['dir' ][0 ],
@@ -224,31 +224,29 @@ def test_martin_ruiz_mm_scalar(martin_ruiz_mismatch_data):
224
224
225
225
226
226
def test_martin_ruiz_mm_series (martin_ruiz_mismatch_data ):
227
- # test with Series input ; only cell_type given
227
+ # test with Series input ; only module_type given
228
228
clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
229
229
airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
230
230
expected = pd .DataFrame (data = {
231
231
'dir' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['dir' ]),
232
232
'sky' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['sky' ]),
233
233
'gnd' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['gnd' ])})
234
234
235
- result = spectrum .martin_ruiz_spectral_modifier (clearness_index ,
236
- airmass_absolute ,
237
- cell_type = 'polysi' )
235
+ result = spectrum .martin_ruiz (clearness_index , airmass_absolute ,
236
+ module_type = 'polysi' )
238
237
assert_allclose (result ['poa_direct' ], expected ['dir' ], atol = 1e-5 )
239
238
assert_allclose (result ['poa_sky_diffuse' ], expected ['sky' ], atol = 1e-5 )
240
239
assert_allclose (result ['poa_ground_diffuse' ], expected ['gnd' ], atol = 1e-5 )
241
240
242
241
243
242
def test_martin_ruiz_mm_nans (martin_ruiz_mismatch_data ):
244
- # test NaN in, NaN out ; only cell_type given
243
+ # test NaN in, NaN out ; only module_type given
245
244
clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
246
245
airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
247
246
airmass_absolute [:5 ] = np .nan
248
247
249
- result = spectrum .martin_ruiz_spectral_modifier (clearness_index ,
250
- airmass_absolute ,
251
- cell_type = 'monosi' )
248
+ result = spectrum .martin_ruiz (clearness_index , airmass_absolute ,
249
+ module_type = 'monosi' )
252
250
assert np .isnan (result ['poa_direct' ][:5 ]).all ()
253
251
assert not np .isnan (result ['poa_direct' ][5 :]).any ()
254
252
assert np .isnan (result ['poa_sky_diffuse' ][:5 ]).all ()
@@ -268,7 +266,7 @@ def test_martin_ruiz_mm_model_dict(martin_ruiz_mismatch_data):
268
266
'gnd' : pd .Series (martin_ruiz_mismatch_data ['monosi_expected' ]['gnd' ])})
269
267
model_parameters = martin_ruiz_mismatch_data ['monosi_model_params_dict' ]
270
268
271
- result = spectrum .martin_ruiz_spectral_modifier (
269
+ result = spectrum .martin_ruiz (
272
270
clearness_index ,
273
271
airmass_absolute ,
274
272
model_parameters = model_parameters )
@@ -287,7 +285,7 @@ def test_martin_ruiz_mm_model_df(martin_ruiz_mismatch_data):
287
285
'dir' : np .array (martin_ruiz_mismatch_data ['monosi_expected' ]['dir' ]),
288
286
'sky' : np .array (martin_ruiz_mismatch_data ['monosi_expected' ]['sky' ])})
289
287
290
- result = spectrum .martin_ruiz_spectral_modifier (
288
+ result = spectrum .martin_ruiz (
291
289
clearness_index ,
292
290
airmass_absolute ,
293
291
model_parameters = model_parameters )
@@ -296,44 +294,15 @@ def test_martin_ruiz_mm_model_df(martin_ruiz_mismatch_data):
296
294
assert result ['poa_ground_diffuse' ].isna ().all ()
297
295
298
296
299
- def test_martin_ruiz_mm_userwarning (martin_ruiz_mismatch_data ):
300
- # test warning is raised with both 'cell_type' and 'model_parameters'
301
- clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
302
- airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
303
- model_parameters = martin_ruiz_mismatch_data ['monosi_model_params_dict' ]
304
-
305
- with pytest .warns (UserWarning ,
306
- match = 'Both "cell_type" and "model_parameters" given. '
307
- 'Using provided "model_parameters".' ):
308
- _ = spectrum .martin_ruiz_spectral_modifier (
309
- clearness_index ,
310
- airmass_absolute ,
311
- cell_type = 'asi' ,
312
- model_parameters = model_parameters )
313
-
314
-
315
297
def test_martin_ruiz_mm_error_notimplemented (martin_ruiz_mismatch_data ):
316
- # test exception is raised when cell_type does not exist in algorithm
298
+ # test exception is raised when module_type does not exist in algorithm
317
299
clearness_index = np .array (martin_ruiz_mismatch_data ['clearness_index' ])
318
300
airmass_absolute = np .array (martin_ruiz_mismatch_data ['airmass_absolute' ])
319
301
320
302
with pytest .raises (NotImplementedError ,
321
303
match = 'Cell type parameters not defined in algorithm.' ):
322
- _ = spectrum .martin_ruiz_spectral_modifier (clearness_index ,
323
- airmass_absolute ,
324
- cell_type = '' )
325
-
326
-
327
- def test_martin_ruiz_mm_error_missing_params (martin_ruiz_mismatch_data ):
328
- # test exception is raised when missing cell_type and model_parameters
329
- clearness_index = np .array (martin_ruiz_mismatch_data ['clearness_index' ])
330
- airmass_absolute = np .array (martin_ruiz_mismatch_data ['airmass_absolute' ])
331
-
332
- with pytest .raises (TypeError ,
333
- match = 'You must pass at least "cell_type" '
334
- 'or "model_parameters" as arguments.' ):
335
- _ = spectrum .martin_ruiz_spectral_modifier (clearness_index ,
336
- airmass_absolute )
304
+ _ = spectrum .martin_ruiz (clearness_index , airmass_absolute ,
305
+ module_type = '' )
337
306
338
307
339
308
def test_martin_ruiz_mm_error_model_keys (martin_ruiz_mismatch_data ):
@@ -345,7 +314,30 @@ def test_martin_ruiz_mm_error_model_keys(martin_ruiz_mismatch_data):
345
314
with pytest .raises (ValueError ,
346
315
match = "You must specify model parameters with keys "
347
316
"'a','b','c' for each irradiation component." ):
348
- _ = spectrum .martin_ruiz_spectral_modifier (
349
- clearness_index ,
350
- airmass_absolute ,
351
- model_parameters = model_parameters )
317
+ _ = spectrum .martin_ruiz (clearness_index , airmass_absolute ,
318
+ model_parameters = model_parameters )
319
+
320
+
321
+ def test_martin_ruiz_mm_error_missing_params (martin_ruiz_mismatch_data ):
322
+ # test exception is raised when missing module_type and model_parameters
323
+ clearness_index = np .array (martin_ruiz_mismatch_data ['clearness_index' ])
324
+ airmass_absolute = np .array (martin_ruiz_mismatch_data ['airmass_absolute' ])
325
+
326
+ with pytest .raises (TypeError ,
327
+ match = 'You must pass at least "module_type" '
328
+ 'or "model_parameters" as arguments.' ):
329
+ _ = spectrum .martin_ruiz (clearness_index , airmass_absolute )
330
+
331
+
332
+ def test_martin_ruiz_mm_error_too_many_arguments (martin_ruiz_mismatch_data ):
333
+ # test warning is raised with both 'module_type' and 'model_parameters'
334
+ clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
335
+ airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
336
+ model_parameters = martin_ruiz_mismatch_data ['monosi_model_params_dict' ]
337
+
338
+ with pytest .raises (TypeError ,
339
+ match = 'Cannot resolve input: must supply only one of '
340
+ '"module_type" or "model_parameters"' ):
341
+ _ = spectrum .martin_ruiz (clearness_index , airmass_absolute ,
342
+ module_type = 'asi' ,
343
+ model_parameters = model_parameters )
0 commit comments