Skip to content

Commit c9dc7fe

Browse files
Pequecwhanse
authored andcommitted
refactor cec test data into fixtures (#774)
Refactors module and inverter parameter sets used for tests into conftest.py. Parameter sets are hardcoded rather than read from the current version of the SAM data files, since the values in the SAM files may not be stable. Thanks @Peque
1 parent b4238be commit c9dc7fe

File tree

5 files changed

+353
-194
lines changed

5 files changed

+353
-194
lines changed

pvlib/test/conftest.py

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,203 @@ def has_numba():
149149

150150
requires_pvfactors = pytest.mark.skipif(not has_pvfactors,
151151
reason='requires pvfactors')
152+
153+
154+
@pytest.fixture(scope="session")
155+
def sam_data():
156+
data = {}
157+
data['sandiamod'] = pvlib.pvsystem.retrieve_sam('sandiamod')
158+
data['adrinverter'] = pvlib.pvsystem.retrieve_sam('adrinverter')
159+
return data
160+
161+
162+
@pytest.fixture(scope="function")
163+
def pvsyst_module_params():
164+
"""
165+
Define some PVSyst module parameters for testing.
166+
167+
The scope of the fixture is set to ``'function'`` to allow tests to modify
168+
parameters if required without affecting other tests.
169+
"""
170+
parameters = {
171+
'gamma_ref': 1.05,
172+
'mu_gamma': 0.001,
173+
'I_L_ref': 6.0,
174+
'I_o_ref': 5e-9,
175+
'EgRef': 1.121,
176+
'R_sh_ref': 300,
177+
'R_sh_0': 1000,
178+
'R_s': 0.5,
179+
'R_sh_exp': 5.5,
180+
'cells_in_series': 60,
181+
'alpha_sc': 0.001,
182+
}
183+
return parameters
184+
185+
186+
@pytest.fixture(scope='function')
187+
def cec_inverter_parameters():
188+
"""
189+
Define some CEC inverter parameters for testing.
190+
191+
The scope of the fixture is set to ``'function'`` to allow tests to modify
192+
parameters if required without affecting other tests.
193+
"""
194+
parameters = {
195+
'Name': 'ABB: MICRO-0.25-I-OUTD-US-208 208V [CEC 2014]',
196+
'Vac': 208.0,
197+
'Paco': 250.0,
198+
'Pdco': 259.5220505,
199+
'Vdco': 40.24260317,
200+
'Pso': 1.771614224,
201+
'C0': -2.48e-5,
202+
'C1': -9.01e-5,
203+
'C2': 6.69e-4,
204+
'C3': -0.0189,
205+
'Pnt': 0.02,
206+
'Vdcmax': 65.0,
207+
'Idcmax': 10.0,
208+
'Mppt_low': 20.0,
209+
'Mppt_high': 50.0,
210+
}
211+
return parameters
212+
213+
214+
@pytest.fixture(scope='function')
215+
def cec_module_params():
216+
"""
217+
Define some CEC module parameters for testing.
218+
219+
The scope of the fixture is set to ``'function'`` to allow tests to modify
220+
parameters if required without affecting other tests.
221+
"""
222+
parameters = {
223+
'Name': 'Example Module',
224+
'BIPV': 'Y',
225+
'Date': '4/28/2008',
226+
'T_NOCT': 65,
227+
'A_c': 0.67,
228+
'N_s': 18,
229+
'I_sc_ref': 7.5,
230+
'V_oc_ref': 10.4,
231+
'I_mp_ref': 6.6,
232+
'V_mp_ref': 8.4,
233+
'alpha_sc': 0.003,
234+
'beta_oc': -0.04,
235+
'a_ref': 0.473,
236+
'I_L_ref': 7.545,
237+
'I_o_ref': 1.94e-09,
238+
'R_s': 0.094,
239+
'R_sh_ref': 15.72,
240+
'Adjust': 10.6,
241+
'gamma_r': -0.5,
242+
'Version': 'MM105',
243+
'PTC': 48.9,
244+
'Technology': 'Multi-c-Si',
245+
}
246+
return parameters
247+
248+
249+
@pytest.fixture(scope='function')
250+
def cec_module_cs5p_220m():
251+
"""
252+
Define Canadian Solar CS5P-220M module parameters for testing.
253+
254+
The scope of the fixture is set to ``'function'`` to allow tests to modify
255+
parameters if required without affecting other tests.
256+
"""
257+
parameters = {
258+
'Name': 'Canadian Solar CS5P-220M',
259+
'BIPV': 'N',
260+
'Date': '10/5/2009',
261+
'T_NOCT': 42.4,
262+
'A_c': 1.7,
263+
'N_s': 96,
264+
'I_sc_ref': 5.1,
265+
'V_oc_ref': 59.4,
266+
'I_mp_ref': 4.69,
267+
'V_mp_ref': 46.9,
268+
'alpha_sc': 0.004539,
269+
'beta_oc': -0.22216,
270+
'a_ref': 2.6373,
271+
'I_L_ref': 5.114,
272+
'I_o_ref': 8.196e-10,
273+
'R_s': 1.065,
274+
'R_sh_ref': 381.68,
275+
'Adjust': 8.7,
276+
'gamma_r': -0.476,
277+
'Version': 'MM106',
278+
'PTC': 200.1,
279+
'Technology': 'Mono-c-Si',
280+
}
281+
return parameters
282+
283+
284+
@pytest.fixture(scope='function')
285+
def cec_module_spr_e20_327():
286+
"""
287+
Define SunPower SPR-E20-327 module parameters for testing.
288+
289+
The scope of the fixture is set to ``'function'`` to allow tests to modify
290+
parameters if required without affecting other tests.
291+
"""
292+
parameters = {
293+
'Name': 'SunPower SPR-E20-327',
294+
'BIPV': 'N',
295+
'Date': '1/14/2013',
296+
'T_NOCT': 46,
297+
'A_c': 1.631,
298+
'N_s': 96,
299+
'I_sc_ref': 6.46,
300+
'V_oc_ref': 65.1,
301+
'I_mp_ref': 5.98,
302+
'V_mp_ref': 54.7,
303+
'alpha_sc': 0.004522,
304+
'beta_oc': -0.23176,
305+
'a_ref': 2.6868,
306+
'I_L_ref': 6.468,
307+
'I_o_ref': 1.88e-10,
308+
'R_s': 0.37,
309+
'R_sh_ref': 298.13,
310+
'Adjust': -0.1862,
311+
'gamma_r': -0.386,
312+
'Version': 'NRELv1',
313+
'PTC': 301.4,
314+
'Technology': 'Mono-c-Si',
315+
}
316+
return parameters
317+
318+
319+
@pytest.fixture(scope='function')
320+
def cec_module_fs_495():
321+
"""
322+
Define First Solar FS-495 module parameters for testing.
323+
324+
The scope of the fixture is set to ``'function'`` to allow tests to modify
325+
parameters if required without affecting other tests.
326+
"""
327+
parameters = {
328+
'Name': 'First Solar FS-495',
329+
'BIPV': 'N',
330+
'Date': '9/18/2014',
331+
'T_NOCT': 44.6,
332+
'A_c': 0.72,
333+
'N_s': 216,
334+
'I_sc_ref': 1.55,
335+
'V_oc_ref': 86.5,
336+
'I_mp_ref': 1.4,
337+
'V_mp_ref': 67.9,
338+
'alpha_sc': 0.000924,
339+
'beta_oc': -0.22741,
340+
'a_ref': 2.9482,
341+
'I_L_ref': 1.563,
342+
'I_o_ref': 2.64e-13,
343+
'R_s': 6.804,
344+
'R_sh_ref': 806.27,
345+
'Adjust': -10.65,
346+
'gamma_r': -0.264,
347+
'Version': 'NRELv1',
348+
'PTC': 89.7,
349+
'Technology': 'CdTe',
350+
}
351+
return parameters

0 commit comments

Comments
 (0)