Skip to content

Commit 83237b2

Browse files
committed
Fixed indentation in run_model_from_poa function
1 parent 25db27c commit 83237b2

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

pvlib/modelchain.py

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
from pvlib.tools import _build_kwargs
2020

2121
from pvlib._deprecation import deprecated
22+
2223
# Keys used to detect input data and assign values to the appropriate
2324
# ModelChain attributes.
2425

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).
26+
# Weather-related input columns for ModelChain.weather
2927
WEATHER_KEYS = (
3028
'ghi', # Global Horizontal Irradiance (W/m^2)
3129
'dhi', # Diffuse Horizontal Irradiance (W/m^2)
@@ -35,26 +33,22 @@
3533
'precipitable_water' # Column precipitable water (cm)
3634
)
3735

38-
#: tuple[str]
39-
#: Plane-of-array irradiance components used to populate
40-
#: ``ModelChain.total_irrad`` when running from POA input.
36+
# Plane-of-array irradiance input columns for ModelChain.total_irrad
4137
POA_KEYS = (
4238
'poa_global', # Total plane-of-array irradiance (W/m^2)
4339
'poa_direct', # Direct POA irradiance (W/m^2)
4440
'poa_diffuse' # Diffuse POA irradiance (W/m^2)
4541
)
4642

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.
43+
# Temperature-related optional input columns for ModelChain
5144
TEMPERATURE_KEYS = (
5245
'module_temperature', # Back-surface module temperature (°C)
5346
'cell_temperature', # Direct cell temperature input (°C)
5447
)
55-
#: tuple[str]
56-
#: All supported input keys recognized by ModelChain.
48+
49+
# All supported input keys combined
5750
DATA_KEYS = WEATHER_KEYS + POA_KEYS + TEMPERATURE_KEYS
51+
5852
# these dictionaries contain the default configuration for following
5953
# established modeling sequences. They can be used in combination with
6054
# ModelChain, particularly they are used by the methods
@@ -1730,7 +1724,6 @@ def run_model_from_poa(self, data):
17301724
of Arrays in the PVSystem.
17311725
ValueError
17321726
If the DataFrames in `data` have different indexes.
1733-
17341727
Notes
17351728
-----
17361729
Assigns attributes to results: ``times``, ``weather``,
@@ -1755,7 +1748,6 @@ def run_model_from_poa(self, data):
17551748
self._run_from_effective_irrad(data)
17561749

17571750
return self
1758-
17591751
def _run_from_effective_irrad(self, data):
17601752
"""
17611753
Executes the temperature, DC, losses and AC models.
@@ -1774,7 +1766,7 @@ def _run_from_effective_irrad(self, data):
17741766
17751767
Notes
17761768
-----
1777-
Assigns attributes:``cell_temperature``, ``dc``, ``ac``, ``losses``,
1769+
Assigns attributes:``cell_temperature, 'dc', ``ac', ``losses``,
17781770
``diode_params`` (if dc_model is a single diode model).
17791771
"""
17801772
self._prepare_temperature(data)
@@ -1815,6 +1807,49 @@ def run_model_from_effective_irradiance(self, data):
18151807
of Arrays in the PVSystem.
18161808
ValueError
18171809
If the DataFrames in `data` have different indexes.
1810+
Examples
1811+
--------
1812+
Single-array system:
1813+
1814+
>>> import pandas as pd
1815+
>>> from pvlib.pvsystem import PVSystem
1816+
>>> from pvlib.location import Location
1817+
>>> from pvlib.modelchain import ModelChain
1818+
>>>
1819+
>>> system = PVSystem(module_parameters={'pdc0': 300})
1820+
>>> location = Location(35, -110)
1821+
>>> mc = ModelChain(system, location)
1822+
>>>
1823+
>>> eff = pd.DataFrame({
1824+
... 'effective_irradiance': [900, 920],
1825+
... 'temp_air': [25, 24],
1826+
... 'wind_speed': [2.0, 1.5],
1827+
... },
1828+
... index=pd.date_range("2021-06-01", periods=2, freq="H"))
1829+
>>>
1830+
>>> mc.run_model_from_effective_irradiance(eff)
1831+
<pvlib.modelchain.ModelChain ...>
1832+
1833+
Multi-array system:
1834+
>>> array1 = Array(tilt=30, azimuth=180)
1835+
>>> array2 = Array(tilt=10, azimuth=90)
1836+
>>> system = PVSystem(arrays=[array1, array2],
1837+
... module_parameters={'pdc0': 300})
1838+
>>> mc = ModelChain(system, location)
1839+
>>> eff1 = pd.DataFrame({
1840+
... 'effective_irradiance': [900, 920],
1841+
... 'temp_air': [25, 24],
1842+
... 'wind_speed': [2.0, 1.5],
1843+
... },
1844+
... index=pd.date_range("2021-06-01", periods=2, freq="H"))
1845+
>>> eff2 = pd.DataFrame({
1846+
... 'effective_irradiance': [600, 630],
1847+
... 'temp_air': [26, 25],
1848+
... 'wind_speed': [1.8, 1.2],
1849+
... },
1850+
... index=eff1.index)
1851+
>>> mc.run_model_from_effective_irradiance([eff1, eff2])
1852+
<pvlib.modelchain.ModelChain ...>
18181853
18191854
Notes
18201855
-----
@@ -1853,6 +1888,7 @@ def run_model_from_effective_irradiance(self, data):
18531888
return self
18541889

18551890

1891+
18561892
def _irrad_for_celltemp(total_irrad, effective_irradiance):
18571893
"""
18581894
Determine irradiance to use for cell temperature models, in order

0 commit comments

Comments
 (0)