Skip to content

Commit a366714

Browse files
committed
get the procedural code example working in the docs
1 parent 7120082 commit a366714

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

docs/sphinx/source/package_overview.rst

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ corresponding procedural code.
2727

2828
Let's use each of these pvlib modeling paradigms
2929
to calculate the yearly energy yield for a given hardware
30-
configuration at a handful of sites listed below ::
30+
configuration at a handful of sites listed below.
31+
32+
.. ipython:: python
3133
3234
import pandas as pd
3335
@@ -38,36 +40,44 @@ configuration at a handful of sites listed below ::
3840
(35, -105, 'Albuquerque'),
3941
(40, -120, 'San Francisco'),
4042
(50, 10, 'Berlin')]
41-
42-
None of these examples are complete!
43-
Should replace the clear sky assumption with TMY or similar
44-
(or leave as an exercise to the reader?).
43+
44+
import pvlib
45+
46+
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
47+
sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter')
48+
module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']
49+
inverter = sapm_inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_']
4550
4651
4752
Procedural
4853
^^^^^^^^^^
4954

50-
Procedural code can be used to for all modeling steps in pvlib-python.
55+
The straightforward procedural code can be used for all modeling
56+
steps in pvlib-python.
5157

5258
The following code demonstrates how to use the procedural code
53-
to accomplish our system modeling goal: ::
54-
55-
import pvlib
59+
to accomplish our system modeling goal:
60+
61+
.. ipython:: python
5662
5763
system = {'module': module, 'inverter': inverter,
58-
'surface_azimuth': 180, **other_params}
64+
'surface_azimuth': 180}
5965
6066
energies = {}
6167
for latitude, longitude, name in coordinates:
68+
system['surface_tilt'] = latitude
6269
cs = pvlib.clearsky.ineichen(times, latitude, longitude)
6370
solpos = pvlib.solarposition.get_solarposition(times, latitude, longitude)
64-
system['surface_tilt'] = latitude
65-
total_irrad = pvlib.irradiance.total_irradiance(**solpos, **cs, **system)
66-
temps = pvlib.pvsystem.sapm_celltemp(**total_irrad, **system)
67-
dc = pvlib.pvsystem.sapm(**temps, **total_irrad, **system)
68-
ac = pvlib.pvsystem.snlinverter(**system, **dc)
69-
annual_energy = power.sum()
71+
airmass = pvlib.atmosphere.relativeairmass(solpos['apparent_zenith'])
72+
aoi = pvlib.irradiance.aoi(system['surface_tilt'], system['surface_azimuth'], solpos['apparent_zenith'], solpos['azimuth'])
73+
total_irrad = pvlib.irradiance.total_irrad(**solpos, **cs, **system)
74+
temps = pvlib.pvsystem.sapm_celltemp(total_irrad['poa_global'], 0, 20)
75+
dc = pvlib.pvsystem.sapm(module, total_irrad['poa_direct'], total_irrad['poa_diffuse'], temps['temp_cell'], airmass, aoi)
76+
ac = pvlib.pvsystem.snlinverter(inverter, dc['v_mp'], dc['p_mp'])
77+
annual_energy = ac.sum()
7078
energies[name] = annual_energy
79+
80+
print(energies)
7181
7282
#energies = pd.DataFrame(energies)
7383
#energies.plot()
@@ -93,7 +103,9 @@ The following code demonstrates how to use
93103
:class:`Location <pvlib.location.Location>`,
94104
:class:`PVSystem <pvlib.pvsystem.PVSystem>`, and
95105
:class:`ModelChain <pvlib.modelchain.ModelChain>`
96-
objects to accomplish our system modeling goal: ::
106+
objects to accomplish our system modeling goal:
107+
108+
.. ipython:: python
97109
98110
from pvlib.pvsystem import PVSystem
99111
from pvlib.location import Location
@@ -126,10 +138,15 @@ a power plant that already exists.
126138

127139
The following code demonstrates how to use a
128140
:class:`LocalizedPVSystem <pvlib.pvsystem.LocalizedPVSystem>`
129-
object to accomplish our modeling goal: ::
141+
object to accomplish our modeling goal:
142+
143+
.. ipython:: python
130144
131145
from pvlib.pvsystem import PVSystem, LocalizedPVSystem
132146
147+
module =
148+
inverter =
149+
other_system_params = {} # sometime helpful to break apart
133150
base_system = PVSystem(module, inverter, **other_system_params)
134151
135152
energies = {}

0 commit comments

Comments
 (0)