diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 07c466783c..aeb600b100 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -163,6 +163,8 @@ Bug fixes * Fix floating point round-off issue in :py:func:`~pvlib.irradiance.aoi_projection` (:issue:`1185`, :pull:`1191`) * Update GFS product names for GFS v16. (:issue:`1202`, :pull:`1203`) +* Take into account ``EgRef``, ``dEgdT``, ``irrad_ref`` and ``temp_ref`` when + calling :py:func:`~pvlib.pvsystem.calcparams_cec`. (:issue:`1215`, :pull:`1216`) * Corrected methodology error in :py:func:`~pvlib.scaling.wvm`. Tracks with fix in PVLib for MATLAB. (:issue:`1206`, :pull:`1213`) @@ -197,5 +199,6 @@ Contributors * Joshua Stein (:ghuser:`jsstein`) * Tony Lorenzo (:ghuser:`alorenzo175`) * Damjan Postolovski (:ghuser:`dpostolovski`) +* Miguel Sánchez de León Peque (:ghuser:`Peque`) * Joe Ranalli (:ghuser:`jranalli`) * Chas Schweizer (:ghuser:`cpr-chas`) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 43b856b903..06230d6c95 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1994,8 +1994,8 @@ def calcparams_cec(effective_irradiance, temp_cell, alpha_sc*(1.0 - Adjust/100), a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s, - EgRef=1.121, dEgdT=-0.0002677, - irrad_ref=1000, temp_ref=25) + EgRef=EgRef, dEgdT=dEgdT, + irrad_ref=irrad_ref, temp_ref=temp_ref) def calcparams_pvsyst(effective_irradiance, temp_cell, diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index d0abdefd4b..4533e58567 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -792,6 +792,43 @@ def test_calcparams_cec(cec_module_params): check_less_precise=3) +def test_calcparams_cec_extra_params_propagation(cec_module_params, mocker): + """ + See bug #1215. + + When calling `calcparams_cec`, the parameters `EgRef`, `dEgdT`, `irrad_ref` + and `temp_ref` must not be ignored. + + Since, internally, this function is calling `calcparams_desoto`, this test + checks that the latter is called with the expected parameters instead of + some default values. + """ + times = pd.date_range(start='2015-01-01', periods=3, freq='12H') + effective_irradiance = pd.Series([0.0, 800.0, 800.0], index=times) + temp_cell = pd.Series([25, 25, 50], index=times) + extra_parameters = dict( + EgRef=1.123, + dEgdT=-0.0002688, + irrad_ref=1100, + temp_ref=23, + ) + m = mocker.spy(pvsystem, 'calcparams_desoto') + pvsystem.calcparams_cec( + effective_irradiance=effective_irradiance, + temp_cell=temp_cell, + alpha_sc=cec_module_params['alpha_sc'], + a_ref=cec_module_params['a_ref'], + I_L_ref=cec_module_params['I_L_ref'], + I_o_ref=cec_module_params['I_o_ref'], + R_sh_ref=cec_module_params['R_sh_ref'], + R_s=cec_module_params['R_s'], + Adjust=cec_module_params['Adjust'], + **extra_parameters, + ) + assert m.call_count == 1 + assert m.call_args[1] == extra_parameters + + def test_calcparams_pvsyst(pvsyst_module_params): times = pd.date_range(start='2015-01-01', periods=2, freq='12H') effective_irradiance = pd.Series([0.0, 800.0], index=times)