17
17
18
18
19
19
@pytest .fixture (scope = 'function' )
20
- def system (sapm_module_params , cec_inverter_parameters ,
21
- sapm_temperature_cs5p_220m ):
20
+ def sapm_dc_snl_ac_system (sapm_module_params , cec_inverter_parameters ,
21
+ sapm_temperature_cs5p_220m ):
22
22
module = 'Canadian_Solar_CS5P_220M___2009_'
23
23
module_parameters = sapm_module_params .copy ()
24
24
temp_model_params = sapm_temperature_cs5p_220m .copy ()
@@ -166,26 +166,26 @@ def weather():
166
166
return weather
167
167
168
168
169
- def test_ModelChain_creation (system , location ):
170
- ModelChain (system , location )
169
+ def test_ModelChain_creation (sapm_dc_snl_ac_system , location ):
170
+ ModelChain (sapm_dc_snl_ac_system , location )
171
171
172
172
173
173
@pytest .mark .parametrize ('strategy, expected' , [
174
174
(None , (32.2 , 180 )), ('None' , (32.2 , 180 )), ('flat' , (0 , 180 )),
175
175
('south_at_latitude_tilt' , (32.2 , 180 ))
176
176
])
177
- def test_orientation_strategy (strategy , expected , system , location ):
178
- mc = ModelChain (system , location , orientation_strategy = strategy )
177
+ def test_orientation_strategy (strategy , expected , sapm_dc_snl_ac_system , location ):
178
+ mc = ModelChain (sapm_dc_snl_ac_system , location , orientation_strategy = strategy )
179
179
180
180
# the || accounts for the coercion of 'None' to None
181
181
assert (mc .orientation_strategy == strategy or
182
182
mc .orientation_strategy is None )
183
- assert system .surface_tilt == expected [0 ]
184
- assert system .surface_azimuth == expected [1 ]
183
+ assert sapm_dc_snl_ac_system .surface_tilt == expected [0 ]
184
+ assert sapm_dc_snl_ac_system .surface_azimuth == expected [1 ]
185
185
186
186
187
- def test_run_model_with_irradiance (system , location ):
188
- mc = ModelChain (system , location )
187
+ def test_run_model_with_irradiance (sapm_dc_snl_ac_system , location ):
188
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
189
189
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
190
190
irradiance = pd .DataFrame ({'dni' : 900 , 'ghi' : 600 , 'dhi' : 150 },
191
191
index = times )
@@ -196,42 +196,42 @@ def test_run_model_with_irradiance(system, location):
196
196
assert_series_equal (ac , expected )
197
197
198
198
199
- def test_run_model_times (system , location ):
200
- mc = ModelChain (system , location )
199
+ def test_run_model_times (sapm_dc_snl_ac_system , location ):
200
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
201
201
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
202
202
irradiance = pd .DataFrame ({'dni' : 900 , 'ghi' : 600 , 'dhi' : 150 },
203
203
index = times )
204
204
with pytest .warns (pvlibDeprecationWarning ):
205
205
mc .run_model (irradiance , times = times )
206
206
207
207
208
- def test_prepare_inputs_times (system , location ):
209
- mc = ModelChain (system , location )
208
+ def test_prepare_inputs_times (sapm_dc_snl_ac_system , location ):
209
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
210
210
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
211
211
irradiance = pd .DataFrame ({'dni' : 900 , 'ghi' : 600 , 'dhi' : 150 },
212
212
index = times )
213
213
with pytest .warns (pvlibDeprecationWarning ):
214
214
mc .prepare_inputs (irradiance , times = times )
215
215
216
216
217
- def test_prepare_inputs_no_irradiance (system , location ):
218
- mc = ModelChain (system , location )
217
+ def test_prepare_inputs_no_irradiance (sapm_dc_snl_ac_system , location ):
218
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
219
219
weather = pd .DataFrame ()
220
220
with pytest .raises (ValueError ):
221
221
mc .prepare_inputs (weather )
222
222
223
223
224
224
@requires_tables
225
- def test_complete_irradiance_times (system , location ):
226
- mc = ModelChain (system , location )
225
+ def test_complete_irradiance_times (sapm_dc_snl_ac_system , location ):
226
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
227
227
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
228
228
irradiance = pd .DataFrame ({'ghi' : 600. , 'dhi' : 150. }, index = times )
229
229
with pytest .warns (pvlibDeprecationWarning ):
230
230
mc .complete_irradiance (irradiance , times = times )
231
231
232
232
233
- def test_run_model_perez (system , location ):
234
- mc = ModelChain (system , location , transposition_model = 'perez' )
233
+ def test_run_model_perez (sapm_dc_snl_ac_system , location ):
234
+ mc = ModelChain (sapm_dc_snl_ac_system , location , transposition_model = 'perez' )
235
235
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
236
236
irradiance = pd .DataFrame ({'dni' : 900 , 'ghi' : 600 , 'dhi' : 150 },
237
237
index = times )
@@ -242,8 +242,8 @@ def test_run_model_perez(system, location):
242
242
assert_series_equal (ac , expected )
243
243
244
244
245
- def test_run_model_gueymard_perez (system , location ):
246
- mc = ModelChain (system , location , airmass_model = 'gueymard1993' ,
245
+ def test_run_model_gueymard_perez (sapm_dc_snl_ac_system , location ):
246
+ mc = ModelChain (sapm_dc_snl_ac_system , location , airmass_model = 'gueymard1993' ,
247
247
transposition_model = 'perez' )
248
248
times = pd .date_range ('20160101 1200-0700' , periods = 2 , freq = '6H' )
249
249
irradiance = pd .DataFrame ({'dni' : 900 , 'ghi' : 600 , 'dhi' : 150 },
@@ -255,15 +255,15 @@ def test_run_model_gueymard_perez(system, location):
255
255
assert_series_equal (ac , expected )
256
256
257
257
258
- def test_run_model_with_weather_sapm_temp (system , location , weather , mocker ):
258
+ def test_run_model_with_weather_sapm_temp (sapm_dc_snl_ac_system , location , weather , mocker ):
259
259
# test with sapm cell temperature model
260
260
weather ['wind_speed' ] = 5
261
261
weather ['temp_air' ] = 10
262
- system .racking_model = 'open_rack'
263
- system .module_type = 'glass_glass'
264
- mc = ModelChain (system , location )
262
+ sapm_dc_snl_ac_system .racking_model = 'open_rack'
263
+ sapm_dc_snl_ac_system .module_type = 'glass_glass'
264
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
265
265
mc .temperature_model = 'sapm'
266
- m_sapm = mocker .spy (system , 'sapm_celltemp' )
266
+ m_sapm = mocker .spy (sapm_dc_snl_ac_system , 'sapm_celltemp' )
267
267
mc .run_model (weather )
268
268
assert m_sapm .call_count == 1
269
269
# assert_called_once_with cannot be used with series, so need to use
@@ -273,43 +273,43 @@ def test_run_model_with_weather_sapm_temp(system, location, weather, mocker):
273
273
assert not mc .ac .empty
274
274
275
275
276
- def test_run_model_with_weather_pvsyst_temp (system , location , weather , mocker ):
276
+ def test_run_model_with_weather_pvsyst_temp (sapm_dc_snl_ac_system , location , weather , mocker ):
277
277
# test with pvsyst cell temperature model
278
278
weather ['wind_speed' ] = 5
279
279
weather ['temp_air' ] = 10
280
- system .racking_model = 'freestanding'
281
- system .temperature_model_parameters = \
280
+ sapm_dc_snl_ac_system .racking_model = 'freestanding'
281
+ sapm_dc_snl_ac_system .temperature_model_parameters = \
282
282
temperature ._temperature_model_params ('pvsyst' , 'freestanding' )
283
- mc = ModelChain (system , location )
283
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
284
284
mc .temperature_model = 'pvsyst'
285
- m_pvsyst = mocker .spy (system , 'pvsyst_celltemp' )
285
+ m_pvsyst = mocker .spy (sapm_dc_snl_ac_system , 'pvsyst_celltemp' )
286
286
mc .run_model (weather )
287
287
assert m_pvsyst .call_count == 1
288
288
assert_series_equal (m_pvsyst .call_args [0 ][1 ], weather ['temp_air' ])
289
289
assert_series_equal (m_pvsyst .call_args [0 ][2 ], weather ['wind_speed' ])
290
290
assert not mc .ac .empty
291
291
292
292
293
- def test_run_model_with_weather_faiman_temp (system , location , weather , mocker ):
293
+ def test_run_model_with_weather_faiman_temp (sapm_dc_snl_ac_system , location , weather , mocker ):
294
294
# test with faiman cell temperature model
295
295
weather ['wind_speed' ] = 5
296
296
weather ['temp_air' ] = 10
297
- system .temperature_model_parameters = {'u0' : 25.0 , 'u1' : 6.84 }
298
- mc = ModelChain (system , location )
297
+ sapm_dc_snl_ac_system .temperature_model_parameters = {'u0' : 25.0 , 'u1' : 6.84 }
298
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
299
299
mc .temperature_model = 'faiman'
300
- m_faiman = mocker .spy (system , 'faiman_celltemp' )
300
+ m_faiman = mocker .spy (sapm_dc_snl_ac_system , 'faiman_celltemp' )
301
301
mc .run_model (weather )
302
302
assert m_faiman .call_count == 1
303
303
assert_series_equal (m_faiman .call_args [0 ][1 ], weather ['temp_air' ])
304
304
assert_series_equal (m_faiman .call_args [0 ][2 ], weather ['wind_speed' ])
305
305
assert not mc .ac .empty
306
306
307
307
308
- def test_run_model_tracker (system , location , weather , mocker ):
308
+ def test_run_model_tracker (sapm_dc_snl_ac_system , location , weather , mocker ):
309
309
system = SingleAxisTracker (
310
- module_parameters = system .module_parameters ,
311
- temperature_model_parameters = system .temperature_model_parameters ,
312
- inverter_parameters = system .inverter_parameters )
310
+ module_parameters = sapm_dc_snl_ac_system .module_parameters ,
311
+ temperature_model_parameters = sapm_dc_snl_ac_system .temperature_model_parameters ,
312
+ inverter_parameters = sapm_dc_snl_ac_system .inverter_parameters )
313
313
mocker .spy (system , 'singleaxis' )
314
314
mc = ModelChain (system , location )
315
315
mc .run_model (weather )
@@ -332,10 +332,10 @@ def poadc(mc):
332
332
pytest .param ('pvsyst' , marks = requires_scipy ),
333
333
pytest .param ('singlediode' , marks = requires_scipy ),
334
334
'pvwatts_dc' ])
335
- def test_infer_dc_model (system , cec_dc_snl_ac_system , pvsyst_dc_snl_ac_system ,
335
+ def test_infer_dc_model (sapm_dc_snl_ac_system , cec_dc_snl_ac_system , pvsyst_dc_snl_ac_system ,
336
336
pvwatts_dc_pvwatts_ac_system , location , dc_model ,
337
337
weather , mocker ):
338
- dc_systems = {'sapm' : system ,
338
+ dc_systems = {'sapm' : sapm_dc_snl_ac_system ,
339
339
'cec' : cec_dc_snl_ac_system ,
340
340
'desoto' : cec_dc_snl_ac_system ,
341
341
'pvsyst' : pvsyst_dc_snl_ac_system ,
@@ -374,9 +374,9 @@ def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system,
374
374
'sapm' ,
375
375
pytest .param ('cec' , marks = requires_scipy ),
376
376
pytest .param ('cec_native' , marks = requires_scipy )])
377
- def test_infer_spectral_model (location , system , cec_dc_snl_ac_system ,
377
+ def test_infer_spectral_model (location , sapm_dc_snl_ac_system , cec_dc_snl_ac_system ,
378
378
cec_dc_native_snl_ac_system , dc_model ):
379
- dc_systems = {'sapm' : system ,
379
+ dc_systems = {'sapm' : sapm_dc_snl_ac_system ,
380
380
'cec' : cec_dc_snl_ac_system ,
381
381
'cec_native' : cec_dc_native_snl_ac_system }
382
382
system = dc_systems [dc_model ]
@@ -388,11 +388,11 @@ def test_infer_spectral_model(location, system, cec_dc_snl_ac_system,
388
388
@pytest .mark .parametrize ('temp_model' , [
389
389
'sapm_temp' , 'faiman_temp' ,
390
390
pytest .param ('pvsyst_temp' , marks = requires_scipy )])
391
- def test_infer_temp_model (location , system ,
391
+ def test_infer_temp_model (location , sapm_dc_snl_ac_system ,
392
392
pvwatts_dc_pvwatts_ac_pvsyst_temp_system ,
393
393
pvwatts_dc_pvwatts_ac_faiman_temp_system ,
394
394
temp_model ):
395
- dc_systems = {'sapm_temp' : system ,
395
+ dc_systems = {'sapm_temp' : sapm_dc_snl_ac_system ,
396
396
'pvsyst_temp' : pvwatts_dc_pvwatts_ac_pvsyst_temp_system ,
397
397
'faiman_temp' : pvwatts_dc_pvwatts_ac_faiman_temp_system }
398
398
system = dc_systems [temp_model ]
@@ -404,17 +404,17 @@ def test_infer_temp_model(location, system,
404
404
405
405
406
406
@requires_scipy
407
- def test_infer_temp_model_invalid (location , system ):
408
- system .temperature_model_parameters .pop ('a' )
407
+ def test_infer_temp_model_invalid (location , sapm_dc_snl_ac_system ):
408
+ sapm_dc_snl_ac_system .temperature_model_parameters .pop ('a' )
409
409
with pytest .raises (ValueError ):
410
- ModelChain (system , location , orientation_strategy = 'None' ,
410
+ ModelChain (sapm_dc_snl_ac_system , location , orientation_strategy = 'None' ,
411
411
aoi_model = 'physical' , spectral_model = 'no_loss' )
412
412
413
413
414
414
@requires_scipy
415
- def test_temperature_model_inconsistent (location , system ):
415
+ def test_temperature_model_inconsistent (location , sapm_dc_snl_ac_system ):
416
416
with pytest .raises (ValueError ):
417
- ModelChain (system , location , orientation_strategy = 'None' ,
417
+ ModelChain (sapm_dc_snl_ac_system , location , orientation_strategy = 'None' ,
418
418
aoi_model = 'physical' , spectral_model = 'no_loss' ,
419
419
temperature_model = 'pvsyst' )
420
420
@@ -437,9 +437,9 @@ def acdc(mc):
437
437
@pytest .mark .parametrize ('ac_model' , [
438
438
'snlinverter' , pytest .param ('adrinverter' , marks = requires_scipy ),
439
439
'pvwatts' ])
440
- def test_ac_models (system , cec_dc_adr_ac_system , pvwatts_dc_pvwatts_ac_system ,
440
+ def test_ac_models (sapm_dc_snl_ac_system , cec_dc_adr_ac_system , pvwatts_dc_pvwatts_ac_system ,
441
441
location , ac_model , weather , mocker ):
442
- ac_systems = {'snlinverter' : system , 'adrinverter' : cec_dc_adr_ac_system ,
442
+ ac_systems = {'snlinverter' : sapm_dc_snl_ac_system , 'adrinverter' : cec_dc_adr_ac_system ,
443
443
'pvwatts' : pvwatts_dc_pvwatts_ac_system }
444
444
system = ac_systems [ac_model ]
445
445
@@ -473,10 +473,10 @@ def constant_aoi_loss(mc):
473
473
@pytest .mark .parametrize ('aoi_model' , [
474
474
'sapm' , 'ashrae' , 'physical' , 'martin_ruiz'
475
475
])
476
- def test_aoi_models (system , location , aoi_model , weather , mocker ):
477
- mc = ModelChain (system , location , dc_model = 'sapm' ,
476
+ def test_aoi_models (sapm_dc_snl_ac_system , location , aoi_model , weather , mocker ):
477
+ mc = ModelChain (sapm_dc_snl_ac_system , location , dc_model = 'sapm' ,
478
478
aoi_model = aoi_model , spectral_model = 'no_loss' )
479
- m = mocker .spy (system , 'get_iam' )
479
+ m = mocker .spy (sapm_dc_snl_ac_system , 'get_iam' )
480
480
mc .run_model (weather = weather )
481
481
assert m .call_count == 1
482
482
assert isinstance (mc .ac , pd .Series )
@@ -485,8 +485,8 @@ def test_aoi_models(system, location, aoi_model, weather, mocker):
485
485
assert mc .ac [1 ] < 1
486
486
487
487
488
- def test_aoi_model_no_loss (system , location , weather ):
489
- mc = ModelChain (system , location , dc_model = 'sapm' ,
488
+ def test_aoi_model_no_loss (sapm_dc_snl_ac_system , location , weather ):
489
+ mc = ModelChain (sapm_dc_snl_ac_system , location , dc_model = 'sapm' ,
490
490
aoi_model = 'no_loss' , spectral_model = 'no_loss' )
491
491
mc .run_model (weather )
492
492
assert mc .aoi_modifier == 1.0
@@ -495,9 +495,9 @@ def test_aoi_model_no_loss(system, location, weather):
495
495
assert mc .ac [1 ] < 1
496
496
497
497
498
- def test_aoi_model_user_func (system , location , weather , mocker ):
498
+ def test_aoi_model_user_func (sapm_dc_snl_ac_system , location , weather , mocker ):
499
499
m = mocker .spy (sys .modules [__name__ ], 'constant_aoi_loss' )
500
- mc = ModelChain (system , location , dc_model = 'sapm' ,
500
+ mc = ModelChain (sapm_dc_snl_ac_system , location , dc_model = 'sapm' ,
501
501
aoi_model = constant_aoi_loss , spectral_model = 'no_loss' )
502
502
mc .run_model (weather )
503
503
assert m .call_count == 1
@@ -534,10 +534,10 @@ def constant_spectral_loss(mc):
534
534
@pytest .mark .parametrize ('spectral_model' , [
535
535
'sapm' , 'first_solar' , 'no_loss' , constant_spectral_loss
536
536
])
537
- def test_spectral_models (system , location , spectral_model , weather ):
537
+ def test_spectral_models (sapm_dc_snl_ac_system , location , spectral_model , weather ):
538
538
# add pw to weather dataframe
539
539
weather ['precipitable_water' ] = [0.3 , 0.5 ]
540
- mc = ModelChain (system , location , dc_model = 'sapm' ,
540
+ mc = ModelChain (sapm_dc_snl_ac_system , location , dc_model = 'sapm' ,
541
541
aoi_model = 'no_loss' , spectral_model = spectral_model )
542
542
spectral_modifier = mc .run_model (weather ).spectral_modifier
543
543
assert isinstance (spectral_modifier , (pd .Series , float , int ))
@@ -596,14 +596,14 @@ def test_losses_models_no_loss(pvwatts_dc_pvwatts_ac_system, location, weather,
596
596
assert mc .losses == 1
597
597
598
598
599
- def test_invalid_dc_model_params (system , cec_dc_snl_ac_system ,
599
+ def test_invalid_dc_model_params (sapm_dc_snl_ac_system , cec_dc_snl_ac_system ,
600
600
pvwatts_dc_pvwatts_ac_system , location ):
601
601
kwargs = {'dc_model' : 'sapm' , 'ac_model' : 'snlinverter' ,
602
602
'aoi_model' : 'no_loss' , 'spectral_model' : 'no_loss' ,
603
603
'temperature_model' : 'sapm' , 'losses_model' : 'no_loss' }
604
- system .module_parameters .pop ('A0' ) # remove a parameter
604
+ sapm_dc_snl_ac_system .module_parameters .pop ('A0' ) # remove a parameter
605
605
with pytest .raises (ValueError ):
606
- ModelChain (system , location , ** kwargs )
606
+ ModelChain (sapm_dc_snl_ac_system , location , ** kwargs )
607
607
608
608
kwargs ['dc_model' ] = 'singlediode'
609
609
cec_dc_snl_ac_system .module_parameters .pop ('a_ref' ) # remove a parameter
@@ -621,13 +621,13 @@ def test_invalid_dc_model_params(system, cec_dc_snl_ac_system,
621
621
'dc_model' , 'ac_model' , 'aoi_model' , 'spectral_model' ,
622
622
'temperature_model' , 'losses_model'
623
623
])
624
- def test_invalid_models (model , system , location ):
624
+ def test_invalid_models (model , sapm_dc_snl_ac_system , location ):
625
625
kwargs = {'dc_model' : 'pvwatts' , 'ac_model' : 'pvwatts' ,
626
626
'aoi_model' : 'no_loss' , 'spectral_model' : 'no_loss' ,
627
627
'temperature_model' : 'sapm' , 'losses_model' : 'no_loss' }
628
628
kwargs [model ] = 'invalid'
629
629
with pytest .raises (ValueError ):
630
- ModelChain (system , location , ** kwargs )
630
+ ModelChain (sapm_dc_snl_ac_system , location , ** kwargs )
631
631
632
632
633
633
def test_bad_get_orientation ():
@@ -766,9 +766,9 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters,
766
766
@pytest .mark .parametrize ('strategy, strategy_str' , [
767
767
('south_at_latitude_tilt' , 'south_at_latitude_tilt' ),
768
768
(None , 'None' )]) # GitHub issue 352
769
- def test_ModelChain___repr__ (system , location , strategy , strategy_str ):
769
+ def test_ModelChain___repr__ (sapm_dc_snl_ac_system , location , strategy , strategy_str ):
770
770
771
- mc = ModelChain (system , location , orientation_strategy = strategy ,
771
+ mc = ModelChain (sapm_dc_snl_ac_system , location , orientation_strategy = strategy ,
772
772
name = 'my mc' )
773
773
774
774
expected = '\n ' .join ([
@@ -791,9 +791,9 @@ def test_ModelChain___repr__(system, location, strategy, strategy_str):
791
791
792
792
793
793
@requires_scipy
794
- def test_complete_irradiance_clean_run (system , location ):
794
+ def test_complete_irradiance_clean_run (sapm_dc_snl_ac_system , location ):
795
795
"""The DataFrame should not change if all columns are passed"""
796
- mc = ModelChain (system , location )
796
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
797
797
times = pd .date_range ('2010-07-05 9:00:00' , periods = 2 , freq = 'H' )
798
798
i = pd .DataFrame (
799
799
{'dni' : [2 , 3 ], 'dhi' : [4 , 6 ], 'ghi' : [9 , 5 ]}, index = times )
@@ -809,9 +809,9 @@ def test_complete_irradiance_clean_run(system, location):
809
809
810
810
811
811
@requires_scipy
812
- def test_complete_irradiance (system , location ):
812
+ def test_complete_irradiance (sapm_dc_snl_ac_system , location ):
813
813
"""Check calculations"""
814
- mc = ModelChain (system , location )
814
+ mc = ModelChain (sapm_dc_snl_ac_system , location )
815
815
times = pd .date_range ('2010-07-05 7:00:00-0700' , periods = 2 , freq = 'H' )
816
816
i = pd .DataFrame ({'dni' : [49.756966 , 62.153947 ],
817
817
'ghi' : [372.103976116 , 497.087579068 ],
0 commit comments