|
11 | 11 | # This example demonstrates how to use the |
12 | 12 | # :py:func:`~pvlib.spectrum.average_photon_energy` function to calculate the |
13 | 13 | # 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`. |
15 | 15 | # More information on the SPECTRL2 model can be found in [2]_ |
16 | 16 | # The APE parameter is a useful indicator of the overall shape of the solar |
17 | 17 | # spectrum [1]_. Higher (lower) APE values indicate a blue (red) shift in the |
|
20 | 20 | # |
21 | 21 | # To demonstrate this functionality, first we need to simulate some spectra |
22 | 22 | # 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 |
25 | 27 | # import the required packages and define some basic system parameters and |
26 | 28 | # and meteorological conditions. |
| 29 | + |
27 | 30 | # %% |
28 | 31 | import numpy as np |
29 | 32 | import pandas as pd |
30 | 33 | import matplotlib.pyplot as plt |
31 | 34 | from scipy.integrate import trapezoid |
32 | 35 | from pvlib import spectrum, solarposition, irradiance, atmosphere |
33 | 36 |
|
34 | | -lat, lon = 39.742, -105.18 # NREL SRRL location |
| 37 | +lat, lon = 39.742, -105.18 # NREL SRRL location |
35 | 38 | tilt = 25 |
36 | | -azimuth = 180 # south-facing system |
| 39 | +azimuth = 180 # south-facing system |
37 | 40 | pressure = 81190 # at 1828 metres AMSL, roughly |
38 | 41 | water_vapor_content = 0.5 # cm |
39 | 42 | tau500 = 0.1 |
|
56 | 59 | # more than one set of conditions, the function will return a dictionary |
57 | 60 | # containing 2-D arrays for the spectral irradiance components and a 1-D array |
58 | 61 | # 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`. |
62 | 65 |
|
63 | 66 | spectra_components = spectrum.spectrl2( |
64 | 67 | apparent_zenith=solpos.apparent_zenith, |
|
92 | 95 | plt.legend(labels) |
93 | 96 | plt.show() |
94 | 97 |
|
| 98 | +# %% |
95 | 99 | # Given the changing irradiance throughout the day, it is not obvious from |
96 | 100 | # inspection how the relative distribution of light changes as a function of |
97 | 101 | # wavelength. We can normalise the spectral irradiance curves to get an idea |
|
109 | 113 | poa_global_normalised = poa_global / broadband_irradiance |
110 | 114 |
|
111 | 115 | # Plot the normalised spectra |
112 | | - |
113 | 116 | plt.figure() |
114 | 117 | plt.plot(wavelength, poa_global_normalised) |
115 | 118 | plt.xlim(200, 2700) |
|
124 | 127 | plt.legend(labels) |
125 | 128 | plt.show() |
126 | 129 |
|
| 130 | + |
| 131 | +# XX figure layout --- one on top of another? increase size/readability |
| 132 | + |
| 133 | +# %% |
127 | 134 | # Now we can see from XX figure numbers? XX that at the start and end of the |
128 | 135 | # day, the spectrum is red shifted, meaning there is a greater proportion of |
129 | 136 | # longer wavelength radiation. Meanwhile, during the middle of the day there is |
|
138 | 145 | # ------------------------------------- |
139 | 146 | # To calculate the APE, first we must convert our output spectra from from the |
140 | 147 | # 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 |
142 | 149 | # spectral irradiance distribution, a :py:class:`pandas.DataFrame` is |
143 | 150 | # appropriate. We also need to set the column headers as wavelength, so each |
144 | 151 | # row is a single spectral irradiance distribution. It is important to remember |
|
0 commit comments