|
4 | 4 | import re
|
5 | 5 | import pandas as pd
|
6 | 6 | import warnings
|
| 7 | +from pvlib._deprecation import pvlibDeprecationWarning |
| 8 | + |
| 9 | +# Dictionary mapping TMY3 names to pvlib names |
| 10 | +VARIABLE_MAP = { |
| 11 | + 'GHI': 'ghi', |
| 12 | + 'DNI': 'dni', |
| 13 | + 'DHI': 'dhi', |
| 14 | + 'Pressure': 'pressure', |
| 15 | + 'Wdir': 'wind_direction', |
| 16 | + 'Wspd': 'wind_speed', |
| 17 | +} |
7 | 18 |
|
8 | 19 |
|
9 | 20 | def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True):
|
@@ -203,16 +214,16 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True):
|
203 | 214 | # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta
|
204 | 215 | # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour'
|
205 | 216 | data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h')
|
206 |
| - |
207 |
| - if map_variables: |
| 217 | + if map_variables is None: |
208 | 218 | 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," |
215 |
| - "please use map_variables parameter instead.",DeprecationWarning) |
| 219 | + warnings.warn( |
| 220 | + 'TMY3 variable names will be renamed to pvlib conventions by ' |
| 221 | + 'default starting in pvlib 0.9.5. Specify map_variables=True ' |
| 222 | + 'to enable that behavior now, or specify map_variables=False ' |
| 223 | + 'to hide this warning.', pvlibDeprecationWarning) |
| 224 | + map_variables = False |
| 225 | + if map_variables: |
| 226 | + data = _recolumn(data).rename(columns=VARIABLE_MAP) |
216 | 227 |
|
217 | 228 | data = data.tz_localize(int(meta['TZ'] * 3600))
|
218 | 229 |
|
|
0 commit comments