From af31f395b3bc8f086e0e3b418c3bd3bb3f83df68 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 9 Feb 2022 16:58:49 -0500 Subject: [PATCH 1/4] deprecate basic_chain --- pvlib/modelchain.py | 6 ++++++ pvlib/tests/test_modelchain.py | 31 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index eb0db817fd..6d00568d7c 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -21,6 +21,8 @@ from pvlib._deprecation import pvlibDeprecationWarning from pvlib.tools import _build_kwargs +from pvlib._deprecation import deprecated + # keys that are used to detect input data and assign data to appropriate # ModelChain attribute # for ModelChain.weather @@ -62,6 +64,10 @@ ) +@deprecated(since='0.9.1', name='pvlib.modelchain.basic_chain', + alternative='pvlib.modelchain.ModelChain.with_pvwatts', + addendum='Note that with_pvwatts takes different model parameters.' +) def basic_chain(times, latitude, longitude, surface_tilt, surface_azimuth, module_parameters, temperature_model_parameters, diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index 17887dc693..fbd8a07a75 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -1799,10 +1799,11 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters, modules = sam_data['sandiamod'] module_parameters = modules['Canadian_Solar_CS5P_220M___2009_'] temp_model_params = sapm_temperature_cs5p_220m.copy() - dc, ac = modelchain.basic_chain(times, latitude, longitude, - surface_tilt, surface_azimuth, - module_parameters, temp_model_params, - cec_inverter_parameters) + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + dc, ac = modelchain.basic_chain(times, latitude, longitude, + surface_tilt, surface_azimuth, + module_parameters, temp_model_params, + cec_inverter_parameters) expected = pd.Series(np.array([111.621405, -2.00000000e-02]), index=times) @@ -1821,21 +1822,23 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters, modules = sam_data['sandiamod'] module_parameters = modules['Canadian_Solar_CS5P_220M___2009_'] temp_model_params = sapm_temperature_cs5p_220m.copy() - dc, ac = modelchain.basic_chain(times, latitude, longitude, - surface_tilt, surface_azimuth, - module_parameters, temp_model_params, - cec_inverter_parameters, - pressure=93194) + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + dc, ac = modelchain.basic_chain(times, latitude, longitude, + surface_tilt, surface_azimuth, + module_parameters, temp_model_params, + cec_inverter_parameters, + pressure=93194) expected = pd.Series(np.array([113.190045, -2.00000000e-02]), index=times) assert_series_equal(ac, expected) - dc, ac = modelchain.basic_chain(times, latitude, longitude, - surface_tilt, surface_azimuth, - module_parameters, temp_model_params, - cec_inverter_parameters, - altitude=altitude) + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + dc, ac = modelchain.basic_chain(times, latitude, longitude, + surface_tilt, surface_azimuth, + module_parameters, temp_model_params, + cec_inverter_parameters, + altitude=altitude) expected = pd.Series(np.array([113.189814, -2.00000000e-02]), index=times) From 5c376f019962ef7c03ff2a3f056b82cdfbc4b933 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 9 Feb 2022 16:58:55 -0500 Subject: [PATCH 2/4] whatsnew --- docs/sphinx/source/whatsnew/v0.9.1.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.9.1.rst b/docs/sphinx/source/whatsnew/v0.9.1.rst index 5ff19a4fd5..42cc7421a2 100644 --- a/docs/sphinx/source/whatsnew/v0.9.1.rst +++ b/docs/sphinx/source/whatsnew/v0.9.1.rst @@ -8,6 +8,11 @@ Breaking changes Deprecations ~~~~~~~~~~~~ +* :py:func:`pvlib.modelchain.basic_chain` is deprecated. + See :py:meth:`pvlib.modelchain.ModelChain.with_pvwatts` for a simplified + :py:class:`~pvlib.modelchain.ModelChain` interface, although note that the + model parameters for :py:func:`~pvlib.modelchain.basic_chain` do not directly + translate. (:pull:`1401`) Enhancements ~~~~~~~~~~~~ From 2bac39bc9e73c5d980126bd873e04a72d4947351 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 9 Feb 2022 17:15:09 -0500 Subject: [PATCH 3/4] stickler --- pvlib/modelchain.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index 6d00568d7c..1beb106284 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -64,7 +64,9 @@ ) -@deprecated(since='0.9.1', name='pvlib.modelchain.basic_chain', +@deprecated( + since='0.9.1', + name='pvlib.modelchain.basic_chain', alternative='pvlib.modelchain.ModelChain.with_pvwatts', addendum='Note that with_pvwatts takes different model parameters.' ) From bfc43d4487d5fb0f1e978f4a78544a9071448c3b Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 16 Feb 2022 12:12:14 -0500 Subject: [PATCH 4/4] also recommend with_sapm --- docs/sphinx/source/whatsnew/v0.9.1.rst | 8 ++++---- pvlib/modelchain.py | 5 +++-- pvlib/tests/test_modelchain.py | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.1.rst b/docs/sphinx/source/whatsnew/v0.9.1.rst index 42cc7421a2..3d9b7d47cf 100644 --- a/docs/sphinx/source/whatsnew/v0.9.1.rst +++ b/docs/sphinx/source/whatsnew/v0.9.1.rst @@ -9,10 +9,10 @@ Breaking changes Deprecations ~~~~~~~~~~~~ * :py:func:`pvlib.modelchain.basic_chain` is deprecated. - See :py:meth:`pvlib.modelchain.ModelChain.with_pvwatts` for a simplified - :py:class:`~pvlib.modelchain.ModelChain` interface, although note that the - model parameters for :py:func:`~pvlib.modelchain.basic_chain` do not directly - translate. (:pull:`1401`) + See :py:meth:`pvlib.modelchain.ModelChain.with_pvwatts` and + :py:meth:`pvlib.modelchain.ModelChain.with_sapm` for alternative simplified + :py:class:`~pvlib.modelchain.ModelChain` interfaces, although note that the + inputs do not directly translate. (:pull:`1401`) Enhancements ~~~~~~~~~~~~ diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index 1beb106284..d26c5f790e 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -67,8 +67,9 @@ @deprecated( since='0.9.1', name='pvlib.modelchain.basic_chain', - alternative='pvlib.modelchain.ModelChain.with_pvwatts', - addendum='Note that with_pvwatts takes different model parameters.' + alternative=('pvlib.modelchain.ModelChain.with_pvwatts' + ' or pvlib.modelchain.ModelChain.with_sapm'), + addendum='Note that the with_xyz methods take different model parameters.' ) def basic_chain(times, latitude, longitude, surface_tilt, surface_azimuth, diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index fbd8a07a75..f4a92eadad 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -1799,7 +1799,7 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters, modules = sam_data['sandiamod'] module_parameters = modules['Canadian_Solar_CS5P_220M___2009_'] temp_model_params = sapm_temperature_cs5p_220m.copy() - with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'): dc, ac = modelchain.basic_chain(times, latitude, longitude, surface_tilt, surface_azimuth, module_parameters, temp_model_params, @@ -1822,7 +1822,7 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters, modules = sam_data['sandiamod'] module_parameters = modules['Canadian_Solar_CS5P_220M___2009_'] temp_model_params = sapm_temperature_cs5p_220m.copy() - with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'): dc, ac = modelchain.basic_chain(times, latitude, longitude, surface_tilt, surface_azimuth, module_parameters, temp_model_params, @@ -1833,7 +1833,7 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters, index=times) assert_series_equal(ac, expected) - with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts instead'): + with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'): dc, ac = modelchain.basic_chain(times, latitude, longitude, surface_tilt, surface_azimuth, module_parameters, temp_model_params,