Skip to content

Remove deprecated spectrum.get_am15g function #2409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Spectrum

spectrum.spectrl2
spectrum.get_example_spectral_response
spectrum.get_am15g
spectrum.get_reference_spectra
spectrum.calc_spectral_mismatch_field
spectrum.spectral_factor_caballero
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Deprecations
~~~~~~~~~~~~
* The ``pvlib.irradiance.SURFACE_ALBEDOS`` dictionary has been moved to
:py:const:`pvlib.albedo.SURFACE_ALBEDOS`. (:pull:`2095`)
* Function :py:func:`pvlib.spectrum.get_am15g` has been deprecated in favor
* 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`)
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Breaking Changes
Additionally, the deprecated ``recolumn`` parameter is now removed. (:issue:`2324`, :pull:`2408`)
* Remove :py:func:`!pvlib.atmosphere.first_solar_spectral_correction`, deprecated in v0.10.0.
Use :py:func:`~pvlib.spectrum.spectral_factor_firstsolar` instead. (:issue:`2130`, :pull:`2131`)
* Remove deprecated :py:func:`!pvlib.spectrum.get_am15g` function; use
:py:func:`~pvlib.spectrum.get_reference_spectra` instead. (:pull:`2409`)
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Remove deprecated :py:func:`!pvlib.spectrum.get_am15g` function; use
:py:func:`~pvlib.spectrum.get_reference_spectra` instead. (:pull:`2409`)
* Remove deprecated :py:func:`~pvlib.spectrum.get_am15g` function; use
:py:func:`~pvlib.spectrum.get_reference_spectra` instead. (:pull:`2409`)

What does the ! do? Should it be a ~?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only learned about ! recently, I think from one of @echedey-ls's PRs if I remember correctly. From https://www.sphinx-doc.org/en/master/usage/referencing.html:

Prefixing with an exclamation mark (!) prevents the creation of a link but otherwise keeps the visual output of the role.

a tilde ~ prefix shortens the link text to the last component of the target.

We're getting rid of get_am15g, so there's no point in trying to link somewhere, but it would be nice (IMHO) to have the same function formatting applied regardless.


Bug fixes
~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.9.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Enhancements
(:issue:`1516`, :pull:`1518`)
* New module to calculate spectral mismatch from field spectral measurements
:py:func:`~pvlib.spectrum.get_example_spectral_response`
:py:func:`~pvlib.spectrum.get_am15g`
:py:func:`!pvlib.spectrum.get_am15g`
:py:func:`~pvlib.spectrum.calc_spectral_mismatch_field`
(:issue:`1523`, :pull:`1524`)
* Added Townsend-Powers monthly snow loss model:
Expand Down
1 change: 0 additions & 1 deletion pvlib/spectrum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
spectral_factor_jrc,
)
from pvlib.spectrum.irradiance import ( # noqa: F401
get_am15g,
get_reference_spectra,
average_photon_energy,
)
Expand Down
63 changes: 0 additions & 63 deletions pvlib/spectrum/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import pvlib
from pvlib._deprecation import deprecated
import numpy as np
import pandas as pd
from pathlib import Path
Expand All @@ -13,68 +12,6 @@
from scipy.integrate import trapezoid


@deprecated(
since="0.11",
removal="0.12",
name="pvlib.spectrum.get_am15g",
alternative="pvlib.spectrum.get_reference_spectra",
addendum=(
"The new function reads more data. Use it with "
+ "standard='ASTM G173-03' and extract the 'global' column."
),
)
def get_am15g(wavelength=None):
r"""
Read the ASTM G173-03 AM1.5 global spectrum on a 37-degree tilted surface,
optionally interpolated to the specified wavelength(s).

Global (tilted) irradiance includes direct and diffuse irradiance from sky
and ground reflections, and is more formally called hemispherical
irradiance (on a tilted surface). In the context of photovoltaic systems
the irradiance on a flat receiver is frequently called plane-of-array (POA)
irradiance.

Parameters
----------
wavelength: 1-D sequence of numeric, optional
Wavelengths at which the spectrum is interpolated.
By default the 2002 wavelengths of the standard are returned. [nm].

Returns
-------
am15g: pandas.Series
The AM1.5g standard spectrum indexed by ``wavelength``. [W/(m²nm)].

Notes
-----
If ``wavelength`` is specified this function uses linear interpolation.

If the values in ``wavelength`` are too widely spaced, the integral of the
spectrum may deviate from the standard value of 1000.37 W/m².

The values in the data file provided with pvlib-python are copied from an
Excel file distributed by NREL, which is found here:
https://www.nrel.gov/grid/solar-resource/assets/data/astmg173.xls

More information about reference spectra is found here:
https://www.nrel.gov/grid/solar-resource/spectra-am1.5.html

See Also
--------
pvlib.spectrum.get_reference_spectra : reads also the direct and
extraterrestrial components of the spectrum.

References
----------
.. [1] ASTM "G173-03 Standard Tables for Reference Solar Spectral
Irradiances: Direct Normal and Hemispherical on 37° Tilted Surface."
""" # noqa: E501
# Contributed by Anton Driesse (@adriesse), PV Performance Labs. Aug. 2022
# modified by @echedey-ls, as a wrapper of spectrum.get_reference_spectra
standard = get_reference_spectra(wavelength, standard="ASTM G173-03")
return standard["global"]


def get_reference_spectra(wavelengths=None, standard="ASTM G173-03"):
r"""
Read a standard spectrum specified by ``standard``, optionally
Expand Down
11 changes: 3 additions & 8 deletions tests/spectrum/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@
import pandas as pd
import numpy as np
from pvlib import spectrum
from pvlib._deprecation import pvlibDeprecationWarning

from tests.conftest import assert_series_equal, fail_on_pvlib_version


@fail_on_pvlib_version('0.12')
def test_get_am15g():
def test_get_reference_spectra_am15g():
# test that the reference spectrum is read and interpolated correctly
with pytest.warns(pvlibDeprecationWarning,
match="get_reference_spectra instead"):
e = spectrum.get_am15g()
e = spectrum.get_reference_spectra()['global']
assert_equal(len(e), 2002)
assert_equal(np.sum(e.index), 2761442)
assert_approx_equal(np.sum(e), 1002.88, significant=6)

wavelength = [270, 850, 950, 1200, 1201.25, 4001]
expected = [0.0, 0.893720, 0.147260, 0.448250, 0.4371025, 0.0]

with pytest.warns(pvlibDeprecationWarning,
match="get_reference_spectra instead"):
e = spectrum.get_am15g(wavelength)
e = spectrum.get_reference_spectra(wavelength)['global']
assert_equal(len(e), len(wavelength))
assert_allclose(e, expected, rtol=1e-6)

Expand Down