Skip to content

Commit 93e8404

Browse files
authored
Deprecate modelchain.basic_chain (#1401)
* deprecate basic_chain * whatsnew * stickler * also recommend with_sapm
1 parent 9a6f76e commit 93e8404

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

docs/sphinx/source/whatsnew/v0.9.1.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Breaking changes
88

99
Deprecations
1010
~~~~~~~~~~~~
11+
* :py:func:`pvlib.modelchain.basic_chain` is deprecated.
12+
See :py:meth:`pvlib.modelchain.ModelChain.with_pvwatts` and
13+
:py:meth:`pvlib.modelchain.ModelChain.with_sapm` for alternative simplified
14+
:py:class:`~pvlib.modelchain.ModelChain` interfaces, although note that the
15+
inputs do not directly translate. (:pull:`1401`)
1116

1217
Enhancements
1318
~~~~~~~~~~~~

pvlib/modelchain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from pvlib._deprecation import pvlibDeprecationWarning
2222
from pvlib.tools import _build_kwargs
2323

24+
from pvlib._deprecation import deprecated
25+
2426
# keys that are used to detect input data and assign data to appropriate
2527
# ModelChain attribute
2628
# for ModelChain.weather
@@ -62,6 +64,13 @@
6264
)
6365

6466

67+
@deprecated(
68+
since='0.9.1',
69+
name='pvlib.modelchain.basic_chain',
70+
alternative=('pvlib.modelchain.ModelChain.with_pvwatts'
71+
' or pvlib.modelchain.ModelChain.with_sapm'),
72+
addendum='Note that the with_xyz methods take different model parameters.'
73+
)
6574
def basic_chain(times, latitude, longitude,
6675
surface_tilt, surface_azimuth,
6776
module_parameters, temperature_model_parameters,

pvlib/tests/test_modelchain.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,10 +1799,11 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
17991799
modules = sam_data['sandiamod']
18001800
module_parameters = modules['Canadian_Solar_CS5P_220M___2009_']
18011801
temp_model_params = sapm_temperature_cs5p_220m.copy()
1802-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1803-
surface_tilt, surface_azimuth,
1804-
module_parameters, temp_model_params,
1805-
cec_inverter_parameters)
1802+
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
1803+
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1804+
surface_tilt, surface_azimuth,
1805+
module_parameters, temp_model_params,
1806+
cec_inverter_parameters)
18061807

18071808
expected = pd.Series(np.array([111.621405, -2.00000000e-02]),
18081809
index=times)
@@ -1821,21 +1822,23 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters,
18211822
modules = sam_data['sandiamod']
18221823
module_parameters = modules['Canadian_Solar_CS5P_220M___2009_']
18231824
temp_model_params = sapm_temperature_cs5p_220m.copy()
1824-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1825-
surface_tilt, surface_azimuth,
1826-
module_parameters, temp_model_params,
1827-
cec_inverter_parameters,
1828-
pressure=93194)
1825+
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
1826+
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1827+
surface_tilt, surface_azimuth,
1828+
module_parameters, temp_model_params,
1829+
cec_inverter_parameters,
1830+
pressure=93194)
18291831

18301832
expected = pd.Series(np.array([113.190045, -2.00000000e-02]),
18311833
index=times)
18321834
assert_series_equal(ac, expected)
18331835

1834-
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1835-
surface_tilt, surface_azimuth,
1836-
module_parameters, temp_model_params,
1837-
cec_inverter_parameters,
1838-
altitude=altitude)
1836+
with pytest.warns(pvlibDeprecationWarning, match='with_pvwatts'):
1837+
dc, ac = modelchain.basic_chain(times, latitude, longitude,
1838+
surface_tilt, surface_azimuth,
1839+
module_parameters, temp_model_params,
1840+
cec_inverter_parameters,
1841+
altitude=altitude)
18391842

18401843
expected = pd.Series(np.array([113.189814, -2.00000000e-02]),
18411844
index=times)

0 commit comments

Comments
 (0)