Skip to content

Commit 9fcf180

Browse files
committed
Update average_photon_energy.py
1 parent 27a92b0 commit 9fcf180

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

docs/examples/spectrum/average_photon_energy.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# This example demonstrates how to use the
1212
# :py:func:`~pvlib.spectrum.average_photon_energy` function to calculate the
1313
# Average Photon Energy (APE, :math:`\overline{E_\gamma}`) of spectral
14-
# irradiance distributions simulated using :pyfunc:`~pvlib.spectrum.spectrl2`.
14+
# irradiance distributions simulated using :py:func:`~pvlib.spectrum.spectrl2`.
1515
# More information on the SPECTRL2 model can be found in [2]_
1616
# The APE parameter is a useful indicator of the overall shape of the solar
1717
# spectrum [1]_. Higher (lower) APE values indicate a blue (red) shift in the
@@ -20,20 +20,23 @@
2020
#
2121
# To demonstrate this functionality, first we need to simulate some spectra
2222
# using :py:func:`~pvlib.spectrum.spectrl2`. In this example, we will simulate
23-
# spectra following a similar structure to that which is followed in
24-
# XX link example XX, which reproduces a figure from [4]_. The first step is to
23+
# spectra following a similar method to that which is followed in the
24+
# `Modelling Spectral Irradiance
25+
# <https://pvlib-python.readthedocs.io/en/stable/gallery/spectrum/plot_spectrl2_fig51A.html>`_
26+
# example, which reproduces a figure from [4]_. The first step is to
2527
# import the required packages and define some basic system parameters and
2628
# and meteorological conditions.
29+
2730
# %%
2831
import numpy as np
2932
import pandas as pd
3033
import matplotlib.pyplot as plt
3134
from scipy.integrate import trapezoid
3235
from pvlib import spectrum, solarposition, irradiance, atmosphere
3336

34-
lat, lon = 39.742, -105.18 # NREL SRRL location
37+
lat, lon = 39.742, -105.18 # NREL SRRL location
3538
tilt = 25
36-
azimuth = 180 # south-facing system
39+
azimuth = 180 # south-facing system
3740
pressure = 81190 # at 1828 metres AMSL, roughly
3841
water_vapor_content = 0.5 # cm
3942
tau500 = 0.1
@@ -56,9 +59,9 @@
5659
# more than one set of conditions, the function will return a dictionary
5760
# containing 2-D arrays for the spectral irradiance components and a 1-D array
5861
# of shape (122,) for wavelength. For each of the 2-D arrays, one dimension is
59-
# for wavelength in nm and one is for irradiance in Wm⁻².
60-
# The next section will show how to convert this output into a suitable
61-
# input for :pyfunc:`~average_photon_energy`.
62+
# for wavelength in nm and one is for irradiance in Wm⁻²nm⁻¹. The next section
63+
# will show how to convert this output into a suitable input for
64+
# :py:func:`~average_photon_energy`.
6265

6366
spectra_components = spectrum.spectrl2(
6467
apparent_zenith=solpos.apparent_zenith,
@@ -92,6 +95,7 @@
9295
plt.legend(labels)
9396
plt.show()
9497

98+
# %%
9599
# Given the changing irradiance throughout the day, it is not obvious from
96100
# inspection how the relative distribution of light changes as a function of
97101
# wavelength. We can normalise the spectral irradiance curves to get an idea
@@ -109,7 +113,6 @@
109113
poa_global_normalised = poa_global / broadband_irradiance
110114

111115
# Plot the normalised spectra
112-
113116
plt.figure()
114117
plt.plot(wavelength, poa_global_normalised)
115118
plt.xlim(200, 2700)
@@ -124,6 +127,10 @@
124127
plt.legend(labels)
125128
plt.show()
126129

130+
131+
# XX figure layout --- one on top of another? increase size/readability
132+
133+
# %%
127134
# Now we can see from XX figure numbers? XX that at the start and end of the
128135
# day, the spectrum is red shifted, meaning there is a greater proportion of
129136
# longer wavelength radiation. Meanwhile, during the middle of the day there is
@@ -138,7 +145,7 @@
138145
# -------------------------------------
139146
# To calculate the APE, first we must convert our output spectra from from the
140147
# simulation into a compatible input for
141-
# :pyfunc:`pvlib.spectrum.average_photon_energy`. Since we have more than one
148+
# :py:func:`pvlib.spectrum.average_photon_energy`. Since we have more than one
142149
# spectral irradiance distribution, a :py:class:`pandas.DataFrame` is
143150
# appropriate. We also need to set the column headers as wavelength, so each
144151
# row is a single spectral irradiance distribution. It is important to remember

0 commit comments

Comments
 (0)