From f0e700c3a1fb65acaa4174a9040c7f13fb2b2570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20S=C3=A1nchez=20de=20Le=C3=B3n=20Peque?= Date: Wed, 5 May 2021 19:39:53 +0200 Subject: [PATCH 1/2] Propagate parameters on `calcparams_cec` call (#1215) --- docs/sphinx/source/whatsnew/v0.9.0.rst | 4 +++ pvlib/pvsystem.py | 4 +-- pvlib/tests/test_pvsystem.py | 37 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index d50ed7f3e5..0bb76c03b1 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -117,6 +117,9 @@ Bug fixes * Reindl model fixed to generate sky_diffuse=0 when GHI=0. (:issue:`1153`, :pull:`1154`) * 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`) Testing ~~~~~~~ @@ -150,3 +153,4 @@ Contributors * Joshua Stein (:ghuser:`jsstein`) * Tony Lorenzo (:ghuser:`alorenzo175`) * Damjan Postolovski (:ghuser:`dpostolovski`) +* Miguel Sánchez de León Peque (:ghuser:`Peque`) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index f6901617c3..adef4982bd 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1851,8 +1851,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 2d20660b98..f66fce50b2 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -807,6 +807,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) From fa434f07891c181ed5d140404ebf9245da3bfaed Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 27 May 2021 10:18:07 -0600 Subject: [PATCH 2/2] Update v0.9.0.rst Remove mistaken text --- docs/sphinx/source/whatsnew/v0.9.0.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.0.rst b/docs/sphinx/source/whatsnew/v0.9.0.rst index 216936b352..aeb600b100 100644 --- a/docs/sphinx/source/whatsnew/v0.9.0.rst +++ b/docs/sphinx/source/whatsnew/v0.9.0.rst @@ -164,8 +164,7 @@ Bug fixes :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` from - :py:meth:`~pvlib.pvsystem.PVSystem.calcparams_cec`. (:issue:`1215`, :pull:`1216`) + 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`)