Skip to content

Remove deprecated basic_chain method #1862

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 7 commits into from
May 26, 2024
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
1 change: 0 additions & 1 deletion docs/sphinx/source/reference/modelchain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ Functions for power modeling.
.. autosummary::
:toctree: generated/

modelchain.basic_chain
modelchain.get_orientation
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ v0.11.0 (Anticipated June, 2024)

Breaking changes
~~~~~~~~~~~~~~~~
* Remove the function and all its reference `poa_horizontal_ratio`. (:issue:`1697`, :pull:`2021`)
* The deprecated ``pvlib.modelchain.basic_chain`` has now been removed. (:pull:`1862`)
* Remove the `poa_horizontal_ratio` function and all of its references. (:issue:`1697`, :pull:`2021`)


Deprecations
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.9.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Breaking changes
* The ``orientation_strategy`` parameter has been removed from the various
:py:class:`pvlib.modelchain.ModelChain` constructors and ``surface_tilt``,
``surface_azimuth`` are now required parameters for
:py:func:`pvlib.modelchain.basic_chain` (:issue:`1028`, :pull:`1181`)
``pvlib.modelchain.basic_chain`` (:issue:`1028`, :pull:`1181`)

* Removed the ``**kwargs`` parameters from :py:meth:`~pvlib.pvsystem.PVSystem.sapm` and
:py:meth:`~pvlib.pvsystem.PVSystem.calcparams_desoto` and
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.9.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Deprecations
* Moved :py:func:`pvlib.bifacial.pvfactors_timeseries` to
:py:func:`pvlib.bifacial.pvfactors.pvfactors_timeseries`.
:py:mod:`pvlib.bifacial` is now a sub-package. (:pull:`717`)
* :py:func:`pvlib.modelchain.basic_chain` is deprecated.
* ``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
Expand Down
167 changes: 2 additions & 165 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
from dataclasses import dataclass, field
from typing import Union, Tuple, Optional, TypeVar

from pvlib import (atmosphere, clearsky, inverter, pvsystem, solarposition,
temperature, iam)
from pvlib import pvsystem, iam
import pvlib.irradiance # avoid name conflict with full import
from pvlib.pvsystem import _DC_MODEL_PARAMS
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 All @@ -41,7 +38,7 @@

# these dictionaries contain the default configuration for following
# established modeling sequences. They can be used in combination with
# basic_chain and ModelChain. They are used by the ModelChain methods
# ModelChain, particularly they are used by the methods
# ModelChain.with_pvwatts, ModelChain.with_sapm, etc.

# pvwatts documentation states that it uses the following reference for
Expand All @@ -62,165 +59,6 @@
)


@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,
inverter_parameters,
irradiance=None, weather=None,
transposition_model='haydavies',
solar_position_method='nrel_numpy',
airmass_model='kastenyoung1989',
altitude=None, pressure=None,
**kwargs):
"""
An experimental function that computes all of the modeling steps
necessary for calculating power or energy for a PV system at a given
location.

Parameters
----------
times : DatetimeIndex
Times at which to evaluate the model.

latitude : float.
Positive is north of the equator.
Use decimal degrees notation.

longitude : float.
Positive is east of the prime meridian.
Use decimal degrees notation.

surface_tilt : numeric
Surface tilt angles in decimal degrees.
The tilt angle is defined as degrees from horizontal
(e.g. surface facing up = 0, surface facing horizon = 90)

surface_azimuth : numeric
Surface azimuth angles in decimal degrees.
The azimuth convention is defined
as degrees east of north
(North=0, South=180, East=90, West=270).

module_parameters : dict or Series
Module parameters as defined by the SAPM. See pvsystem.sapm for
details.

temperature_model_parameters : dict or Series
Temperature model parameters as defined by the SAPM.
See temperature.sapm_cell for details.

inverter_parameters : dict or Series
Inverter parameters as defined by the CEC. See
:py:func:`inverter.sandia` for details.

irradiance : DataFrame, optional
If not specified, calculates clear sky data.
Columns must be 'dni', 'ghi', 'dhi'.

weather : DataFrame, optional
If not specified, assumes air temperature is 20 C and
wind speed is 0 m/s.
Columns must be 'wind_speed', 'temp_air'.

transposition_model : str, default 'haydavies'
Passed to system.get_irradiance.

solar_position_method : str, default 'nrel_numpy'
Passed to solarposition.get_solarposition.

airmass_model : str, default 'kastenyoung1989'
Passed to atmosphere.relativeairmass.

altitude : float, optional
If not specified, computed from ``pressure``. Assumed to be 0 m
if ``pressure`` is also unspecified.

pressure : float, optional
If not specified, computed from ``altitude``. Assumed to be 101325 Pa
if ``altitude`` is also unspecified.

**kwargs
Arbitrary keyword arguments.
See code for details.

Returns
-------
output : (dc, ac)
Tuple of DC power (with SAPM parameters) (DataFrame) and AC
power (Series).
"""

if altitude is None and pressure is None:
altitude = 0.
pressure = 101325.
elif altitude is None:
altitude = atmosphere.pres2alt(pressure)
elif pressure is None:
pressure = atmosphere.alt2pres(altitude)

solar_position = solarposition.get_solarposition(
times, latitude, longitude, altitude=altitude, pressure=pressure,
method=solar_position_method, **kwargs)

# possible error with using apparent zenith with some models
airmass = atmosphere.get_relative_airmass(
solar_position['apparent_zenith'], model=airmass_model)
airmass = atmosphere.get_absolute_airmass(airmass, pressure)
dni_extra = pvlib.irradiance.get_extra_radiation(solar_position.index)

aoi = pvlib.irradiance.aoi(surface_tilt, surface_azimuth,
solar_position['apparent_zenith'],
solar_position['azimuth'])

if irradiance is None:
linke_turbidity = clearsky.lookup_linke_turbidity(
solar_position.index, latitude, longitude)
irradiance = clearsky.ineichen(
solar_position['apparent_zenith'],
airmass,
linke_turbidity,
altitude=altitude,
dni_extra=dni_extra
)

total_irrad = pvlib.irradiance.get_total_irradiance(
surface_tilt,
surface_azimuth,
solar_position['apparent_zenith'],
solar_position['azimuth'],
irradiance['dni'],
irradiance['ghi'],
irradiance['dhi'],
model=transposition_model,
dni_extra=dni_extra)

if weather is None:
weather = {'wind_speed': 0, 'temp_air': 20}

cell_temperature = temperature.sapm_cell(
total_irrad['poa_global'], weather['temp_air'], weather['wind_speed'],
temperature_model_parameters['a'], temperature_model_parameters['b'],
temperature_model_parameters['deltaT'])

effective_irradiance = pvsystem.sapm_effective_irradiance(
total_irrad['poa_direct'], total_irrad['poa_diffuse'], airmass, aoi,
module_parameters)

dc = pvsystem.sapm(effective_irradiance, cell_temperature,
module_parameters)

ac = inverter.sandia(dc['v_mp'], dc['p_mp'], inverter_parameters)

return dc, ac


def get_orientation(strategy, **kwargs):
"""
Determine a PV system's surface tilt and surface azimuth
Expand All @@ -238,7 +76,6 @@ def get_orientation(strategy, **kwargs):
-------
surface_tilt, surface_azimuth
"""

if strategy == 'south_at_latitude_tilt':
surface_azimuth = 180
surface_tilt = kwargs['latitude']
Expand Down
57 changes: 0 additions & 57 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1787,63 +1787,6 @@ def test_ModelChain_no_extra_kwargs(sapm_dc_snl_ac_system, location):
ModelChain(sapm_dc_snl_ac_system, location, arbitrary_kwarg='value')


def test_basic_chain_alt_az(sam_data, cec_inverter_parameters,
sapm_temperature_cs5p_220m):
times = pd.date_range(start='20160101 1200-0700',
end='20160101 1800-0700', freq='6h')
latitude = 32.2
longitude = -111
surface_tilt = 0
surface_azimuth = 0
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'):
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)
assert_series_equal(ac, expected)


def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters,
sapm_temperature_cs5p_220m):
times = pd.date_range(start='20160101 1200-0700',
end='20160101 1800-0700', freq='6h')
latitude = 32.2
longitude = -111
altitude = 700
surface_tilt = 0
surface_azimuth = 0
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'):
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)

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)
assert_series_equal(ac, expected)


def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location):
"""The DataFrame should not change if all columns are passed"""
mc = ModelChain(sapm_dc_snl_ac_system, location)
Expand Down
Loading