Skip to content

Commit f90e0b9

Browse files
committed
change new names to sapm and first_solar
in coordination with pvlib#1658, drop "spectral_correction" from the new function names
1 parent 6d4aa00 commit f90e0b9

File tree

8 files changed

+41
-45
lines changed

8 files changed

+41
-45
lines changed

docs/sphinx/source/reference/effects_on_pv_system_output/spectrum.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Spectrum
1010
spectrum.get_example_spectral_response
1111
spectrum.get_am15g
1212
spectrum.calc_spectral_mismatch_field
13-
spectrum.first_solar_spectral_correction
14-
spectrum.sapm_spectral_correction
13+
spectrum.first_solar
14+
spectrum.sapm

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Deprecations
1414
~~~~~~~~~~~~
1515
* Functions for calculating spectral modifiers have been moved to :py:mod:`pvlib.spectrum`:
1616
``pvlib.atmosphere.first_solar_spectral_correction`` is now
17-
:py:func:`pvlib.spectrum.first_solar_spectral_correction` and
17+
:py:func:`pvlib.spectrum.first_solar` and
1818
``pvlib.pvsystem.sapm_spectral_loss`` is now
19-
:py:func:`pvlib.spectrum.sapm_spectral_correction`. (:pull:`1628`)
19+
:py:func:`pvlib.spectrum.sapm`. (:pull:`1628`)
2020

2121

2222
Enhancements

pvlib/atmosphere.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ def gueymard94_pw(temp_air, relative_humidity):
323323

324324
first_solar_spectral_correction = deprecated(
325325
since='0.9.5',
326-
alternative='pvlib.spectrum.first_solar_spectral_correction'
327-
)(pvlib.spectrum.first_solar_spectral_correction)
326+
alternative='pvlib.spectrum.first_solar'
327+
)(pvlib.spectrum.first_solar)
328328

329329

330330
def bird_hulstrom80_aod_bb(aod380, aod500):

pvlib/pvsystem.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def sapm_celltemp(self, poa_global, temp_air, wind_speed):
672672
@_unwrap_single_value
673673
def sapm_spectral_loss(self, airmass_absolute):
674674
"""
675-
Use the :py:func:`pvlib.spectrum.sapm_spectral_correction` function,
675+
Use the :py:func:`pvlib.spectrum.sapm` function,
676676
the input parameters, and ``self.module_parameters`` to calculate F1.
677677
678678
Parameters
@@ -686,8 +686,7 @@ def sapm_spectral_loss(self, airmass_absolute):
686686
The SAPM spectral loss coefficient.
687687
"""
688688
return tuple(
689-
spectrum.sapm_spectral_correction(airmass_absolute,
690-
array.module_parameters)
689+
spectrum.sapm(airmass_absolute, array.module_parameters)
691690
for array in self.arrays
692691
)
693692

@@ -885,7 +884,7 @@ def noct_sam_celltemp(self, poa_global, temp_air, wind_speed,
885884
@_unwrap_single_value
886885
def first_solar_spectral_loss(self, pw, airmass_absolute):
887886
"""
888-
Use :py:func:`pvlib.spectrum.first_solar_spectral_correction` to
887+
Use :py:func:`pvlib.spectrum.first_solar` to
889888
calculate the spectral loss modifier. The model coefficients are
890889
specific to the module's cell type, and are determined by searching
891890
for one of the following keys in self.module_parameters (in order):
@@ -926,9 +925,8 @@ def _spectral_correction(array, pw):
926925
module_type = array._infer_cell_type()
927926
coefficients = None
928927

929-
return spectrum.first_solar_spectral_correction(
930-
pw, airmass_absolute,
931-
module_type, coefficients
928+
return spectrum.first_solar(
929+
pw, airmass_absolute, module_type, coefficients
932930
)
933931
return tuple(
934932
itertools.starmap(_spectral_correction, zip(self.arrays, pw))
@@ -2601,8 +2599,8 @@ def sapm(effective_irradiance, temp_cell, module):
26012599

26022600
sapm_spectral_loss = deprecated(
26032601
since='0.9.5',
2604-
alternative='pvlib.spectrum.sapm_spectral_correction'
2605-
)(spectrum.sapm_spectral_correction)
2602+
alternative='pvlib.spectrum.sapm'
2603+
)(spectrum.sapm)
26062604

26072605

26082606
def sapm_effective_irradiance(poa_direct, poa_diffuse, airmass_absolute, aoi,
@@ -2662,11 +2660,11 @@ def sapm_effective_irradiance(poa_direct, poa_diffuse, airmass_absolute, aoi,
26622660
See also
26632661
--------
26642662
pvlib.iam.sapm
2665-
pvlib.spectrum.sapm_spectral_correction
2663+
pvlib.spectrum.sapm
26662664
pvlib.pvsystem.sapm
26672665
"""
26682666

2669-
F1 = spectrum.sapm_spectral_correction(airmass_absolute, module)
2667+
F1 = spectrum.sapm(airmass_absolute, module)
26702668
F2 = iam.sapm(aoi, module)
26712669

26722670
Ee = F1 * (poa_direct * F2 + module['FD'] * poa_diffuse)

pvlib/spectrum/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from pvlib.spectrum.spectrl2 import spectrl2 # noqa: F401
22
from pvlib.spectrum.mismatch import ( # noqa: F401
33
calc_spectral_mismatch_field,
4-
first_solar_spectral_correction,
4+
first_solar,
55
get_am15g,
66
get_example_spectral_response,
7-
sapm_spectral_correction,
7+
sapm,
88
)

pvlib/spectrum/mismatch.py

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

241241

242-
def first_solar_spectral_correction(pw, airmass_absolute,
243-
module_type=None, coefficients=None,
244-
min_pw=0.1, max_pw=8):
242+
def first_solar(pw, airmass_absolute, module_type=None, coefficients=None,
243+
min_pw=0.1, max_pw=8):
245244
r"""
246245
Spectral mismatch modifier based on precipitable water and absolute
247246
(pressure-adjusted) airmass.
@@ -410,7 +409,7 @@ def first_solar_spectral_correction(pw, airmass_absolute,
410409
return modifier
411410

412411

413-
def sapm_spectral_correction(airmass_absolute, module):
412+
def sapm(airmass_absolute, module):
414413
"""
415414
Calculates the SAPM spectral loss coefficient, F1.
416415

pvlib/tests/test_atmosphere.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_gueymard94_pw():
8989

9090
def test_first_solar_spectral_correction_deprecated():
9191
with pytest.warns(pvlibDeprecationWarning,
92-
match='Use pvlib.spectrum.first_solar_spectral'):
92+
match='Use pvlib.spectrum.first_solar'):
9393
atmosphere.first_solar_spectral_correction(1, 1, 'cdte')
9494

9595

pvlib/tests/test_spectrum.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,65 +195,64 @@ def test_calc_spectral_mismatch_field(spectrl2_data):
195195
[ 1.11225204, 0.93665901, 0.78487953],
196196
[ 1.14555295, 0.97084011, 0.81994083]]))
197197
])
198-
def test_first_solar_spectral_correction(module_type, expect):
198+
def test_first_solar(module_type, expect):
199199
ams = np.array([1, 3, 5])
200200
pws = np.array([1, 3, 5])
201201
ams, pws = np.meshgrid(ams, pws)
202-
out = spectrum.first_solar_spectral_correction(pws, ams, module_type)
202+
out = spectrum.first_solar(pws, ams, module_type)
203203
assert_allclose(out, expect, atol=0.001)
204204

205205

206-
def test_first_solar_spectral_correction_supplied():
206+
def test_first_solar_supplied():
207207
# use the cdte coeffs
208208
coeffs = (0.87102, -0.040543, -0.00929202, 0.10052, 0.073062, -0.0034187)
209-
out = spectrum.first_solar_spectral_correction(1, 1, coefficients=coeffs)
209+
out = spectrum.first_solar(1, 1, coefficients=coeffs)
210210
expected = 0.99134828
211211
assert_allclose(out, expected, atol=1e-3)
212212

213213

214-
def test_first_solar_spectral_correction_ambiguous():
214+
def test_first_solar_ambiguous():
215215
with pytest.raises(TypeError):
216-
spectrum.first_solar_spectral_correction(1, 1)
216+
spectrum.first_solar(1, 1)
217217

218218

219-
def test_first_solar_spectral_correction_ambiguous_both():
219+
def test_first_solar_ambiguous_both():
220220
# use the cdte coeffs
221221
coeffs = (0.87102, -0.040543, -0.00929202, 0.10052, 0.073062, -0.0034187)
222222
with pytest.raises(TypeError):
223-
spectrum.first_solar_spectral_correction(1, 1, 'cdte',
224-
coefficients=coeffs)
223+
spectrum.first_solar(1, 1, 'cdte', coefficients=coeffs)
225224

226225

227-
def test_first_solar_spectral_correction_large_airmass():
226+
def test_first_solar_large_airmass():
228227
# test that airmass > 10 is treated same as airmass==10
229-
m_eq10 = spectrum.first_solar_spectral_correction(1, 10, 'monosi')
230-
m_gt10 = spectrum.first_solar_spectral_correction(1, 15, 'monosi')
228+
m_eq10 = spectrum.first_solar(1, 10, 'monosi')
229+
m_gt10 = spectrum.first_solar(1, 15, 'monosi')
231230
assert_allclose(m_eq10, m_gt10)
232231

233232

234-
def test_first_solar_spectral_correction_low_airmass():
233+
def test_first_solar_low_airmass():
235234
with pytest.warns(UserWarning, match='Exceptionally low air mass'):
236-
_ = spectrum.first_solar_spectral_correction(1, 0.1, 'monosi')
235+
_ = spectrum.first_solar(1, 0.1, 'monosi')
237236

238237

239-
def test_first_solar_spectral_correction_range():
238+
def test_first_solar_range():
240239
with pytest.warns(UserWarning, match='Exceptionally high pw values'):
241-
out = spectrum.first_solar_spectral_correction(np.array([.1, 3, 10]),
240+
out = spectrum.first_solar(np.array([.1, 3, 10]),
242241
np.array([1, 3, 5]),
243242
module_type='monosi')
244243
expected = np.array([0.96080878, 1.03055092, np.nan])
245244
assert_allclose(out, expected, atol=1e-3)
246245
with pytest.warns(UserWarning, match='Exceptionally high pw values'):
247-
out = spectrum.first_solar_spectral_correction(6, 1.5, max_pw=5,
246+
out = spectrum.first_solar(6, 1.5, max_pw=5,
248247
module_type='monosi')
249248
with pytest.warns(UserWarning, match='Exceptionally low pw values'):
250-
out = spectrum.first_solar_spectral_correction(np.array([0, 3, 8]),
249+
out = spectrum.first_solar(np.array([0, 3, 8]),
251250
np.array([1, 3, 5]),
252251
module_type='monosi')
253252
expected = np.array([0.96080878, 1.03055092, 1.04932727])
254253
assert_allclose(out, expected, atol=1e-3)
255254
with pytest.warns(UserWarning, match='Exceptionally low pw values'):
256-
out = spectrum.first_solar_spectral_correction(0.2, 1.5, min_pw=1,
255+
out = spectrum.first_solar(0.2, 1.5, min_pw=1,
257256
module_type='monosi')
258257

259258

@@ -262,9 +261,9 @@ def test_first_solar_spectral_correction_range():
262261
(np.array([[10, np.nan]]), np.array([[0.999535, 0]])),
263262
(pd.Series([5]), pd.Series([1.0387675]))
264263
])
265-
def test_sapm_spectral_loss(sapm_module_params, airmass, expected):
264+
def test_sapm(sapm_module_params, airmass, expected):
266265

267-
out = spectrum.sapm_spectral_correction(airmass, sapm_module_params)
266+
out = spectrum.sapm(airmass, sapm_module_params)
268267

269268
if isinstance(airmass, pd.Series):
270269
assert_series_equal(out, expected, check_less_precise=4)

0 commit comments

Comments
 (0)