Skip to content

Commit a773130

Browse files
committed
make optional in PVSystem and ModelChain as well
1 parent 37d3fcc commit a773130

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

pvlib/modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def infer_dc_model(self):
611611
"""Infer DC power model from Array module parameters."""
612612
params = _common_keys(
613613
tuple(array.module_parameters for array in self.system.arrays))
614-
if {'A0', 'A1', 'C7'} <= params:
614+
if {'A0', 'A1', 'C3'} <= params:
615615
return self.sapm, 'sapm'
616616
elif {'a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref', 'R_s',
617617
'Adjust'} <= params:

pvlib/pvsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# a dict of required parameter names for each DC power model
3030
_DC_MODEL_PARAMS = {
3131
'sapm': {
32-
'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7',
32+
'C0', 'C1', 'C2', 'C3', # C4-C7 (i_x and i_xx params) not required
3333
'Isco', 'Impo', 'Voco', 'Vmpo', 'Aisc', 'Aimp', 'Bvoco',
3434
'Mbvoc', 'Bvmpo', 'Mbvmp', 'N', 'Cells_in_Series',
3535
'IXO', 'IXXO'},

tests/test_modelchain.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,16 @@ def test_invalid_dc_model_params(sapm_dc_snl_ac_system, cec_dc_snl_ac_system,
17621762
ModelChain(pvwatts_dc_pvwatts_ac_system, location, **kwargs)
17631763

17641764

1765+
def test_sapm_optional_params(sapm_dc_snl_ac_system, location):
1766+
# inference works when the optional (i_x, i_xx) SAPM parameters are missing
1767+
for array in sapm_dc_snl_ac_system.arrays:
1768+
for key in ['C4', 'C5', 'C6', 'C7']:
1769+
array.module_parameters.pop(key)
1770+
1771+
# no error:
1772+
ModelChain(sapm_dc_snl_ac_system, location)
1773+
1774+
17651775
@pytest.mark.parametrize('model', [
17661776
'dc_model', 'ac_model', 'aoi_model', 'spectral_model',
17671777
'temperature_model', 'losses_model'

0 commit comments

Comments
 (0)