Skip to content

Commit 432c3b3

Browse files
authored
Remove expired read_tmy3 deprecations (#2408)
* nix `recolumn`; default `map_variables` to `True` * ditch the associated tests * whatsnew * remove unused imports * more whatsnew
1 parent ae7de97 commit 432c3b3

File tree

3 files changed

+5
-88
lines changed

3 files changed

+5
-88
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ 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`)
1517
* Remove :py:func:`!pvlib.atmosphere.first_solar_spectral_correction`, deprecated in v0.10.0.
1618
Use :py:func:`~pvlib.spectrum.spectral_factor_firstsolar` instead. (:issue:`2130`, :pull:`2131`)
1719

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,

0 commit comments

Comments
 (0)