Skip to content

Commit db1e875

Browse files
committed
Create average_photon_energy.py
1 parent cd9cb9a commit db1e875

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
"""
2+
Spectral Mismatch Estimation
3+
============================
4+
5+
Calculation of the Average Photon Energy from Spectrl2 output.
6+
"""
7+
8+
# %%
9+
# Introduction
10+
# ------------
11+
# This example demonstrates how to use the
12+
# :py:func:`~pvlib.spectrum.average_photon_energy` function to calculate the
13+
# Average Photon Energy (APE, :math:`\overline{E_\gamma}`) of spectral
14+
# irradiance distributions simulated using :pyfunc:`~pvlib.spectrum.spectrl2`.
15+
# More information on the SPECTRL2 model can be found in [2]_
16+
# The APE parameter is a useful indicator of the overall shape of the solar
17+
# spectrum [1]_. Higher (lower) APE values indicate a blue (red) shift in the
18+
# spectrum and is one of a variety of such characterisation indexes that are
19+
# used in the PV performance literature [3]_.
20+
#
21+
# To demonstrate this functionality, first we need to simulate some spectra
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
25+
# import the required packages and define some basic system parameters and
26+
# and meteorological conditions.
27+
# %%
28+
from pvlib import spectrum, solarposition, irradiance, atmosphere
29+
import pandas as pd
30+
import matplotlib.pyplot as plt
31+
32+
lat, lon = 39.742, -105.18 # NREL SRRL location
33+
tilt = 25
34+
azimuth = 180 # south-facing system
35+
pressure = 81190 # at 1828 metres AMSL, roughly
36+
water_vapor_content = 0.5 # cm
37+
tau500 = 0.1
38+
ozone = 0.31 # atm-cm
39+
albedo = 0.2
40+
41+
times = pd.date_range('2023-01-01 12:00', freq='D', periods=7,
42+
tz='America/Denver')
43+
solpos = solarposition.get_solarposition(times, lat, lon)
44+
aoi = irradiance.aoi(tilt, azimuth, solpos.apparent_zenith, solpos.azimuth)
45+
46+
relative_airmass = atmosphere.get_relative_airmass(solpos.apparent_zenith,
47+
model='kastenyoung1989')
48+
49+
# %%
50+
# Spectral simulation
51+
# -------------------------
52+
# With all the necessary inputs now defined, we can model spectral irradiance
53+
# using :py:func:`pvlib.spectrum.spectrl2`. As we are calculating spectra for
54+
# more than one set of conditions, the function will return a dictionary of
55+
# 2-D arrays with the exception of wavelength, which has shape (122, N), where
56+
# N is the length of the input ``apparent_zenith``. For each of the 2-D arrays,
57+
# one dimension is allocated for wavelength and one is for irradiance in Wm⁻².
58+
# The next section will show how to convert this output into a suitable
59+
# input for :pyfunc:`~average_photon_energy`.
60+
61+
spectra = spectrum.spectrl2(
62+
apparent_zenith=solpos.apparent_zenith,
63+
aoi=aoi,
64+
surface_tilt=tilt,
65+
ground_albedo=albedo,
66+
surface_pressure=pressure,
67+
relative_airmass=relative_airmass,
68+
precipitable_water=water_vapor_content,
69+
ozone=ozone,
70+
aerosol_turbidity_500nm=tau500,
71+
)
72+
# %%
73+
# another section
74+
# --------------------------------
75+
# %%
76+
#
77+
78+
# %%
79+
# References
80+
# ----------
81+
# .. [1] Jardine, C., et al., 2002, January. Influence of spectral effects on
82+
# the performance of multijunction amorphous silicon cells. In Proc.
83+
# Photovoltaic in Europe Conference (pp. 1756-1759).
84+
# .. [2] Bird, R, and Riordan, C., 1984, "Simple solar spectral model for
85+
# direct and diffuse irradiance on horizontal and tilted planes at the
86+
# earth's surface for cloudless atmospheres", NREL Technical Report
87+
# TR-215-2436 :doi:`10.2172/5986936`.
88+
# .. [3] Daxini, R., and Wu, Y., 2023. "Review of methods to account
89+
# for the solar spectral influence on photovoltaic device performance."
90+
# Energy 286 :doi:`10.1016/j.energy.2023.129461`
91+
# .. [4] Bird Simple Spectral Model: spectrl2_2.c.
92+
# https://www.nrel.gov/grid/solar-resource/spectral.html
93+

0 commit comments

Comments
 (0)