From 3baa12897a43671c8e7805258784870714dbf7b4 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 10:53:17 +0200 Subject: [PATCH 1/3] Set map_variables=True in pvgis_tmy functions --- .../source/user_guide/introtutorial.rst | 3 +-- docs/sphinx/source/whatsnew/v0.10.0.rst | 5 +++- pvlib/iotools/pvgis.py | 24 ++++--------------- pvlib/tests/iotools/test_pvgis.py | 11 --------- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/docs/sphinx/source/user_guide/introtutorial.rst b/docs/sphinx/source/user_guide/introtutorial.rst index 2f1bb8a0bc..957884b892 100644 --- a/docs/sphinx/source/user_guide/introtutorial.rst +++ b/docs/sphinx/source/user_guide/introtutorial.rst @@ -57,8 +57,7 @@ includes irradiation, temperature and wind speed. tmys = [] for location in coordinates: latitude, longitude, name, altitude, timezone = location - weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude, - map_variables=True)[0] + weather = pvlib.iotools.get_pvgis_tmy(latitude, longitude)[0] weather.index.name = "utc_time" tmys.append(weather) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index a4406072f8..e461b0c23d 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -17,7 +17,9 @@ Breaking changes Deprecations ~~~~~~~~~~~~ - +* :func:`~pvlib.iotools.get_pvgis_tmy` and :func:`~pvlib.iotools.read_pvgis_tmy` + now rename columns to standard pvlib names by default (``map_variables=True``) + (:pull:`1772`) Enhancements ~~~~~~~~~~~~ @@ -45,3 +47,4 @@ Requirements Contributors ~~~~~~~~~~~~ * Taos Transue (:ghuser:`reepoi`) +* Adam R. Jensen (:ghuser:`AdamRJensen`) diff --git a/pvlib/iotools/pvgis.py b/pvlib/iotools/pvgis.py index 3d44022b60..f437a192c3 100644 --- a/pvlib/iotools/pvgis.py +++ b/pvlib/iotools/pvgis.py @@ -392,7 +392,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True): def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, userhorizon=None, startyear=None, endyear=None, url=URL, - map_variables=None, timeout=30): + map_variables=True, timeout=30): """ Get TMY data from PVGIS. @@ -420,7 +420,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, last year to calculate TMY, must be at least 10 years from first year url : str, default: :const:`pvlib.iotools.pvgis.URL` base url of PVGIS API, append ``tmy`` to get TMY endpoint - map_variables: bool + map_variables: bool, default True When true, renames columns of the Dataframe to pvlib variable names where applicable. See variable const:`VARIABLE_MAP`. timeout : int, default 30 @@ -508,14 +508,6 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, # the response is HTTP/1.1 400 BAD REQUEST which is handled earlier pass - if map_variables is None: - warnings.warn( - 'PVGIS variable names will be renamed to pvlib conventions by ' - 'default starting in pvlib 0.10.0. Specify map_variables=True ' - 'to enable that behavior now, or specify map_variables=False ' - 'to hide this warning.', pvlibDeprecationWarning - ) - map_variables = False if map_variables: data = data.rename(columns=VARIABLE_MAP) @@ -573,7 +565,7 @@ def _parse_pvgis_tmy_basic(src): return data, None, None, None -def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None): +def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True): """ Read a file downloaded from PVGIS. @@ -589,7 +581,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None): ``outputformat='basic'``, please set ``pvgis_format`` to ``'basic'``. If ``filename`` is a buffer, then ``pvgis_format`` is required and must be in ``['csv', 'epw', 'json', 'basic']``. - map_variables: bool + map_variables: bool, default True When true, renames columns of the Dataframe to pvlib variable names where applicable. See variable :const:`VARIABLE_MAP`. @@ -671,14 +663,6 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None): "'csv', or 'basic'").format(outputformat) raise ValueError(err_msg) - if map_variables is None: - warnings.warn( - 'PVGIS variable names will be renamed to pvlib conventions by ' - 'default starting in pvlib 0.10.0. Specify map_variables=True ' - 'to enable that behavior now, or specify map_variables=False ' - 'to hide this warning.', pvlibDeprecationWarning - ) - map_variables = False if map_variables: data = data.rename(columns=VARIABLE_MAP) diff --git a/pvlib/tests/iotools/test_pvgis.py b/pvlib/tests/iotools/test_pvgis.py index 41281208eb..84927d04d7 100644 --- a/pvlib/tests/iotools/test_pvgis.py +++ b/pvlib/tests/iotools/test_pvgis.py @@ -365,17 +365,6 @@ def pvgis_tmy_mapped_columns(): 'wind_speed', 'wind_direction', 'pressure'] -@fail_on_pvlib_version('0.10') -@pytest.mark.remote_data -@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY) -def test_pvgis_tmy_variable_map_deprecating_warning_0_10(): - with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): - _ = get_pvgis_tmy(45, 8) - with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): - fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.epw' - _ = read_pvgis_tmy(fn) - - @pytest.mark.remote_data @pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY) def test_get_pvgis_tmy(expected, month_year_expected, inputs_expected, From 4c1ac0f612101e4a2133a34772a05923f3785916 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:19:03 +0200 Subject: [PATCH 2/3] Fix typo in get_pvgis_tmy doc string --- pvlib/iotools/pvgis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/pvgis.py b/pvlib/iotools/pvgis.py index f437a192c3..cdb7e63389 100644 --- a/pvlib/iotools/pvgis.py +++ b/pvlib/iotools/pvgis.py @@ -422,7 +422,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, base url of PVGIS API, append ``tmy`` to get TMY endpoint map_variables: bool, default True When true, renames columns of the Dataframe to pvlib variable names - where applicable. See variable const:`VARIABLE_MAP`. + where applicable. See variable :const:`VARIABLE_MAP`. timeout : int, default 30 time in seconds to wait for server response before timeout From f93ce1ce0496acbf531f90ab46b27a3de694e1f6 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:48:07 +0200 Subject: [PATCH 3/3] Move whatsnew entry to breaking changes --- docs/sphinx/source/whatsnew/v0.10.0.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index e461b0c23d..f4368de6f2 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -13,14 +13,14 @@ Breaking changes :py:func:`pvlib.singlediode._lambertw_v_from_i` to match :py:func:`pvlib.pvsystem.singlediode`. (:issue:`1718`, :pull:`1719`) - - -Deprecations -~~~~~~~~~~~~ * :func:`~pvlib.iotools.get_pvgis_tmy` and :func:`~pvlib.iotools.read_pvgis_tmy` now rename columns to standard pvlib names by default (``map_variables=True``) (:pull:`1772`) +Deprecations +~~~~~~~~~~~~ + + Enhancements ~~~~~~~~~~~~