@@ -50,6 +50,7 @@ def test_pvefficiency_adr_round_trip():
5050
5151
5252def 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
7577def 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