Skip to content

Commit

Permalink
Add extraterrestrial and direct spectra of ASTM G173-03 standard spec…
Browse files Browse the repository at this point in the history
…trum (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]>
  • Loading branch information
3 people authored Jun 17, 2024
1 parent 19c9598 commit 2d0ed71
Show file tree
Hide file tree
Showing 8 changed files with 2,228 additions and 2,030 deletions.
31 changes: 31 additions & 0 deletions docs/examples/spectrum/plot_standard_ASTM_G173-03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
ASTM G173-03 Standard Spectrum
==============================
This example demonstrates how to read the data from the ASTM G173-03 standard
spectrum bundled with pvlib and plot each of the components.
The ASTM G173-03 standard provides reference solar spectral irradiance data.
"""

import matplotlib.pyplot as plt
import pvlib


# %%
# Use :py:func:`pvlib.spectrum.get_reference_spectra` to read a spectra dataset
# bundled with pvlib.

am15 = pvlib.spectrum.get_reference_spectra(standard="ASTM G173-03")

# Plot
plt.plot(am15.index, am15["extraterrestrial"], label="Extraterrestrial")
plt.plot(am15.index, am15["global"], label="Global")
plt.plot(am15.index, am15["direct"], label="Direct")
plt.xlabel(r"Wavelength $[nm]$")
plt.ylabel(r"Irradiance $\left[\frac{W}{m^2 nm}\right]$")
plt.title("ASTM G173-03 Solar Spectral Irradiance")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Spectrum
spectrum.spectrl2
spectrum.get_example_spectral_response
spectrum.get_am15g
spectrum.get_reference_spectra
spectrum.calc_spectral_mismatch_field
spectrum.spectral_factor_caballero
spectrum.spectral_factor_firstsolar
Expand Down
7 changes: 7 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Breaking changes

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


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

Bug fixes
~~~~~~~~~
Expand Down
Loading

0 comments on commit 2d0ed71

Please sign in to comment.