From fa5fa80dc50eae0da97b56759e7b9c28323a0aee Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 28 Jul 2025 16:45:26 -0400 Subject: [PATCH 1/4] remove warnings --- pvlib/spectrum/mismatch.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/pvlib/spectrum/mismatch.py b/pvlib/spectrum/mismatch.py index 980f0d0165..9f68d77c83 100644 --- a/pvlib/spectrum/mismatch.py +++ b/pvlib/spectrum/mismatch.py @@ -239,27 +239,15 @@ def spectral_factor_firstsolar(precipitable_water, airmass_absolute, """ pw = np.atleast_1d(precipitable_water) pw = pw.astype('float64') - if np.min(pw) < min_precipitable_water: - pw = np.maximum(pw, min_precipitable_water) - warn('Low precipitable water values replaced with ' - f'{min_precipitable_water} cm in the calculation of spectral ' - 'mismatch.') - - if np.max(pw) > max_precipitable_water: - pw[pw > max_precipitable_water] = np.nan - warn('High precipitable water values replaced with np.nan in ' - 'the calculation of spectral mismatch.') + pw = np.maximum(pw, min_precipitable_water) + pw[pw > max_precipitable_water] = np.nan airmass_absolute = np.minimum(airmass_absolute, max_airmass_absolute) - - if np.min(airmass_absolute) < min_airmass_absolute: - airmass_absolute = np.maximum(airmass_absolute, min_airmass_absolute) - warn('Low airmass values replaced with 'f'{min_airmass_absolute} in ' - 'the calculation of spectral mismatch.') - # pvlib.atmosphere.get_absolute_airmass(1, - # pvlib.atmosphere.alt2pres(4340)) = 0.58 Elevation of - # Mina Pirquita, Argentian = 4340 m. Highest elevation city with - # population over 50,000. + # pvlib.atmosphere.get_absolute_airmass(1, + # pvlib.atmosphere.alt2pres(4340)) = 0.58 Elevation of + # Mina Pirquita, Argentian = 4340 m. Highest elevation city with + # population over 50,000. + airmass_absolute = np.maximum(airmass_absolute, min_airmass_absolute) _coefficients = {} _coefficients['cdte'] = ( From 7df44432afc3f2a7c1c3b965dc099dda569cf852 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 28 Jul 2025 16:50:35 -0400 Subject: [PATCH 2/4] drop warning checks in tests --- tests/spectrum/test_mismatch.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tests/spectrum/test_mismatch.py b/tests/spectrum/test_mismatch.py index 69ed476f59..edd780b2b1 100644 --- a/tests/spectrum/test_mismatch.py +++ b/tests/spectrum/test_mismatch.py @@ -112,8 +112,6 @@ def test_spectral_factor_firstsolar_low_airmass(): m_eq58 = spectrum.spectral_factor_firstsolar(1, 0.58, 'monosi') m_lt58 = spectrum.spectral_factor_firstsolar(1, 0.1, 'monosi') assert_allclose(m_eq58, m_lt58) - with pytest.warns(UserWarning, match='Low airmass values replaced'): - _ = spectrum.spectral_factor_firstsolar(1, 0.1, 'monosi') def test_spectral_factor_firstsolar_range(): @@ -122,23 +120,11 @@ def test_spectral_factor_firstsolar_range(): module_type='monosi') expected = np.array([0.96080878, 1.03055092, np.nan]) assert_allclose(out, expected, atol=1e-3) - with pytest.warns(UserWarning, match='High precipitable water values ' - 'replaced'): - out = spectrum.spectral_factor_firstsolar(6, 1.5, - max_precipitable_water=5, - module_type='monosi') - with pytest.warns(UserWarning, match='Low precipitable water values ' - 'replaced'): - out = spectrum.spectral_factor_firstsolar(np.array([0, 3, 8]), - np.array([1, 3, 5]), - module_type='monosi') + out = spectrum.spectral_factor_firstsolar(np.array([0, 3, 8]), + np.array([1, 3, 5]), + module_type='monosi') expected = np.array([0.96080878, 1.03055092, 1.04932727]) assert_allclose(out, expected, atol=1e-3) - with pytest.warns(UserWarning, match='Low precipitable water values ' - 'replaced'): - out = spectrum.spectral_factor_firstsolar(0.2, 1.5, - min_precipitable_water=1, - module_type='monosi') @pytest.mark.parametrize('airmass,expected', [ From 1e8f79dc48957907b0f50796a6eb150d4744f07f Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 28 Jul 2025 17:01:33 -0400 Subject: [PATCH 3/4] whatsnew --- docs/sphinx/source/whatsnew/v0.13.1.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.13.1.rst b/docs/sphinx/source/whatsnew/v0.13.1.rst index 9c50d00bbb..8b6b489c8e 100644 --- a/docs/sphinx/source/whatsnew/v0.13.1.rst +++ b/docs/sphinx/source/whatsnew/v0.13.1.rst @@ -19,7 +19,8 @@ Bug fixes Enhancements ~~~~~~~~~~~~ - +* :py:func:`pvlib.spectrum.spectral_factor_firstsolar` no longer emits warnings + when airmass and precipitable water values fall out of range. (:pull:`2512`) Documentation ~~~~~~~~~~~~~ @@ -45,3 +46,4 @@ Maintenance Contributors ~~~~~~~~~~~~ * Elijah Passmore (:ghuser:`eljpsm`) +* Kevin Anderson (:ghuser:`kandersolar`) From 461614a18d5f819f5d3528ecf576d62cf48affb4 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 28 Jul 2025 17:21:40 -0400 Subject: [PATCH 4/4] Update docs/sphinx/source/whatsnew/v0.13.1.rst Co-authored-by: RDaxini <143435106+RDaxini@users.noreply.github.com> --- docs/sphinx/source/whatsnew/v0.13.1.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sphinx/source/whatsnew/v0.13.1.rst b/docs/sphinx/source/whatsnew/v0.13.1.rst index 8b6b489c8e..21fa97c296 100644 --- a/docs/sphinx/source/whatsnew/v0.13.1.rst +++ b/docs/sphinx/source/whatsnew/v0.13.1.rst @@ -20,6 +20,7 @@ Bug fixes Enhancements ~~~~~~~~~~~~ * :py:func:`pvlib.spectrum.spectral_factor_firstsolar` no longer emits warnings + when airmass and precipitable water values fall out of range. (:pull:`2512`) Documentation