55library. With great power comes great responsibility: users should take
66the time to read the source code for the module.
77"""
8-
98from functools import partial
109import itertools
1110import warnings
1211import pandas as pd
1312from dataclasses import dataclass , field
1413from typing import Union , Tuple , Optional , TypeVar
15-
1614from pvlib import pvsystem , iam
1715import pvlib .irradiance # avoid name conflict with full import
1816from pvlib .pvsystem import _DC_MODEL_PARAMS
1917from pvlib .tools import _build_kwargs
20-
2118from pvlib ._deprecation import deprecated
2219# Keys used to detect input data and assign values to the appropriate
2320# ModelChain attributes.
24-
25- #: tuple[str]
26- #: Weather-related input columns used by :class:`ModelChain` to populate
27- #: ``ModelChain.weather``. Missing ``temp_air`` or ``wind_speed`` are
28- #: automatically filled (20 °C and 0 m/s).
21+ # Weather-related input columns for ModelChain.weather
2922WEATHER_KEYS = (
3023 'ghi' , # Global Horizontal Irradiance (W/m^2)
3124 'dhi' , # Diffuse Horizontal Irradiance (W/m^2)
3427 'temp_air' , # Ambient air temperature (°C)
3528 'precipitable_water' # Column precipitable water (cm)
3629)
37-
38- #: tuple[str]
39- #: Plane-of-array irradiance components used to populate
40- #: ``ModelChain.total_irrad`` when running from POA input.
30+ # Plane-of-array irradiance input columns for ModelChain.total_irrad
4131POA_KEYS = (
4232 'poa_global' , # Total plane-of-array irradiance (W/m^2)
4333 'poa_direct' , # Direct POA irradiance (W/m^2)
4434 'poa_diffuse' # Diffuse POA irradiance (W/m^2)
4535)
46-
47- #: tuple[str]
48- #: Temperature-related input columns that override or supplement the
49- #: ModelChain temperature model. If ``cell_temperature`` is provided,
50- #: the temperature model is skipped.
36+ # Temperature-related optional input columns for ModelChain
5137TEMPERATURE_KEYS = (
5238 'module_temperature' , # Back-surface module temperature (°C)
5339 'cell_temperature' , # Direct cell temperature input (°C)
5440)
55- #: tuple[str]
56- #: All supported input keys recognized by ModelChain.
41+ # All supported input keys combined
5742DATA_KEYS = WEATHER_KEYS + POA_KEYS + TEMPERATURE_KEYS
5843# these dictionaries contain the default configuration for following
5944# established modeling sequences. They can be used in combination with
6045# ModelChain, particularly they are used by the methods
6146# ModelChain.with_pvwatts, ModelChain.with_sapm, etc.
62-
6347# pvwatts documentation states that it uses the following reference for
6448# a temperature model: Fuentes, M. K. (1987). A Simplified Thermal Model
6549# for Flat-Plate Photovoltaic Arrays. SAND85-0330. Albuquerque, NM:
@@ -1730,6 +1714,27 @@ def run_model_from_poa(self, data):
17301714 of Arrays in the PVSystem.
17311715 ValueError
17321716 If the DataFrames in `data` have different indexes.
1717+ Examples
1718+ --------
1719+ Single-array system:
1720+
1721+ >>> import pandas as pd
1722+ >>> from pvlib.pvsystem import PVSystem
1723+ >>> from pvlib.location import Location
1724+ >>> from pvlib.modelchain import ModelChain
1725+ >>>
1726+ >>> system = PVSystem(module_parameters={'pdc0': 300})
1727+ >>> location = Location(35, -110)
1728+ >>> mc = ModelChain(system, location)
1729+ >>>
1730+ >>> poa = pd.DataFrame({
1731+ ... 'poa_global': [900, 850],
1732+ ... 'poa_direct': [600, 560],
1733+ ... 'poa_diffuse': [300, 290],
1734+ ... }, index=pd.date_range("2021-06-01", periods=2, freq="H"))
1735+ >>>
1736+ >>> mc.run_model_from_poa(poa)
1737+ <pvlib.modelchain.ModelChain ...>
17331738
17341739 Notes
17351740 -----
@@ -1755,7 +1760,6 @@ def run_model_from_poa(self, data):
17551760 self ._run_from_effective_irrad (data )
17561761
17571762 return self
1758-
17591763 def _run_from_effective_irrad (self , data ):
17601764 """
17611765 Executes the temperature, DC, losses and AC models.
@@ -1774,7 +1778,7 @@ def _run_from_effective_irrad(self, data):
17741778
17751779 Notes
17761780 -----
1777- Assigns attributes:``cell_temperature``, ``dc`` , ``ac`` , ``losses``,
1781+ Assigns attributes:``cell_temperature, 'dc' , ``ac' , ``losses``,
17781782 ``diode_params`` (if dc_model is a single diode model).
17791783 """
17801784 self ._prepare_temperature (data )
@@ -1815,6 +1819,25 @@ def run_model_from_effective_irradiance(self, data):
18151819 of Arrays in the PVSystem.
18161820 ValueError
18171821 If the DataFrames in `data` have different indexes.
1822+ Examples
1823+ --------
1824+ >>> import pandas as pd
1825+ >>> from pvlib.pvsystem import PVSystem
1826+ >>> from pvlib.location import Location
1827+ >>> from pvlib.modelchain import ModelChain
1828+ >>>
1829+ >>> system = PVSystem(module_parameters={'pdc0': 300})
1830+ >>> location = Location(35, -110)
1831+ >>> mc = ModelChain(system, location)
1832+ >>>
1833+ >>> eff = pd.DataFrame({
1834+ ... 'effective_irradiance': [900, 920],
1835+ ... 'temp_air': [25, 24],
1836+ ... 'wind_speed': [2.0, 1.5],
1837+ ... })
1838+ >>>
1839+ >>> mc.run_model_from_effective_irradiance(eff)
1840+ <pvlib.modelchain.ModelChain ...>
18181841
18191842 Notes
18201843 -----
@@ -1853,6 +1876,7 @@ def run_model_from_effective_irradiance(self, data):
18531876 return self
18541877
18551878
1879+
18561880def _irrad_for_celltemp (total_irrad , effective_irradiance ):
18571881 """
18581882 Determine irradiance to use for cell temperature models, in order
0 commit comments