@@ -176,7 +176,7 @@ def test_calc_spectral_mismatch_field(spectrl2_data):
176176
177177@pytest .fixture
178178def martin_ruiz_mismatch_data ():
179- # Data to run tests of martin_ruiz_spectral_modifier
179+ # Data to run tests of spectrum.martin_ruiz
180180 kwargs = {
181181 'clearness_index' : [0.56 , 0.612 , 0.664 , 0.716 , 0.768 , 0.82 ],
182182 'airmass_absolute' : [2 , 1.8 , 1.6 , 1.4 , 1.2 , 1 ],
@@ -205,12 +205,12 @@ def martin_ruiz_mismatch_data():
205205
206206
207207def 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
209209 clearness_index = martin_ruiz_mismatch_data ['clearness_index' ][0 ]
210210 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' )
214214
215215 assert_approx_equal (result ['poa_direct' ],
216216 martin_ruiz_mismatch_data ['asi_expected' ]['dir' ][0 ],
@@ -224,31 +224,29 @@ def test_martin_ruiz_mm_scalar(martin_ruiz_mismatch_data):
224224
225225
226226def 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
228228 clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
229229 airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
230230 expected = pd .DataFrame (data = {
231231 'dir' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['dir' ]),
232232 'sky' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['sky' ]),
233233 'gnd' : pd .Series (martin_ruiz_mismatch_data ['polysi_expected' ]['gnd' ])})
234234
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' )
238237 assert_allclose (result ['poa_direct' ], expected ['dir' ], atol = 1e-5 )
239238 assert_allclose (result ['poa_sky_diffuse' ], expected ['sky' ], atol = 1e-5 )
240239 assert_allclose (result ['poa_ground_diffuse' ], expected ['gnd' ], atol = 1e-5 )
241240
242241
243242def 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
245244 clearness_index = pd .Series (martin_ruiz_mismatch_data ['clearness_index' ])
246245 airmass_absolute = pd .Series (martin_ruiz_mismatch_data ['airmass_absolute' ])
247246 airmass_absolute [:5 ] = np .nan
248247
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' )
252250 assert np .isnan (result ['poa_direct' ][:5 ]).all ()
253251 assert not np .isnan (result ['poa_direct' ][5 :]).any ()
254252 assert np .isnan (result ['poa_sky_diffuse' ][:5 ]).all ()
@@ -268,7 +266,7 @@ def test_martin_ruiz_mm_model_dict(martin_ruiz_mismatch_data):
268266 'gnd' : pd .Series (martin_ruiz_mismatch_data ['monosi_expected' ]['gnd' ])})
269267 model_parameters = martin_ruiz_mismatch_data ['monosi_model_params_dict' ]
270268
271- result = spectrum .martin_ruiz_spectral_modifier (
269+ result = spectrum .martin_ruiz (
272270 clearness_index ,
273271 airmass_absolute ,
274272 model_parameters = model_parameters )
@@ -287,7 +285,7 @@ def test_martin_ruiz_mm_model_df(martin_ruiz_mismatch_data):
287285 'dir' : np .array (martin_ruiz_mismatch_data ['monosi_expected' ]['dir' ]),
288286 'sky' : np .array (martin_ruiz_mismatch_data ['monosi_expected' ]['sky' ])})
289287
290- result = spectrum .martin_ruiz_spectral_modifier (
288+ result = spectrum .martin_ruiz (
291289 clearness_index ,
292290 airmass_absolute ,
293291 model_parameters = model_parameters )
@@ -296,44 +294,15 @@ def test_martin_ruiz_mm_model_df(martin_ruiz_mismatch_data):
296294 assert result ['poa_ground_diffuse' ].isna ().all ()
297295
298296
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-
315297def 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
317299 clearness_index = np .array (martin_ruiz_mismatch_data ['clearness_index' ])
318300 airmass_absolute = np .array (martin_ruiz_mismatch_data ['airmass_absolute' ])
319301
320302 with pytest .raises (NotImplementedError ,
321303 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 = '' )
337306
338307
339308def 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):
345314 with pytest .raises (ValueError ,
346315 match = "You must specify model parameters with keys "
347316 "'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