From d9b99fe8504a0b8d849cc4416e4f28e5fc4cde98 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 14:19:02 -0400 Subject: [PATCH 1/7] remove get_am15g --- pvlib/spectrum/irradiance.py | 63 ------------------------------------ 1 file changed, 63 deletions(-) diff --git a/pvlib/spectrum/irradiance.py b/pvlib/spectrum/irradiance.py index 14b2da27ba..c03c99872d 100644 --- a/pvlib/spectrum/irradiance.py +++ b/pvlib/spectrum/irradiance.py @@ -4,7 +4,6 @@ """ import pvlib -from pvlib._deprecation import deprecated import numpy as np import pandas as pd from pathlib import Path @@ -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 From 4f340e2b898c5c20712f04d8f65fc0b7aa1fe55d Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 14:19:27 -0400 Subject: [PATCH 2/7] update associated tests --- tests/spectrum/test_irradiance.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/spectrum/test_irradiance.py b/tests/spectrum/test_irradiance.py index f53948dd82..213346e071 100644 --- a/tests/spectrum/test_irradiance.py +++ b/tests/spectrum/test_irradiance.py @@ -3,17 +3,14 @@ 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) @@ -21,9 +18,7 @@ def test_get_am15g(): 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) From 27a4774d43db91e68c3e16653c2bce0ce32f21e5 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 14:19:38 -0400 Subject: [PATCH 3/7] remove from spectrum init --- pvlib/spectrum/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/spectrum/__init__.py b/pvlib/spectrum/__init__.py index e282afc01f..59f9db9582 100644 --- a/pvlib/spectrum/__init__.py +++ b/pvlib/spectrum/__init__.py @@ -8,7 +8,6 @@ spectral_factor_jrc, ) from pvlib.spectrum.irradiance import ( # noqa: F401 - get_am15g, get_reference_spectra, average_photon_energy, ) From 572fcfc5bf93652a3d301536ab95d1a87950841d Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 14:19:47 -0400 Subject: [PATCH 4/7] remove from API reference docs --- .../source/reference/effects_on_pv_system_output/spectrum.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst b/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst index 23b5f5bb6d..982bc91742 100644 --- a/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst +++ b/docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst @@ -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 From 2215b603809907ef5d158dc36dea8bd47b73ab65 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 14:19:56 -0400 Subject: [PATCH 5/7] whatsnew --- docs/sphinx/source/whatsnew/v0.11.3.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.11.3.rst b/docs/sphinx/source/whatsnew/v0.11.3.rst index 62c7c29c57..0d072796b7 100644 --- a/docs/sphinx/source/whatsnew/v0.11.3.rst +++ b/docs/sphinx/source/whatsnew/v0.11.3.rst @@ -12,6 +12,8 @@ Breaking Changes * Users must now provide ModelChain.spectral_model, or the 'no_loss' spectral model is assumed. pvlib.modelchain.ModelChain no longer attempts to infer the spectral model from PVSystem attributes. (:issue:`2017`, :pull:`2253`) +* Remove deprecated :py:func:`!pvlib.spectrum.get_am15g` function; use + :py:func:`~pvlib.spectrum.get_reference_spectra` instead. (:pull:`2409`) Bug fixes ~~~~~~~~~ From 02b978e67fd759d93dece10cf9ff39749eaa5568 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 15:10:34 -0400 Subject: [PATCH 6/7] exclamation marks in old whatsnew files --- docs/sphinx/source/whatsnew/v0.11.0.rst | 2 +- docs/sphinx/source/whatsnew/v0.9.3.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.0.rst b/docs/sphinx/source/whatsnew/v0.11.0.rst index 067094a014..219b57a059 100644 --- a/docs/sphinx/source/whatsnew/v0.11.0.rst +++ b/docs/sphinx/source/whatsnew/v0.11.0.rst @@ -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`) diff --git a/docs/sphinx/source/whatsnew/v0.9.3.rst b/docs/sphinx/source/whatsnew/v0.9.3.rst index 820ecc251d..4eed47638c 100644 --- a/docs/sphinx/source/whatsnew/v0.9.3.rst +++ b/docs/sphinx/source/whatsnew/v0.9.3.rst @@ -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: From ac760470e0793ae7401e15ffa4661d4535d86902 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 14 Mar 2025 15:16:48 -0400 Subject: [PATCH 7/7] I guess ! and ~ don't work together --- docs/sphinx/source/whatsnew/v0.9.3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.3.rst b/docs/sphinx/source/whatsnew/v0.9.3.rst index 4eed47638c..8e6f0e6a94 100644 --- a/docs/sphinx/source/whatsnew/v0.9.3.rst +++ b/docs/sphinx/source/whatsnew/v0.9.3.rst @@ -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: