Skip to content

Commit 647feac

Browse files
authored
Merge branch 'main' into am15g
2 parents ac76047 + 432c3b3 commit 647feac

File tree

8 files changed

+9
-108
lines changed

8 files changed

+9
-108
lines changed

docs/sphinx/source/reference/airmass_atmospheric.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Airmass and atmospheric models
1414
atmosphere.tdew_from_rh
1515
atmosphere.rh_from_tdew
1616
atmosphere.gueymard94_pw
17-
atmosphere.first_solar_spectral_correction
1817
atmosphere.bird_hulstrom80_aod_bb
1918
atmosphere.kasten96_lt
2019
atmosphere.angstrom_aod_at_lambda

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Deprecations
5353
deprecated. Use :py:func:`pvlib.pvsystem.v_from_i` and
5454
:py:func:`pvlib.pvsystem.i_from_v` instead. (:issue:`1626`, :pull:`1743`)
5555
* Functions for calculating spectral modifiers have been moved to :py:mod:`pvlib.spectrum`:
56-
:py:func:`pvlib.atmosphere.first_solar_spectral_correction` is deprecated and
56+
:py:func:`!pvlib.atmosphere.first_solar_spectral_correction` is deprecated and
5757
replaced by :py:func:`~pvlib.spectrum.spectral_factor_firstsolar`, and
5858
:py:func:`pvlib.pvsystem.sapm_spectral_loss` is deprecated and replaced by
5959
:py:func:`~pvlib.spectrum.spectral_factor_sapm`. (:pull:`1628`)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Breaking Changes
1212
* Users must now provide ModelChain.spectral_model, or the 'no_loss' spectral
1313
model is assumed. pvlib.modelchain.ModelChain no longer attempts to infer
1414
the spectral model from PVSystem attributes. (:issue:`2017`, :pull:`2253`)
15+
* :py:func:`~pvlib.iotools.read_tmy3` now defaults to ``map_variables=True``.
16+
Additionally, the deprecated ``recolumn`` parameter is now removed. (:issue:`2324`, :pull:`2408`)
17+
* Remove :py:func:`!pvlib.atmosphere.first_solar_spectral_correction`, deprecated in v0.10.0.
18+
Use :py:func:`~pvlib.spectrum.spectral_factor_firstsolar` instead. (:issue:`2130`, :pull:`2131`)
1519
* Remove deprecated :py:func:`!pvlib.spectrum.get_am15g` function; use
1620
:py:func:`~pvlib.spectrum.get_reference_spectra` instead. (:pull:`2409`)
1721

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ API Changes with Deprecations
104104
* Changes related to spectral modifier (:issue:`782`):
105105
* Changes to functions
106106
- Added the argument `pw_min` and `pw_max`, default values 0.1 and 8 resp.,
107-
to `atmosphere.first_solar_spectral_correction`. This function now returns NaN
107+
to :py:func:`!pvlib.atmosphere.first_solar_spectral_correction`. This function now returns NaN
108108
if pw value higher than `pw_max`.
109109
* The `times` keyword argument has been deprecated in the
110110
:py:meth:`pvlib.modelchain.ModelChain.run_model`,

pvlib/atmosphere.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
import numpy as np
88
import pandas as pd
9-
import pvlib
10-
11-
from pvlib._deprecation import deprecated
129

1310
APPARENT_ZENITH_MODELS = ('simple', 'kasten1966', 'kastenyoung1989',
1411
'gueymard1993', 'pickering2002')
@@ -416,12 +413,6 @@ def tdew_from_rh(temp_air, relative_humidity, coeff=(6.112, 17.62, 243.12)):
416413
return dewpoint
417414

418415

419-
first_solar_spectral_correction = deprecated(
420-
since='0.10.0',
421-
alternative='pvlib.spectrum.spectral_factor_firstsolar'
422-
)(pvlib.spectrum.spectral_factor_firstsolar)
423-
424-
425416
def bird_hulstrom80_aod_bb(aod380, aod500):
426417
"""
427418
Approximate broadband aerosol optical depth.

pvlib/iotools/tmy.py

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import datetime
44
import re
55
import pandas as pd
6-
import warnings
7-
from pvlib._deprecation import pvlibDeprecationWarning
86

97
# Dictionary mapping TMY3 names to pvlib names
108
VARIABLE_MAP = {
@@ -24,8 +22,7 @@
2422
}
2523

2624

27-
def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None,
28-
encoding=None):
25+
def read_tmy3(filename, coerce_year=None, map_variables=True, encoding=None):
2926
"""Read a TMY3 file into a pandas dataframe.
3027
3128
Note that values contained in the metadata dictionary are unchanged
@@ -44,13 +41,9 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None,
4441
If supplied, the year of the index will be set to ``coerce_year``, except
4542
for the last index value which will be set to the *next* year so that
4643
the index increases monotonically.
47-
map_variables : bool, optional
44+
map_variables : bool, default True
4845
When True, renames columns of the DataFrame to pvlib variable names
4946
where applicable. See variable :const:`VARIABLE_MAP`.
50-
recolumn : bool (deprecated, use map_variables instead)
51-
If ``True``, apply standard names to TMY3 columns. Typically this
52-
results in stripping the units from the column name.
53-
Cannot be used in combination with ``map_variables``.
5447
encoding : str, optional
5548
Encoding of the file. For files that contain non-UTF8 characters it may
5649
be necessary to specify an alternative encoding, e.g., for
@@ -233,74 +226,15 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None,
233226
# unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour'
234227
data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') \
235228
+ pd.to_timedelta(minutes, unit='min')
236-
# shouldnt' specify both recolumn and map_variables
237-
if recolumn is not None and map_variables is not None:
238-
msg = "`map_variables` and `recolumn` cannot both be specified"
239-
raise ValueError(msg)
240-
elif map_variables is None and recolumn is not None:
241-
warnings.warn(
242-
'The recolumn parameter is deprecated and will be removed in '
243-
'pvlib 0.11.0. Use `map_variables` instead, although note that '
244-
'its behavior is different from `recolumn`.',
245-
pvlibDeprecationWarning)
246-
elif map_variables is None and recolumn is None:
247-
warnings.warn(
248-
'TMY3 variable names will be renamed to pvlib conventions by '
249-
'default starting in pvlib 0.11.0. Specify map_variables=True '
250-
'to enable that behavior now, or specify map_variables=False '
251-
'to hide this warning.', pvlibDeprecationWarning)
229+
252230
if map_variables:
253231
data = data.rename(columns=VARIABLE_MAP)
254-
elif recolumn or (recolumn is None and map_variables is None):
255-
data = _recolumn(data)
256232

257233
data = data.tz_localize(int(meta['TZ'] * 3600))
258234

259235
return data, meta
260236

261237

262-
def _recolumn(tmy3_dataframe):
263-
"""
264-
Rename the columns of the TMY3 DataFrame.
265-
266-
Parameters
267-
----------
268-
tmy3_dataframe : DataFrame
269-
inplace : bool
270-
passed to DataFrame.rename()
271-
272-
Returns
273-
-------
274-
Recolumned DataFrame.
275-
"""
276-
# paste in the header as one long line
277-
raw_columns = 'ETR (W/m^2),ETRN (W/m^2),GHI (W/m^2),GHI source,GHI uncert (%),DNI (W/m^2),DNI source,DNI uncert (%),DHI (W/m^2),DHI source,DHI uncert (%),GH illum (lx),GH illum source,Global illum uncert (%),DN illum (lx),DN illum source,DN illum uncert (%),DH illum (lx),DH illum source,DH illum uncert (%),Zenith lum (cd/m^2),Zenith lum source,Zenith lum uncert (%),TotCld (tenths),TotCld source,TotCld uncert (code),OpqCld (tenths),OpqCld source,OpqCld uncert (code),Dry-bulb (C),Dry-bulb source,Dry-bulb uncert (code),Dew-point (C),Dew-point source,Dew-point uncert (code),RHum (%),RHum source,RHum uncert (code),Pressure (mbar),Pressure source,Pressure uncert (code),Wdir (degrees),Wdir source,Wdir uncert (code),Wspd (m/s),Wspd source,Wspd uncert (code),Hvis (m),Hvis source,Hvis uncert (code),CeilHgt (m),CeilHgt source,CeilHgt uncert (code),Pwat (cm),Pwat source,Pwat uncert (code),AOD (unitless),AOD source,AOD uncert (code),Alb (unitless),Alb source,Alb uncert (code),Lprecip depth (mm),Lprecip quantity (hr),Lprecip source,Lprecip uncert (code),PresWth (METAR code),PresWth source,PresWth uncert (code)' # noqa: E501
278-
279-
new_columns = [
280-
'ETR', 'ETRN', 'GHI', 'GHISource', 'GHIUncertainty',
281-
'DNI', 'DNISource', 'DNIUncertainty', 'DHI', 'DHISource',
282-
'DHIUncertainty', 'GHillum', 'GHillumSource', 'GHillumUncertainty',
283-
'DNillum', 'DNillumSource', 'DNillumUncertainty', 'DHillum',
284-
'DHillumSource', 'DHillumUncertainty', 'Zenithlum',
285-
'ZenithlumSource', 'ZenithlumUncertainty', 'TotCld', 'TotCldSource',
286-
'TotCldUncertainty', 'OpqCld', 'OpqCldSource', 'OpqCldUncertainty',
287-
'DryBulb', 'DryBulbSource', 'DryBulbUncertainty', 'DewPoint',
288-
'DewPointSource', 'DewPointUncertainty', 'RHum', 'RHumSource',
289-
'RHumUncertainty', 'Pressure', 'PressureSource',
290-
'PressureUncertainty', 'Wdir', 'WdirSource', 'WdirUncertainty',
291-
'Wspd', 'WspdSource', 'WspdUncertainty', 'Hvis', 'HvisSource',
292-
'HvisUncertainty', 'CeilHgt', 'CeilHgtSource', 'CeilHgtUncertainty',
293-
'Pwat', 'PwatSource', 'PwatUncertainty', 'AOD', 'AODSource',
294-
'AODUncertainty', 'Alb', 'AlbSource', 'AlbUncertainty',
295-
'Lprecipdepth', 'Lprecipquantity', 'LprecipSource',
296-
'LprecipUncertainty', 'PresWth', 'PresWthSource',
297-
'PresWthUncertainty']
298-
299-
mapping = dict(zip(raw_columns.split(','), new_columns))
300-
301-
return tmy3_dataframe.rename(columns=mapping)
302-
303-
304238
def read_tmy2(filename):
305239
"""
306240
Read a TMY2 file into a DataFrame.

tests/iotools/test_tmy.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import numpy as np
22
import pandas as pd
33
from pvlib.iotools import tmy
4-
from pvlib._deprecation import pvlibDeprecationWarning
54
from tests.conftest import TESTS_DATA_DIR, PVLIB_DATA_DIR
65
import pytest
7-
import warnings
86

97
# test the API works
108
from pvlib.iotools import read_tmy3
@@ -21,23 +19,11 @@ def test_read_tmy3():
2119
tmy.read_tmy3(TMY3_TESTFILE, map_variables=False)
2220

2321

24-
def test_read_tmy3_recolumn():
25-
with warnings.catch_warnings():
26-
warnings.simplefilter("ignore")
27-
data, meta = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True)
28-
assert 'GHISource' in data.columns
29-
30-
3122
def test_read_tmy3_norecolumn():
3223
data, _ = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False)
3324
assert 'GHI source' in data.columns
3425

3526

36-
def test_read_tmy3_raise_valueerror():
37-
with pytest.raises(ValueError, match='`map_variables` and `recolumn`'):
38-
_ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True, map_variables=True)
39-
40-
4127
def test_read_tmy3_map_variables():
4228
data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=True)
4329
assert 'ghi' in data.columns
@@ -55,11 +41,6 @@ def test_read_tmy3_map_variables():
5541
assert 'precipitable_water' in data.columns
5642

5743

58-
def test_read_tmy3_map_variables_deprecating_warning():
59-
with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'):
60-
data, meta = tmy.read_tmy3(TMY3_TESTFILE)
61-
62-
6344
def test_read_tmy3_coerce_year():
6445
coerce_year = 1987
6546
data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year,

tests/test_atmosphere.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from pvlib import atmosphere
1111

12-
from pvlib._deprecation import pvlibDeprecationWarning
13-
1412

1513
def test_pres2alt():
1614
out = atmosphere.pres2alt(np.array([10000, 90000, 101325]))
@@ -235,12 +233,6 @@ def test_tdew_from_rh():
235233
assert np.isclose(dewpoint_float, dewpoint.iloc[0])
236234

237235

238-
def test_first_solar_spectral_correction_deprecated():
239-
with pytest.warns(pvlibDeprecationWarning,
240-
match='Use pvlib.spectrum.spectral_factor_firstsolar'):
241-
atmosphere.first_solar_spectral_correction(1, 1, 'cdte')
242-
243-
244236
def test_kasten96_lt():
245237
"""Test Linke turbidity factor calculated from AOD, Pwat and AM"""
246238
amp = np.array([1, 3, 5])

0 commit comments

Comments
 (0)