Skip to content

Commit b2164d7

Browse files
committed
Update average_photon_energy.py
add = variable names remove unused package
1 parent 5d6f7e6 commit b2164d7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

docs/examples/spectrum/average_photon_energy.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
# and meteorological conditions.
3131

3232
# %%
33-
import numpy as np
3433
import pandas as pd
3534
import matplotlib.pyplot as plt
3635
from scipy.integrate import trapezoid
@@ -89,7 +88,7 @@
8988
plt.xlabel(r"Wavelength (nm)")
9089
time_labels = times.strftime("%H:%M")
9190
labels = [
92-
"{}, AM {:0.02f}".format(*vals)
91+
"{}, AM={:0.02f}".format(*vals)
9392
for vals in zip(time_labels, relative_airmass)
9493
]
9594
plt.legend(labels)
@@ -104,16 +103,16 @@
104103
# total broadband irradiance, which we calculate by integrating the entire
105104
# spectral irradiance distribution with respect to wavelength.
106105

107-
poa_global = spectra_components['poa_global']
106+
spectral_poa = spectra_components['poa_global']
108107
wavelength = spectra_components['wavelength']
109108

110-
broadband_irradiance = trapezoid(poa_global, wavelength, axis=0)
109+
broadband_irradiance = trapezoid(spectral_poa, wavelength, axis=0)
111110

112-
poa_global_normalised = poa_global / broadband_irradiance
111+
spectral_poa_normalised = spectral_poa / broadband_irradiance
113112

114113
# Plot the normalised spectra
115114
plt.figure()
116-
plt.plot(wavelength, poa_global_normalised)
115+
plt.plot(wavelength, spectral_poa_normalised)
117116
plt.xlim(200, 2700)
118117
plt.ylim(0, 0.0018)
119118
plt.ylabel(r"Normalised Irradiance (nm⁻¹)")
@@ -150,7 +149,7 @@
150149
# comparable if calculated between the same integration limits. In this case,
151150
# our APE values are calculated between 300nm and 4000nm.
152151

153-
spectra = pd.DataFrame(poa_global).T # convert to dataframe and transpose
152+
spectra = pd.DataFrame(spectral_poa).T # convert to dataframe and transpose
154153
spectra.index = time_labels # add time index
155154
spectra.columns = wavelength # add wavelength column headers
156155

@@ -162,7 +161,7 @@
162161
# units of the APE are electronvolts (eV).
163162

164163
plt.figure()
165-
plt.plot(wavelength, poa_global_normalised)
164+
plt.plot(wavelength, spectral_poa_normalised)
166165
plt.xlim(200, 2700)
167166
plt.ylim(0, 0.0018)
168167
plt.ylabel(r"Normalised Irradiance (nm⁻¹)")

0 commit comments

Comments
 (0)