Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.13.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~
Expand All @@ -45,3 +46,4 @@ Maintenance
Contributors
~~~~~~~~~~~~
* Elijah Passmore (:ghuser:`eljpsm`)
* Kevin Anderson (:ghuser:`kandersolar`)
26 changes: 7 additions & 19 deletions pvlib/spectrum/mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = (
Expand Down
20 changes: 3 additions & 17 deletions tests/spectrum/test_mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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', [
Expand Down
Loading