Skip to content

Set map_variables=True in pvgis_tmy functions #1772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/sphinx/source/user_guide/introtutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion docs/sphinx/source/whatsnew/v0.10.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Breaking changes
:py:func:`pvlib.singlediode._lambertw_v_from_i` to match
:py:func:`pvlib.pvsystem.singlediode`.
(:issue:`1718`, :pull:`1719`)

* :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
~~~~~~~~~~~~
Expand Down Expand Up @@ -45,3 +47,4 @@ Requirements
Contributors
~~~~~~~~~~~~
* Taos Transue (:ghuser:`reepoi`)
* Adam R. Jensen (:ghuser:`AdamRJensen`)
26 changes: 5 additions & 21 deletions pvlib/iotools/pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -420,9 +420,9 @@ 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`.
where applicable. See variable :const:`VARIABLE_MAP`.
timeout : int, default 30
time in seconds to wait for server response before timeout

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.

Expand All @@ -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`.

Expand Down Expand Up @@ -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)

Expand Down
11 changes: 0 additions & 11 deletions pvlib/tests/iotools/test_pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down