Skip to content

Commit ded2867

Browse files
kandersolarRDaxini
andauthored
Remove out-of-range warnings from pvlib.spectrum.spectral_factor_firstsolar (#2512)
* remove warnings * drop warning checks in tests * whatsnew * Update docs/sphinx/source/whatsnew/v0.13.1.rst Co-authored-by: RDaxini <[email protected]> --------- Co-authored-by: RDaxini <[email protected]>
1 parent 59d2e8e commit ded2867

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Enhancements
2121
~~~~~~~~~~~~
2222
* Add :py:func:`pvlib.iotools.get_nasa_power` to retrieve data from NASA POWER free API.
2323
(:pull:`2500`)
24+
* :py:func:`pvlib.spectrum.spectral_factor_firstsolar` no longer emits warnings
25+
when airmass and precipitable water values fall out of range. (:pull:`2512`)
2426

2527
Documentation
2628
~~~~~~~~~~~~~
@@ -51,3 +53,4 @@ Contributors
5153
* Ioannis Sifnaios (:ghuser:`IoannisSifnaios`)
5254
* Rajiv Daxini (:ghuser:`RDaxini`)
5355
* Omar Bahamida (:ghuser:`OmarBahamida`)
56+
* Kevin Anderson (:ghuser:`kandersolar`)

pvlib/spectrum/mismatch.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,27 +239,15 @@ def spectral_factor_firstsolar(precipitable_water, airmass_absolute,
239239
"""
240240
pw = np.atleast_1d(precipitable_water)
241241
pw = pw.astype('float64')
242-
if np.min(pw) < min_precipitable_water:
243-
pw = np.maximum(pw, min_precipitable_water)
244-
warn('Low precipitable water values replaced with '
245-
f'{min_precipitable_water} cm in the calculation of spectral '
246-
'mismatch.')
247-
248-
if np.max(pw) > max_precipitable_water:
249-
pw[pw > max_precipitable_water] = np.nan
250-
warn('High precipitable water values replaced with np.nan in '
251-
'the calculation of spectral mismatch.')
242+
pw = np.maximum(pw, min_precipitable_water)
243+
pw[pw > max_precipitable_water] = np.nan
252244

253245
airmass_absolute = np.minimum(airmass_absolute, max_airmass_absolute)
254-
255-
if np.min(airmass_absolute) < min_airmass_absolute:
256-
airmass_absolute = np.maximum(airmass_absolute, min_airmass_absolute)
257-
warn('Low airmass values replaced with 'f'{min_airmass_absolute} in '
258-
'the calculation of spectral mismatch.')
259-
# pvlib.atmosphere.get_absolute_airmass(1,
260-
# pvlib.atmosphere.alt2pres(4340)) = 0.58 Elevation of
261-
# Mina Pirquita, Argentian = 4340 m. Highest elevation city with
262-
# population over 50,000.
246+
# pvlib.atmosphere.get_absolute_airmass(1,
247+
# pvlib.atmosphere.alt2pres(4340)) = 0.58 Elevation of
248+
# Mina Pirquita, Argentian = 4340 m. Highest elevation city with
249+
# population over 50,000.
250+
airmass_absolute = np.maximum(airmass_absolute, min_airmass_absolute)
263251

264252
_coefficients = {}
265253
_coefficients['cdte'] = (

tests/spectrum/test_mismatch.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ def test_spectral_factor_firstsolar_low_airmass():
112112
m_eq58 = spectrum.spectral_factor_firstsolar(1, 0.58, 'monosi')
113113
m_lt58 = spectrum.spectral_factor_firstsolar(1, 0.1, 'monosi')
114114
assert_allclose(m_eq58, m_lt58)
115-
with pytest.warns(UserWarning, match='Low airmass values replaced'):
116-
_ = spectrum.spectral_factor_firstsolar(1, 0.1, 'monosi')
117115

118116

119117
def test_spectral_factor_firstsolar_range():
@@ -122,23 +120,11 @@ def test_spectral_factor_firstsolar_range():
122120
module_type='monosi')
123121
expected = np.array([0.96080878, 1.03055092, np.nan])
124122
assert_allclose(out, expected, atol=1e-3)
125-
with pytest.warns(UserWarning, match='High precipitable water values '
126-
'replaced'):
127-
out = spectrum.spectral_factor_firstsolar(6, 1.5,
128-
max_precipitable_water=5,
129-
module_type='monosi')
130-
with pytest.warns(UserWarning, match='Low precipitable water values '
131-
'replaced'):
132-
out = spectrum.spectral_factor_firstsolar(np.array([0, 3, 8]),
133-
np.array([1, 3, 5]),
134-
module_type='monosi')
123+
out = spectrum.spectral_factor_firstsolar(np.array([0, 3, 8]),
124+
np.array([1, 3, 5]),
125+
module_type='monosi')
135126
expected = np.array([0.96080878, 1.03055092, 1.04932727])
136127
assert_allclose(out, expected, atol=1e-3)
137-
with pytest.warns(UserWarning, match='Low precipitable water values '
138-
'replaced'):
139-
out = spectrum.spectral_factor_firstsolar(0.2, 1.5,
140-
min_precipitable_water=1,
141-
module_type='monosi')
142128

143129

144130
@pytest.mark.parametrize('airmass,expected', [

0 commit comments

Comments
 (0)