Skip to content

Commit 763dd0a

Browse files
authored
spectral_factor_firstsolar: rename pw to precipitable_water (#1768)
* rename parameter, and docstring cleanup * whatsnew * edits from review * update tests
1 parent 9800c6f commit 763dd0a

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Breaking Changes
1010
* Modified the ``surface_azimuth`` parameter in :py:func:`pvlib.iotools.get_pvgis_hourly` to conform to the
1111
pvlib azimuth convention (counterclockwise from north). Previously 0 degrees represented south.
1212
(:issue:`1724`, :pull:`1739`)
13+
* For consistency with the rest of pvlib, the ``pw`` parameters are renamed to
14+
``precipitable_water`` in :py:func:`pvlib.spectrum.spectral_factor_firstsolar`.
15+
(:pull:`1768`)
1316
* For consistency with the rest of pvlib, the ``tilt`` parameter is renamed
1417
to ``surface_tilt`` in :py:func:`pvlib.soiling.hsu`. (:issue:`1717`, :pull:`1738`)
1518

pvlib/spectrum/mismatch.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ def integrate(e):
239239
return smm
240240

241241

242-
def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None,
243-
coefficients=None, min_pw=0.1, max_pw=8):
242+
def spectral_factor_firstsolar(precipitable_water, airmass_absolute,
243+
module_type=None, coefficients=None,
244+
min_precipitable_water=0.1,
245+
max_precipitable_water=8):
244246
r"""
245247
Spectral mismatch modifier based on precipitable water and absolute
246248
(pressure-adjusted) airmass.
@@ -277,21 +279,13 @@ def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None,
277279
278280
Parameters
279281
----------
280-
pw : array-like
282+
precipitable_water : numeric
281283
atmospheric precipitable water. [cm]
282284
283-
airmass_absolute : array-like
285+
airmass_absolute : numeric
284286
absolute (pressure-adjusted) airmass. [unitless]
285287
286-
min_pw : float, default 0.1
287-
minimum atmospheric precipitable water. Any pw value lower than min_pw
288-
is set to min_pw to avoid model divergence. [cm]
289-
290-
max_pw : float, default 8
291-
maximum atmospheric precipitable water. Any pw value higher than max_pw
292-
is set to NaN to avoid model divergence. [cm]
293-
294-
module_type : None or string, default None
288+
module_type : str, optional
295289
a string specifying a cell type. Values of 'cdte', 'monosi', 'xsi',
296290
'multisi', and 'polysi' (can be lower or upper case). If provided,
297291
module_type selects default coefficients for the following modules:
@@ -307,7 +301,7 @@ def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None,
307301
Manufacturer 2 Model C from [3]_. The spectral response (SR) of CIGS
308302
and a-Si modules used to derive coefficients can be found in [4]_
309303
310-
coefficients : None or array-like, default None
304+
coefficients : array-like, optional
311305
Allows for entry of user-defined spectral correction
312306
coefficients. Coefficients must be of length 6. Derivation of
313307
coefficients requires use of SMARTS and PV module quantum
@@ -317,10 +311,20 @@ def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None,
317311
modules with very similar quantum efficiency should be similar,
318312
in most cases limiting the need for module specific coefficients.
319313
314+
min_precipitable_water : float, default 0.1
315+
minimum atmospheric precipitable water. Any ``precipitable_water``
316+
value lower than ``min_precipitable_water``
317+
is set to ``min_precipitable_water`` to avoid model divergence. [cm]
318+
319+
max_precipitable_water : float, default 8
320+
maximum atmospheric precipitable water. Any ``precipitable_water``
321+
value greater than ``max_precipitable_water``
322+
is set to ``np.nan`` to avoid model divergence. [cm]
323+
320324
Returns
321325
-------
322326
modifier: array-like
323-
spectral mismatch factor (unitless) which is can be multiplied
327+
spectral mismatch factor (unitless) which can be multiplied
324328
with broadband irradiance reaching a module's cells to estimate
325329
effective irradiance, i.e., the irradiance that is converted to
326330
electrical current.
@@ -347,16 +351,16 @@ def spectral_factor_firstsolar(pw, airmass_absolute, module_type=None,
347351
# *** Pw ***
348352
# Replace Pw Values below 0.1 cm with 0.1 cm to prevent model from
349353
# diverging"
350-
pw = np.atleast_1d(pw)
354+
pw = np.atleast_1d(precipitable_water)
351355
pw = pw.astype('float64')
352-
if np.min(pw) < min_pw:
353-
pw = np.maximum(pw, min_pw)
354-
warn(f'Exceptionally low pw values replaced with {min_pw} cm to '
355-
'prevent model divergence')
356+
if np.min(pw) < min_precipitable_water:
357+
pw = np.maximum(pw, min_precipitable_water)
358+
warn('Exceptionally low pw values replaced with '
359+
f'{min_precipitable_water} cm to prevent model divergence')
356360

357361
# Warn user about Pw data that is exceptionally high
358-
if np.max(pw) > max_pw:
359-
pw[pw > max_pw] = np.nan
362+
if np.max(pw) > max_precipitable_water:
363+
pw[pw > max_precipitable_water] = np.nan
360364
warn('Exceptionally high pw values replaced by np.nan: '
361365
'check input data.')
362366

pvlib/tests/test_spectrum.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def test_spectral_factor_firstsolar_range():
243243
expected = np.array([0.96080878, 1.03055092, np.nan])
244244
assert_allclose(out, expected, atol=1e-3)
245245
with pytest.warns(UserWarning, match='Exceptionally high pw values'):
246-
out = spectrum.spectral_factor_firstsolar(6, 1.5, max_pw=5,
246+
out = spectrum.spectral_factor_firstsolar(6, 1.5,
247+
max_precipitable_water=5,
247248
module_type='monosi')
248249
with pytest.warns(UserWarning, match='Exceptionally low pw values'):
249250
out = spectrum.spectral_factor_firstsolar(np.array([0, 3, 8]),
@@ -252,7 +253,8 @@ def test_spectral_factor_firstsolar_range():
252253
expected = np.array([0.96080878, 1.03055092, 1.04932727])
253254
assert_allclose(out, expected, atol=1e-3)
254255
with pytest.warns(UserWarning, match='Exceptionally low pw values'):
255-
out = spectrum.spectral_factor_firstsolar(0.2, 1.5, min_pw=1,
256+
out = spectrum.spectral_factor_firstsolar(0.2, 1.5,
257+
min_precipitable_water=1,
256258
module_type='monosi')
257259

258260

0 commit comments

Comments
 (0)