Skip to content

Commit cc027e4

Browse files
authored
Set map_variables=True by default in PSM3 iotools functions (#2094)
* get, read, parse PSM3: set `map_variables=True` by default * whatsnew
1 parent 2d0ed71 commit cc027e4

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Breaking changes
1616
(:pull:`1779`, :pull:`1989`)
1717
* The `leap_day` parameter in :py:func:`~pvlib.iotools.get_psm3`
1818
now defaults to True instead of False. (:issue:`1481`, :pull:`1991`)
19+
* :py:func:`~pvlib.iotools.get_psm3`, :py:func:`~pvlib.iotools.read_psm3`, and
20+
:py:func:`~pvlib.iotools.parse_psm3` all now have ``map_variables=True`` by
21+
default. (:issue:`1425`, :pull:`2094`)
1922

2023

2124
Deprecations

pvlib/iotools/psm3.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
6565
attributes=ATTRIBUTES, leap_day=True, full_name=PVLIB_PYTHON,
66-
affiliation=PVLIB_PYTHON, map_variables=None, url=None,
66+
affiliation=PVLIB_PYTHON, map_variables=True, url=None,
6767
timeout=30):
6868
"""
6969
Retrieve NSRDB PSM3 timeseries weather data from the PSM3 API. The NSRDB
@@ -105,14 +105,14 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
105105
for lists of available fields. Alternatively, pvlib names may also be
106106
used (e.g. 'ghi' rather than 'GHI'); see :const:`REQUEST_VARIABLE_MAP`.
107107
To retrieve all available fields, set ``attributes=[]``.
108-
leap_day : boolean, default : True
108+
leap_day : bool, default : True
109109
include leap day in the results. Only used for single-year requests
110110
(i.e., it is ignored for tmy/tgy/tdy requests).
111111
full_name : str, default 'pvlib python'
112112
optional
113113
affiliation : str, default 'pvlib python'
114114
optional
115-
map_variables : boolean, optional
115+
map_variables : bool, default True
116116
When true, renames columns of the Dataframe to pvlib variable names
117117
where applicable. See variable :const:`VARIABLE_MAP`.
118118
url : str, optional
@@ -219,7 +219,7 @@ def get_psm3(latitude, longitude, api_key, email, names='tmy', interval=60,
219219
return parse_psm3(fbuf, map_variables)
220220

221221

222-
def parse_psm3(fbuf, map_variables=None):
222+
def parse_psm3(fbuf, map_variables=True):
223223
"""
224224
Parse an NSRDB PSM3 weather file (formatted as SAM CSV). The NSRDB
225225
is described in [1]_ and the SAM CSV format is described in [2]_.
@@ -233,9 +233,9 @@ def parse_psm3(fbuf, map_variables=None):
233233
----------
234234
fbuf: file-like object
235235
File-like object containing data to read.
236-
map_variables: bool
236+
map_variables: bool, default True
237237
When true, renames columns of the Dataframe to pvlib variable names
238-
where applicable. See variable VARIABLE_MAP.
238+
where applicable. See variable :const:`VARIABLE_MAP`.
239239
240240
Returns
241241
-------
@@ -348,13 +348,6 @@ def parse_psm3(fbuf, map_variables=None):
348348
tz = 'Etc/GMT%+d' % -metadata['Time Zone']
349349
data.index = pd.DatetimeIndex(dtidx).tz_localize(tz)
350350

351-
if map_variables is None:
352-
warnings.warn(
353-
'PSM3 variable names will be renamed to pvlib conventions by '
354-
'default starting in pvlib 0.11.0. Specify map_variables=True '
355-
'to enable that behavior now, or specify map_variables=False '
356-
'to hide this warning.', pvlibDeprecationWarning)
357-
map_variables = False
358351
if map_variables:
359352
data = data.rename(columns=VARIABLE_MAP)
360353
metadata['latitude'] = metadata.pop('Latitude')
@@ -364,7 +357,7 @@ def parse_psm3(fbuf, map_variables=None):
364357
return data, metadata
365358

366359

367-
def read_psm3(filename, map_variables=None):
360+
def read_psm3(filename, map_variables=True):
368361
"""
369362
Read an NSRDB PSM3 weather file (formatted as SAM CSV). The NSRDB
370363
is described in [1]_ and the SAM CSV format is described in [2]_.
@@ -378,9 +371,9 @@ def read_psm3(filename, map_variables=None):
378371
----------
379372
filename: str
380373
Filename of a file containing data to read.
381-
map_variables: bool
374+
map_variables: bool, default True
382375
When true, renames columns of the Dataframe to pvlib variable names
383-
where applicable. See variable VARIABLE_MAP.
376+
where applicable. See variable :const:`VARIABLE_MAP`.
384377
385378
Returns
386379
-------

pvlib/tests/iotools/test_psm3.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,3 @@ def test_get_psm3_attribute_mapping(nrel_api_key):
196196
assert 'latitude' in meta.keys()
197197
assert 'longitude' in meta.keys()
198198
assert 'altitude' in meta.keys()
199-
200-
201-
@pytest.mark.remote_data
202-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
203-
def test_psm3_variable_map_deprecation_warning(nrel_api_key):
204-
with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'):
205-
_ = psm3.read_psm3(MANUAL_TEST_DATA)

0 commit comments

Comments
 (0)