Skip to content

Deprecate modelchain.basic_chain #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Breaking changes

Deprecations
~~~~~~~~~~~~
* :py:func:`pvlib.modelchain.basic_chain` is deprecated.
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
~~~~~~~~~~~~
Expand Down
9 changes: 9 additions & 0 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,6 +64,13 @@
)


@deprecated(
since='0.9.1',
name='pvlib.modelchain.basic_chain',
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,
module_parameters, temperature_model_parameters,
Expand Down
31 changes: 17 additions & 14 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
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)
Expand All @@ -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'):
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'):
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)
Expand Down