Skip to content

Commit 0ec9181

Browse files
authored
Set map_variables=True in pvgis_tmy functions (#1772)
* Set map_variables=True in pvgis_tmy functions * Fix typo in get_pvgis_tmy doc string * Move whatsnew entry to breaking changes
1 parent 40e9e97 commit 0ec9181

File tree

4 files changed

+10
-35
lines changed

4 files changed

+10
-35
lines changed

docs/sphinx/source/user_guide/introtutorial.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ includes irradiation, temperature and wind speed.
5757
tmys = []
5858
for location in coordinates:
5959
latitude, longitude, name, altitude, timezone = location
60-
weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude,
61-
map_variables=True)[0]
60+
weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude)[0]
6261
weather.index.name = "utc_time"
6362
tmys.append(weather)
6463

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ Breaking changes
1313
:py:func:`pvlib.singlediode._lambertw_v_from_i` to match
1414
:py:func:`pvlib.pvsystem.singlediode`.
1515
(:issue:`1718`, :pull:`1719`)
16-
16+
* :func:`~pvlib.iotools.get_pvgis_tmy` and :func:`~pvlib.iotools.read_pvgis_tmy`
17+
now rename columns to standard pvlib names by default (``map_variables=True``)
18+
(:pull:`1772`)
1719

1820
Deprecations
1921
~~~~~~~~~~~~
@@ -45,3 +47,4 @@ Requirements
4547
Contributors
4648
~~~~~~~~~~~~
4749
* Taos Transue (:ghuser:`reepoi`)
50+
* Adam R. Jensen (:ghuser:`AdamRJensen`)

pvlib/iotools/pvgis.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
392392

393393
def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
394394
userhorizon=None, startyear=None, endyear=None, url=URL,
395-
map_variables=None, timeout=30):
395+
map_variables=True, timeout=30):
396396
"""
397397
Get TMY data from PVGIS.
398398
@@ -420,9 +420,9 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
420420
last year to calculate TMY, must be at least 10 years from first year
421421
url : str, default: :const:`pvlib.iotools.pvgis.URL`
422422
base url of PVGIS API, append ``tmy`` to get TMY endpoint
423-
map_variables: bool
423+
map_variables: bool, default True
424424
When true, renames columns of the Dataframe to pvlib variable names
425-
where applicable. See variable const:`VARIABLE_MAP`.
425+
where applicable. See variable :const:`VARIABLE_MAP`.
426426
timeout : int, default 30
427427
time in seconds to wait for server response before timeout
428428
@@ -508,14 +508,6 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
508508
# the response is HTTP/1.1 400 BAD REQUEST which is handled earlier
509509
pass
510510

511-
if map_variables is None:
512-
warnings.warn(
513-
'PVGIS variable names will be renamed to pvlib conventions by '
514-
'default starting in pvlib 0.10.0. Specify map_variables=True '
515-
'to enable that behavior now, or specify map_variables=False '
516-
'to hide this warning.', pvlibDeprecationWarning
517-
)
518-
map_variables = False
519511
if map_variables:
520512
data = data.rename(columns=VARIABLE_MAP)
521513

@@ -573,7 +565,7 @@ def _parse_pvgis_tmy_basic(src):
573565
return data, None, None, None
574566

575567

576-
def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
568+
def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
577569
"""
578570
Read a file downloaded from PVGIS.
579571
@@ -589,7 +581,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
589581
``outputformat='basic'``, please set ``pvgis_format`` to ``'basic'``.
590582
If ``filename`` is a buffer, then ``pvgis_format`` is required and must
591583
be in ``['csv', 'epw', 'json', 'basic']``.
592-
map_variables: bool
584+
map_variables: bool, default True
593585
When true, renames columns of the Dataframe to pvlib variable names
594586
where applicable. See variable :const:`VARIABLE_MAP`.
595587
@@ -671,14 +663,6 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
671663
"'csv', or 'basic'").format(outputformat)
672664
raise ValueError(err_msg)
673665

674-
if map_variables is None:
675-
warnings.warn(
676-
'PVGIS variable names will be renamed to pvlib conventions by '
677-
'default starting in pvlib 0.10.0. Specify map_variables=True '
678-
'to enable that behavior now, or specify map_variables=False '
679-
'to hide this warning.', pvlibDeprecationWarning
680-
)
681-
map_variables = False
682666
if map_variables:
683667
data = data.rename(columns=VARIABLE_MAP)
684668

pvlib/tests/iotools/test_pvgis.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,6 @@ def pvgis_tmy_mapped_columns():
365365
'wind_speed', 'wind_direction', 'pressure']
366366

367367

368-
@fail_on_pvlib_version('0.10')
369-
@pytest.mark.remote_data
370-
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
371-
def test_pvgis_tmy_variable_map_deprecating_warning_0_10():
372-
with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'):
373-
_ = get_pvgis_tmy(45, 8)
374-
with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'):
375-
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.epw'
376-
_ = read_pvgis_tmy(fn)
377-
378-
379368
@pytest.mark.remote_data
380369
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
381370
def test_get_pvgis_tmy(expected, month_year_expected, inputs_expected,

0 commit comments

Comments
 (0)