Skip to content

Commit 89727f3

Browse files
committed
change parameter key to pvgis5, etc.
1 parent 8b41911 commit 89727f3

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

pvlib/pvarray.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,16 @@ def _infer_k_huld(cell_type, pdc0, k_version):
249249
# equation that has factored Pdc0 out of the polynomial:
250250
# P = G/1000 * Pdc0 * (1 + k1 log(Geff) + ...) so these parameters are
251251
# multiplied by pdc0
252-
if k_version == '2011':
252+
if k_version.lower() == 'pvgis5':
253+
# coefficients from PVGIS webpage
253254
huld_params = {'csi': (-0.017237, -0.040465, -0.004702, 0.000149,
254255
0.000170, 0.000005),
255256
'cis': (-0.005554, -0.038724, -0.003723, -0.000905,
256257
-0.001256, 0.000001),
257258
'cdte': (-0.046689, -0.072844, -0.002262, 0.000276,
258259
0.000159, -0.000006)}
259-
elif k_version == '2025':
260-
# Updated coefficients from EU JRC paper
260+
elif k_version.lower() == 'pvgis6':
261+
# Coefficients from EU JRC paper
261262
huld_params = {'csi': (-0.0067560, -0.016444, -0.003015, -0.000045,
262263
-0.000043, 0.0),
263264
'cis': (-0.011001, -0.029734, -0.002887, 0.000217,
@@ -272,7 +273,7 @@ def _infer_k_huld(cell_type, pdc0, k_version):
272273

273274

274275
def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None,
275-
k_version='2011'):
276+
k_version='pvgis5'):
276277
r"""
277278
Power (DC) using the Huld model.
278279
@@ -305,10 +306,10 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None,
305306
If provided, must be one of ``'cSi'``, ``'CIS'``, or ``'CdTe'``.
306307
Used to look up default values for ``k`` if ``k`` is not specified.
307308
k_version : str, optional
308-
Either ``'2011'`` (default) or ``'2025'``. Selects values
309-
for ``k`` if ``k`` is not specified. If ``'2011'``, values are
310-
from PVGIS documentation and are published in [2]_ as "current".
311-
If ``'2025'`` values are from [2]_ published as "updated".
309+
Either ``'pvgis5'`` (default) or ``'pvgis6'``. Selects values
310+
for ``k`` if ``k`` is not specified. If ``'pvgis5'``, values are
311+
from PVGIS documentation and are labeled in [2]_ as "current".
312+
If ``'pvgis6'`` values are from [2]_ labeled as "updated".
312313
313314
Returns
314315
-------

tests/test_pvarray.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_pvefficiency_adr_round_trip():
5050

5151

5252
def test_huld():
53+
# tests with default k_version='pvgis5'
5354
pdc0 = 100
5455
res = pvarray.huld(1000, 25, pdc0, cell_type='cSi')
5556
assert np.isclose(res, pdc0)
@@ -68,8 +69,9 @@ def test_huld():
6869
res = pvarray.huld(eff_irr, tm, pdc0, k=(1, 1, 1, 1, 1, 1))
6970
assert_series_equal(res, expected)
7071
with pytest.raises(ValueError,
71-
match='Either k or cell_type must be specified'):
72-
res = pvarray.huld(1000, 25, 100)
72+
match='Either k or cell_type must be specified'
73+
):
74+
pvarray.huld(1000, 25, 100)
7375

7476

7577
def test_huld_params():
@@ -79,26 +81,35 @@ def test_huld_params():
7981
eff_irr = 800 # W/m^2 (not 1000)
8082
temp_mod = 35 # deg C (not 25)
8183
# calculated by C. Hansen using Excel, 2025
82-
expected = {'2011': {'csi': 76.405089,
83-
'cis': 77.086016,
84-
'cdte': 78.642762
85-
},
86-
'2025': {'csi': 77.649421,
87-
'cis': 77.723110,
88-
'cdte': 77.500399
89-
}
84+
expected = {'pvgis5': {'csi': 76.405089,
85+
'cis': 77.086016,
86+
'cdte': 78.642762
87+
},
88+
'pvgis6': {'csi': 77.649421,
89+
'cis': 77.723110,
90+
'cdte': 77.500399
91+
}
9092
}
91-
# Test with 2011 coefficients for all cell types
93+
# Test with PVGIS5 coefficients for all cell types
9294
for yr in expected:
9395
for cell_type in expected[yr]:
9496
result = pvarray.huld(eff_irr, temp_mod, pdc0, cell_type=cell_type,
9597
k_version=yr)
9698
assert np.isclose(result, expected[yr][cell_type])
97-
# Check errors for incorrect cell_type and incorrect k_version
99+
100+
101+
def test_huld_errors():
102+
# Check errors
103+
pdc0 = 100
104+
# Use non-reference values so coefficients affect the result
105+
eff_irr = 800 # W/m^2 (not 1000)
106+
temp_mod = 35 # deg C (not 25)
107+
# provide both cell_type and k_version
98108
with pytest.raises(KeyError):
99109
pvarray.huld(
100-
eff_irr, temp_mod, pdc0, cell_type='invalid', k_version='2011'
110+
eff_irr, temp_mod, pdc0, cell_type='invalid', k_version='pvgis5'
101111
)
112+
# provide invalid k_version
102113
with pytest.raises(ValueError, match='Invalid k_version=2021'):
103114
pvarray.huld(
104115
eff_irr, temp_mod, pdc0, cell_type='csi', k_version='2021'

0 commit comments

Comments
 (0)