Skip to content

Commit 010cff7

Browse files
Chirag3841cwhanse
andauthored
Add examples for run_model_from_poa() and run_model_from_effective_irradiance() (#2621)
* Add examples for run_model_from_poa and run_model_from_effective_irradiance * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Fix lint errors (W291 trailing whitespace) * Fix lint errors (W291/W293) in modelchain.py * Fix doctests for run_model_from_poa and run_model_from_effective_irradiance * Fix doctests for run_model_from_poa and run_model_from_effective_irradiance * Fix doctests for run_model_from_poa and run_model_from_effective_irradiance * Fix doctests for run_model_from_poa and run_model_from_effective_irradiance * Fix docstring examples for ModelChain methods * Fix ModelChain doctest examples * Fix pvwatts doctest parameters in examples * Fix doctests for run_model_from_poa and run_model_from_effective_irradiance * Fix pvwatts doctest parameters in examples * Fix doctest examples for run_model_from_poa and run_model_from_effective_irradiance * Fix ModelChain docstring examples for pvwatts * Fix ModelChain docstring examples for pvwatts * Fix doctest outputs for ModelChain run_model examples * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Update pvlib/modelchain.py Co-authored-by: Cliff Hansen <cwhanse@sandia.gov> * Add whatsnew entry for modelchain examples * Fix doctest examples for run_model_from_poa and run_model_from_effective_irradiance --------- Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
1 parent c14dd73 commit 010cff7

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

docs/sphinx/source/whatsnew/v0.15.1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Enhancements
2424

2525
Documentation
2626
~~~~~~~~~~~~~
27+
* Add examples for run_model_from_poa() and run_model_from_effective_irradiance()
28+
(:issue:`1043`, :pull:`2621`)
2729
* Add the following terms to the :ref:`nomenclature` page
2830
(:issue:`2564`, :pull:`2663`):
2931

pvlib/modelchain.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,75 @@ def run_model_from_poa(self, data):
17131713
of Arrays in the PVSystem.
17141714
ValueError
17151715
If the DataFrames in `data` have different indexes.
1716+
Examples
1717+
--------
1718+
Single-array system:
1719+
1720+
>>> import pandas as pd
1721+
>>> from pvlib.pvsystem import PVSystem, Array, FixedMount
1722+
>>> from pvlib.location import Location
1723+
>>> from pvlib.modelchain import ModelChain
1724+
>>> location = Location(35, -110)
1725+
>>> mount = FixedMount(surface_tilt=30, surface_azimuth=180)
1726+
>>> array = Array(
1727+
... mount=mount,
1728+
... module_parameters={'pdc0': 300, 'gamma_pdc': -0.004},
1729+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1730+
... )
1731+
>>> system = PVSystem(
1732+
... arrays=[array],
1733+
... inverter_parameters={'pdc0': 300}
1734+
... )
1735+
>>> mc = ModelChain(
1736+
... system, location,
1737+
... dc_model="pvwatts", ac_model="pvwatts",
1738+
... aoi_model="no_loss", spectral_model="no_loss",
1739+
... temperature_model="faiman"
1740+
... )
1741+
>>> poa = pd.DataFrame({
1742+
... 'poa_global': [900, 850],
1743+
... 'poa_direct': [600, 560],
1744+
... 'poa_diffuse': [300, 290],},
1745+
... index=pd.date_range("2021-06-01", periods=2, freq="h"))
1746+
>>> _ = mc.run_model_from_poa(poa)
1747+
1748+
Multi-array system:
1749+
1750+
>>> mount1 = FixedMount(surface_tilt=30, surface_azimuth=180)
1751+
>>> mount2 = FixedMount(surface_tilt=10, surface_azimuth=90)
1752+
>>> array1 = Array(
1753+
... mount=mount1,
1754+
... module_parameters={'pdc0': 300, 'gamma_pdc': -0.004},
1755+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1756+
... )
1757+
>>> array2 = Array(
1758+
... mount=mount2,
1759+
... module_parameters={'pdc0': 200, 'gamma_pdc': -0.004},
1760+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1761+
... )
1762+
>>> system = PVSystem(
1763+
... arrays=[array1, array2],
1764+
... inverter_parameters={'pdc0': 500}
1765+
... )
1766+
>>> mc = ModelChain(
1767+
... system, location,
1768+
... dc_model="pvwatts", ac_model="pvwatts",
1769+
... aoi_model="no_loss", spectral_model="no_loss",
1770+
... temperature_model="faiman"
1771+
... )
1772+
>>> poa1 = pd.DataFrame({
1773+
... 'poa_global': [900, 880],
1774+
... 'poa_direct': [600, 580],
1775+
... 'poa_diffuse': [300, 300],},
1776+
... index=pd.date_range("2021-06-01", periods=2, freq="h"))
1777+
>>> poa2 = pd.DataFrame({
1778+
... 'poa_global': [700, 720],
1779+
... 'poa_direct': [400, 420],
1780+
... 'poa_diffuse': [300, 300],},
1781+
... index=poa1.index)
1782+
>>> _ = mc.run_model_from_poa(
1783+
... [poa1, poa2]
1784+
... )
17161785
17171786
Notes
17181787
-----
@@ -1798,6 +1867,75 @@ def run_model_from_effective_irradiance(self, data):
17981867
of Arrays in the PVSystem.
17991868
ValueError
18001869
If the DataFrames in `data` have different indexes.
1870+
Examples
1871+
--------
1872+
Single-array system:
1873+
1874+
>>> import pandas as pd
1875+
>>> from pvlib.pvsystem import PVSystem, Array, FixedMount
1876+
>>> from pvlib.location import Location
1877+
>>> from pvlib.modelchain import ModelChain
1878+
>>> location = Location(35, -110)
1879+
>>> mount = FixedMount(surface_tilt=30, surface_azimuth=180)
1880+
>>> array = Array(
1881+
... mount=mount,
1882+
... module_parameters={'pdc0': 300, 'gamma_pdc': -0.004},
1883+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1884+
... )
1885+
>>> system = PVSystem(
1886+
... arrays=[array],
1887+
... inverter_parameters={'pdc0': 300}
1888+
... )
1889+
>>> mc = ModelChain(
1890+
... system, location,
1891+
... dc_model="pvwatts", ac_model="pvwatts",
1892+
... aoi_model="no_loss", spectral_model="no_loss",
1893+
... temperature_model="faiman"
1894+
... )
1895+
>>> eff = pd.DataFrame({
1896+
... 'effective_irradiance': [900, 920],
1897+
... 'temp_air': [25, 24],
1898+
... 'wind_speed': [2.0, 1.5],},
1899+
... index=pd.date_range("2021-06-01", periods=2, freq="h"))
1900+
>>> _ = mc.run_model_from_effective_irradiance(eff)
1901+
1902+
Multi-array system:
1903+
1904+
>>> mount1 = FixedMount(surface_tilt=30, surface_azimuth=180)
1905+
>>> mount2 = FixedMount(surface_tilt=10, surface_azimuth=90)
1906+
>>> array1 = Array(
1907+
... mount=mount1,
1908+
... module_parameters={'pdc0': 300, 'gamma_pdc': -0.004},
1909+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1910+
... )
1911+
>>> array2 = Array(
1912+
... mount=mount2,
1913+
... module_parameters={'pdc0': 200, 'gamma_pdc': -0.004},
1914+
... temperature_model_parameters={'u0': 25.0, 'u1': 6.84}
1915+
... )
1916+
>>> system = PVSystem(
1917+
... arrays=[array1, array2],
1918+
... inverter_parameters={'pdc0': 500}
1919+
... )
1920+
>>> mc = ModelChain(
1921+
... system, location,
1922+
... dc_model="pvwatts", ac_model="pvwatts",
1923+
... aoi_model="no_loss", spectral_model="no_loss",
1924+
... temperature_model="faiman"
1925+
... )
1926+
>>> eff1 = pd.DataFrame({
1927+
... 'effective_irradiance': [900, 920],
1928+
... 'temp_air': [25, 24],
1929+
... 'wind_speed': [2.0, 1.5],},
1930+
... index=pd.date_range("2021-06-01", periods=2, freq="h"))
1931+
>>> eff2 = pd.DataFrame({
1932+
... 'effective_irradiance': [600, 630],
1933+
... 'temp_air': [26, 25],
1934+
... 'wind_speed': [1.8, 1.2],},
1935+
... index=eff1.index)
1936+
>>> _ = mc.run_model_from_effective_irradiance(
1937+
... [eff1, eff2]
1938+
... )
18011939
18021940
Notes
18031941
-----

0 commit comments

Comments
 (0)