Skip to content

Commit 2d0ed71

Browse files
echedey-lskandersolarmarkcampanelli
authored
Add extraterrestrial and direct spectra of ASTM G173-03 standard spectrum (AM1.5) (#2039)
* Implement all for spectrum.get_ASTM_G173 * Full implementation Implement, test and document spectrum.get_ASTM_G173 Modify spectrum.get_am15g as a wrapper of the latter Delete old file Implementation note: I've used pandas interpolate instead of scipy's because the latter is considered legacy. See docs at https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html * Minor updates to docs * Add print statements to examples * Add example from my other branch * Microoptimization 🚀 * Fix implementation * Format with Ruff, thx Ruff 💚 * Update v0.11.0.rst * Change signature to `get_standard_spectrum`, future-proof implementation * linter 🌋 * Update plot_standard_ASTM_G173-03.py Co-Authored-By: Kevin Anderson <[email protected]> * Update mismatch.py Co-Authored-By: Kevin Anderson <[email protected]> * Update mismatch.py Co-Authored-By: Kevin Anderson <[email protected]> * reference->standard & docs Co-Authored-By: Kevin Anderson <[email protected]> * docs Co-Authored-By: Kevin Anderson <[email protected]> * Fixes Co-Authored-By: Kevin Anderson <[email protected]> * Fix tests, I'm kinda stupid * Deprecation announcement in condition * duh * Update mismatch.py * Add fail on version * Units * Unit formatting, forgot this * Remove deprecated admonition duplicate Co-Authored-By: Kevin Anderson <[email protected]> * Unit formatting went too far Co-Authored-By: Kevin Anderson <[email protected]> * Function rename to get_reference_spectrum Co-Authored-By: Kevin Anderson <[email protected]> * Clean warnings from test logs Co-Authored-By: Kevin Anderson <[email protected]> * Fix wrongly made test https: //stackoverflow.com/questions/65255622/anydf-isna-returns-true-when-no-nans-are-present Co-Authored-By: Kevin Anderson <[email protected]> * Other get_am15g references in code Co-Authored-By: Kevin Anderson <[email protected]> * Update plot_standard_ASTM_G173-03.py Co-Authored-By: Kevin Anderson <[email protected]> * lintar * Order of commits matter Co-Authored-By: Kevin Anderson <[email protected]> * Rm units of function not in scope Co-Authored-By: Kevin Anderson <[email protected]> * Rename function to get_reference_spectra Co-Authored-By: Kevin Anderson <[email protected]> Co-Authored-By: Mark Campanelli <[email protected]> * Code Review from Kevin Co-Authored-By: Kevin Anderson <[email protected]> * linter :D Co-Authored-By: Kevin Anderson <[email protected]> * Remove stupid keyword-only params requirement Co-Authored-By: Mark Campanelli <[email protected]> --------- Co-authored-by: Kevin Anderson <[email protected]> Co-authored-by: Mark Campanelli <[email protected]>
1 parent 19c9598 commit 2d0ed71

File tree

8 files changed

+2228
-2030
lines changed

8 files changed

+2228
-2030
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
ASTM G173-03 Standard Spectrum
3+
==============================
4+
5+
This example demonstrates how to read the data from the ASTM G173-03 standard
6+
spectrum bundled with pvlib and plot each of the components.
7+
8+
The ASTM G173-03 standard provides reference solar spectral irradiance data.
9+
"""
10+
11+
import matplotlib.pyplot as plt
12+
import pvlib
13+
14+
15+
# %%
16+
# Use :py:func:`pvlib.spectrum.get_reference_spectra` to read a spectra dataset
17+
# bundled with pvlib.
18+
19+
am15 = pvlib.spectrum.get_reference_spectra(standard="ASTM G173-03")
20+
21+
# Plot
22+
plt.plot(am15.index, am15["extraterrestrial"], label="Extraterrestrial")
23+
plt.plot(am15.index, am15["global"], label="Global")
24+
plt.plot(am15.index, am15["direct"], label="Direct")
25+
plt.xlabel(r"Wavelength $[nm]$")
26+
plt.ylabel(r"Irradiance $\left[\frac{W}{m^2 nm}\right]$")
27+
plt.title("ASTM G173-03 Solar Spectral Irradiance")
28+
plt.legend()
29+
plt.grid(True)
30+
plt.tight_layout()
31+
plt.show()

docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Spectrum
99
spectrum.spectrl2
1010
spectrum.get_example_spectral_response
1111
spectrum.get_am15g
12+
spectrum.get_reference_spectra
1213
spectrum.calc_spectral_mismatch_field
1314
spectrum.spectral_factor_caballero
1415
spectrum.spectral_factor_firstsolar

docs/sphinx/source/whatsnew/v0.11.0.rst

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Breaking changes
2020

2121
Deprecations
2222
~~~~~~~~~~~~
23+
* Function :py:func:`pvlib.spectrum.get_am15g` has been deprecated in favor
24+
of the new function :py:func:`pvlib.spectrum.get_reference_spectra`. Use
25+
``pvlib.spectrum.get_reference_spectra(standard="ASTM G173-03")["global"]``
26+
instead. (:pull:`2039`)
2327

2428

2529
Enhancements
@@ -38,6 +42,9 @@ Enhancements
3842
* Add function :py:func:`pvlib.spectrum.spectral_factor_pvspec`, which calculates the
3943
spectral mismatch factor as a function of absolute airmass and clearsky index
4044
using the PVSPEC model. (:issue:`1950`, :issue:`2065`, :pull:`2072`)
45+
* Added extraterrestrial and direct spectra of the ASTM G173-03 standard with
46+
the new function :py:func:`pvlib.spectrum.get_reference_spectra`.
47+
(:issue:`1963`, :pull:`2039`)
4148

4249
Bug fixes
4350
~~~~~~~~~

0 commit comments

Comments
 (0)