Skip to content

Commit 67d45f8

Browse files
committed
add basic_chain to package_overview
1 parent 6448172 commit 67d45f8

File tree

1 file changed

+62
-39
lines changed

1 file changed

+62
-39
lines changed

docs/sphinx/source/package_overview.rst

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The core mission of pvlib-python is to provide open, reliable,
1010
interoperable, and benchmark implementations of PV system models.
1111

1212
There are at least as many opinions about how to model PV systems as
13-
there are modelers of PV systems, so
13+
there are modelers of PV systems, so
1414
pvlib-python provides several modeling paradigms.
1515

1616

@@ -36,28 +36,28 @@ configuration at a handful of sites listed below.
3636
3737
import pandas as pd
3838
import matplotlib.pyplot as plt
39-
39+
4040
# seaborn makes the plots look nicer
4141
import seaborn as sns
4242
sns.set_color_codes()
43-
43+
4444
times = pd.DatetimeIndex(start='2015', end='2016', freq='1h')
45-
45+
4646
# very approximate
4747
# latitude, longitude, name, altitude
4848
coordinates = [(30, -110, 'Tucson', 700),
4949
(35, -105, 'Albuquerque', 1500),
5050
(40, -120, 'San Francisco', 10),
5151
(50, 10, 'Berlin', 34)]
52-
52+
5353
import pvlib
54-
54+
5555
# get the module and inverter specifications from SAM
5656
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
5757
sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter')
5858
module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']
5959
inverter = sapm_inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_']
60-
60+
6161
# specify constant ambient air temp and wind for simplicity
6262
temp_air = 20
6363
wind_speed = 0
@@ -73,7 +73,7 @@ The following code demonstrates how to use the procedural code
7373
to accomplish our system modeling goal:
7474

7575
.. ipython:: python
76-
76+
7777
system = {'module': module, 'inverter': inverter,
7878
'surface_azimuth': 180}
7979
@@ -104,32 +104,56 @@ to accomplish our system modeling goal:
104104
ac = pvlib.pvsystem.snlinverter(inverter, dc['v_mp'], dc['p_mp'])
105105
annual_energy = ac.sum()
106106
energies[name] = annual_energy
107-
107+
108108
energies = pd.Series(energies)
109109
110110
# based on the parameters specified above, these are in W*hrs
111111
print(energies.round(0))
112-
112+
113113
energies.plot(kind='bar', rot=0)
114114
@savefig proc-energies.png width=6in
115115
plt.ylabel('Yearly energy yield (W hr)')
116116
117+
pvlib-python provides a :py:func:`~pvlib.modelchain.basic_chain`
118+
function that implements much of the code above. Use this function with
119+
a full understanding of what it is doing internally!
120+
121+
.. ipython:: python
122+
123+
from pvlib.modelchain import basic_chain
124+
125+
energies = {}
126+
for latitude, longitude, name, altitude in coordinates:
127+
dc, ac = basic_chain(times, latitude, longitude,
128+
module, inverter,
129+
altitude=altitude,
130+
orientation_strategy='south_at_latitude_tilt')
131+
annual_energy = ac.sum()
132+
energies[name] = annual_energy
133+
134+
energies = pd.Series(energies)
135+
136+
# based on the parameters specified above, these are in W*hrs
137+
print(energies.round(0))
138+
139+
energies.plot(kind='bar', rot=0)
140+
@savefig basic-chain-energies.png width=6in
141+
plt.ylabel('Yearly energy yield (W hr)')
142+
117143
118144
Object oriented (Location, PVSystem, ModelChain)
119145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120146

121-
The first object oriented paradigm uses a model where
122-
a :py:class:`~pvlib.pvsystem.PVSystem` object represents an
123-
assembled collection of modules, inverters, etc.,
124-
a :py:class:`~pvlib.location.Location` object represents a
125-
particular place on the planet,
126-
and a :py:class:`~pvlib.modelchain.ModelChain` object describes
127-
the modeling chain used to calculate PV output at that Location.
128-
This can be a useful paradigm if you prefer to think about
129-
the PV system and its location as separate concepts or if
130-
you develop your own ModelChain subclasses.
131-
It can also be helpful if you make extensive use of Location-specific
132-
methods for other calculations.
147+
The first object oriented paradigm uses a model where a
148+
:py:class:`~pvlib.pvsystem.PVSystem` object represents an assembled
149+
collection of modules, inverters, etc., a
150+
:py:class:`~pvlib.location.Location` object represents a particular
151+
place on the planet, and a :py:class:`~pvlib.modelchain.ModelChain`
152+
object describes the modeling chain used to calculate PV output at that
153+
Location. This can be a useful paradigm if you prefer to think about the
154+
PV system and its location as separate concepts or if you develop your
155+
own ModelChain subclasses. It can also be helpful if you make extensive
156+
use of Location-specific methods for other calculations.
133157

134158
The following code demonstrates how to use
135159
:py:class:`~pvlib.location.Location`,
@@ -138,14 +162,14 @@ The following code demonstrates how to use
138162
objects to accomplish our system modeling goal:
139163

140164
.. ipython:: python
141-
165+
142166
from pvlib.pvsystem import PVSystem
143167
from pvlib.location import Location
144168
from pvlib.modelchain import ModelChain
145-
169+
146170
system = PVSystem(module_parameters=module,
147171
inverter_parameters=inverter)
148-
172+
149173
energies = {}
150174
for latitude, longitude, name, altitude in coordinates:
151175
location = Location(latitude, longitude, name=name, altitude=altitude)
@@ -156,12 +180,12 @@ objects to accomplish our system modeling goal:
156180
dc, ac = mc.run_model(times)
157181
annual_energy = ac.sum()
158182
energies[name] = annual_energy
159-
183+
160184
energies = pd.Series(energies)
161-
185+
162186
# based on the parameters specified above, these are in W*hrs
163187
print(energies.round(0))
164-
188+
165189
energies.plot(kind='bar', rot=0)
166190
@savefig modelchain-energies.png width=6in
167191
plt.ylabel('Yearly energy yield (W hr)')
@@ -170,18 +194,17 @@ objects to accomplish our system modeling goal:
170194
Object oriented (LocalizedPVSystem)
171195
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
172196

173-
The second object oriented paradigm uses a model where a
197+
The second object oriented paradigm uses a model where a
174198
:py:class:`~pvlib.pvsystem.LocalizedPVSystem` represents a
175-
PV system at a particular place on the planet.
176-
This can be a useful paradigm if you're thinking about
177-
a power plant that already exists.
199+
PV system at a particular place on the planet. This can be a useful
200+
paradigm if you're thinking about a power plant that already exists.
178201

179202
The following code demonstrates how to use a
180203
:py:class:`~pvlib.pvsystem.LocalizedPVSystem`
181204
object to accomplish our modeling goal:
182205

183206
.. ipython:: python
184-
207+
185208
from pvlib.pvsystem import LocalizedPVSystem
186209
187210
energies = {}
@@ -214,22 +237,22 @@ object to accomplish our modeling goal:
214237
ac = localized_system.snlinverter(dc['v_mp'], dc['p_mp'])
215238
annual_energy = ac.sum()
216239
energies[name] = annual_energy
217-
240+
218241
energies = pd.Series(energies)
219-
242+
220243
# based on the parameters specified above, these are in W*hrs
221244
print(energies.round(0))
222-
245+
223246
energies.plot(kind='bar', rot=0)
224247
@savefig localized-pvsystem-energies.png width=6in
225248
plt.ylabel('Yearly energy yield (W hr)')
226249
227250
228251
User extensions
229252
---------------
230-
There are many other ways to organize PV modeling code.
231-
We encourage you to build on these paradigms and to share your experiences
232-
with the pvlib community via issues and pull requests.
253+
There are many other ways to organize PV modeling code. We encourage you
254+
to build on these paradigms and to share your experiences with the pvlib
255+
community via issues and pull requests.
233256

234257

235258
Getting support

0 commit comments

Comments
 (0)