Skip to content

Commit b68c936

Browse files
committed
Fixed indentation in run_model_from_poa function
1 parent f6709d0 commit b68c936

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

pvlib/modelchain.py

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,20 @@
55
library. With great power comes great responsibility: users should take
66
the time to read the source code for the module.
77
"""
8-
98
from functools import partial
109
import itertools
1110
import warnings
1211
import pandas as pd
1312
from dataclasses import dataclass, field
1413
from typing import Union, Tuple, Optional, TypeVar
15-
1614
from pvlib import pvsystem, iam
1715
import pvlib.irradiance # avoid name conflict with full import
1816
from pvlib.pvsystem import _DC_MODEL_PARAMS
1917
from pvlib.tools import _build_kwargs
20-
2118
from 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
2922
WEATHER_KEYS = (
3023
'ghi', # Global Horizontal Irradiance (W/m^2)
3124
'dhi', # Diffuse Horizontal Irradiance (W/m^2)
@@ -34,32 +27,23 @@
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
4131
POA_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
5137
TEMPERATURE_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
5742
DATA_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+
18561880
def _irrad_for_celltemp(total_irrad, effective_irradiance):
18571881
"""
18581882
Determine irradiance to use for cell temperature models, in order

0 commit comments

Comments
 (0)