Skip to content

Commit 37d3fcc

Browse files
committed
make C4-C7 optional in pvlib.pvsystem.sapm
1 parent d62b9b1 commit 37d3fcc

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

pvlib/pvsystem.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,9 +2224,11 @@ def sapm(effective_irradiance, temp_cell, module):
22242224
* v_mp : Voltage at maximum-power point (V)
22252225
* p_mp : Power at maximum-power point (W)
22262226
* i_x : Current at module V = 0.5Voc, defines 4th point on I-V
2227-
curve for modeling curve shape
2227+
curve for modeling curve shape. Omitted if ``C4`` and ``C5``
2228+
parameters are not supplied.
22282229
* i_xx : Current at module V = 0.5(Voc+Vmp), defines 5th point on
2229-
I-V curve for modeling curve shape
2230+
I-V curve for modeling curve shape. Omitted if ``C6`` and ``C7``
2231+
parameters are not supplied.
22302232
22312233
Notes
22322234
-----
@@ -2334,13 +2336,15 @@ def sapm(effective_irradiance, temp_cell, module):
23342336

23352337
out['p_mp'] = out['i_mp'] * out['v_mp']
23362338

2337-
out['i_x'] = (
2338-
module['IXO'] * (module['C4']*Ee + module['C5']*(Ee**2)) *
2339-
(1 + module['Aisc']*(temp_cell - temp_ref)))
2339+
if 'C4' in module and 'C5' in module:
2340+
out['i_x'] = (
2341+
module['IXO'] * (module['C4']*Ee + module['C5']*(Ee**2)) *
2342+
(1 + module['Aisc']*(temp_cell - temp_ref)))
23402343

2341-
out['i_xx'] = (
2342-
module['IXXO'] * (module['C6']*Ee + module['C7']*(Ee**2)) *
2343-
(1 + module['Aimp']*(temp_cell - temp_ref)))
2344+
if 'C6' in module and 'C7' in module:
2345+
out['i_xx'] = (
2346+
module['IXXO'] * (module['C6']*Ee + module['C7']*(Ee**2)) *
2347+
(1 + module['Aimp']*(temp_cell - temp_ref)))
23442348

23452349
if isinstance(out['i_sc'], pd.Series):
23462350
out = pd.DataFrame(out)

tests/test_pvsystem.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ def test_sapm(sapm_module_params):
197197
pvsystem.sapm(effective_irradiance, temp_cell,
198198
pd.Series(sapm_module_params))
199199

200+
# ensure C4-C7 are optional
201+
optional_keys = ['C4', 'C5', 'C6', 'C7']
202+
params_no_c4c7 = {
203+
k: v for k, v in sapm_module_params.items() if k not in optional_keys
204+
}
205+
out = pvsystem.sapm(effective_irradiance, temp_cell, params_no_c4c7)
206+
assert 'i_x' not in out.keys()
207+
assert 'i_xx' not in out.keys()
208+
200209

201210
def test_PVSystem_sapm(sapm_module_params, mocker):
202211
mocker.spy(pvsystem, 'sapm')

0 commit comments

Comments
 (0)