Skip to content

Commit 0e60277

Browse files
Pratham ChauhanPratham Chauhan
Pratham Chauhan
authored and
Pratham Chauhan
committed
Added map_variables param in read_tmy3 func
1 parent 771eb46 commit 0e60277

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pvlib/iotools/tmy.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import datetime
44
import re
55
import pandas as pd
6+
import warnings
67

78

8-
def read_tmy3(filename, coerce_year=None, recolumn=True):
9+
def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True):
910
"""Read a TMY3 file into a pandas dataframe.
1011
1112
Note that values contained in the metadata dictionary are unchanged
@@ -24,6 +25,10 @@ def read_tmy3(filename, coerce_year=None, recolumn=True):
2425
If supplied, the year of the index will be set to `coerce_year`, except
2526
for the last index value which will be set to the *next* year so that
2627
the index increases monotonically.
28+
map_variables : bool, default None
29+
If ``True``, apply standard names to TMY3 columns. Typically this
30+
results in stripping the units from the column name and issues deprecationWarning
31+
for recolumn
2732
recolumn : bool, default True
2833
If ``True``, apply standard names to TMY3 columns. Typically this
2934
results in stripping the units from the column name.
@@ -198,9 +203,17 @@ def read_tmy3(filename, coerce_year=None, recolumn=True):
198203
# NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta
199204
# unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour'
200205
data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h')
201-
202-
if recolumn:
206+
207+
if map_variables:
203208
data = _recolumn(data) # rename to standard column names
209+
elif recolumn:
210+
if not map_variables: # silence warning if map_variables is false
211+
data = _recolumn(data)
212+
elif map_variables is None:
213+
data = _recolumn(data)
214+
warnings.warn("recolumn parameter will be retired starting version 0.9.5, please"
215+
"use map_variables parameter instead.",DeprecationWarning)
216+
204217

205218
data = data.tz_localize(int(meta['TZ'] * 3600))
206219

0 commit comments

Comments
 (0)