Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.12.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Breaking Changes
:py:func:`~pvlib.iotools.get_pvgis_tmy` now return ``(data,meta)``
following the iotools convention instead of ``(data,months_selected,inputs,meta)``.
(:pull:`2470`)
* :py:func:`~pvlib.iotools.get_pvgis_tmy` now defaults to ``coerce_year=1990``,
whereas the default behavior previously was to use the years of the selected
months for the TMY index. (:pull:`2474`)
* Remove ``outputformat='basic'`` option in :py:func:`~pvlib.iotools.get_pvgis_tmy`.
(:pull:`2416`)

Expand Down
10 changes: 6 additions & 4 deletions pvlib/iotools/pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def _coerce_and_roll_tmy(tmy_data, tz, year):
def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
userhorizon=None, startyear=None, endyear=None,
map_variables=True, url=URL, timeout=30,
roll_utc_offset=None, coerce_year=None):
roll_utc_offset=None, coerce_year=1990):
"""
Get TMY data from PVGIS.

Expand Down Expand Up @@ -477,9 +477,11 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
Use to specify a time zone other than the default UTC zero and roll
dataframe by ``roll_utc_offset`` so it starts at midnight on January
1st. Ignored if ``None``, otherwise will force year to ``coerce_year``.
coerce_year: int, optional
Use to force indices to desired year. Will default to 1990 if
``coerce_year`` is not specified, but ``roll_utc_offset`` is specified.
coerce_year: int, default 1990
Use to force indices to desired year. Defaults to 1990. Specify
``None`` to return the actual indicies used for the TMY. If
``coerce_year`` is ``None``, but ``roll_utc_offset`` is specified,
then ``coerce_year`` will be set to the default.

Returns
-------
Expand Down
16 changes: 11 additions & 5 deletions tests/iotools/test_pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def pvgis_tmy_mapped_columns():
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_get_pvgis_tmy(expected, month_year_expected, inputs_expected,
meta_expected):
pvgis_data = get_pvgis_tmy(45, 8, map_variables=False)
pvgis_data = get_pvgis_tmy(45, 8, map_variables=False, coerce_year=None)
_compare_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
meta_expected, pvgis_data)

Expand Down Expand Up @@ -428,7 +428,8 @@ def test_get_pvgis_tmy_kwargs(userhorizon_expected):
_, meta = get_pvgis_tmy(45, 8, usehorizon=False, map_variables=False)
assert meta['inputs']['meteo_data']['use_horizon'] is False
data, _ = get_pvgis_tmy(
45, 8, userhorizon=[0, 10, 20, 30, 40, 15, 25, 5], map_variables=False)
45, 8, userhorizon=[0, 10, 20, 30, 40, 15, 25, 5], map_variables=False,
coerce_year=None)
assert np.allclose(
data['G(h)'], userhorizon_expected['G(h)'].values)
assert np.allclose(
Expand Down Expand Up @@ -486,13 +487,17 @@ def test_get_pvgis_tmy_coerce_year():
for m, test_case in enumerate(noon_test_data):
expected = pvgis_data[pvgis_data.index.month == m+1].iloc[12]
assert all(test_case == expected)
# Test that get_pvgis_tmy defaults to coerce_year=1990
pvgis_data, _ = get_pvgis_tmy(45, 8)
assert all(pvgis_data.index.year == 1990)


@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_get_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
meta_expected, csv_meta):
pvgis_data = get_pvgis_tmy(45, 8, outputformat='csv', map_variables=False)
meta_expected, csv_meta, coerce_year=None):
pvgis_data = get_pvgis_tmy(45, 8, outputformat='csv', map_variables=False,
coerce_year=None)
_compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
meta_expected, csv_meta, pvgis_data)

Expand Down Expand Up @@ -532,7 +537,8 @@ def _compare_pvgis_tmy_csv(expected, month_year_expected, inputs_expected,
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_get_pvgis_tmy_epw(expected, epw_meta):
pvgis_data = get_pvgis_tmy(45, 8, outputformat='epw', map_variables=False)
pvgis_data = get_pvgis_tmy(45, 8, outputformat='epw', map_variables=False,
coerce_year=None)
_compare_pvgis_tmy_epw(expected, epw_meta, pvgis_data)


Expand Down
Loading