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 3 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` 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
~~~~~~~~~~~~
Expand Down
8 changes: 8 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,12 @@
)


@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,
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 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)
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 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)
Expand Down