Skip to content
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.15.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Bug fixes
:py:mod:`csv` module instead of a naive ``str.split(',')``, so quoted column
names containing commas (e.g. the material names in spectral-on-demand files)
are no longer split into spurious columns. (:issue:`2736`, :pull:`2771`)
* Update :py:func:`~pvlib.iotools.get_meteonorm_tmy` to comply
with the updated Meteonorm API. As part of this, the ``data_version``
parameter now has no effect and will be removed in the future. (:pull:`2781`)

Enhancements
~~~~~~~~~~~~
Expand Down
16 changes: 12 additions & 4 deletions pvlib/iotools/meteonorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from urllib.parse import urljoin
from pandas._libs.tslibs.parsing import DateParseError

from pvlib._deprecation import warn_deprecated

URL = "https://api.meteonorm.com/v1/"

VARIABLE_MAP = {
Expand Down Expand Up @@ -402,7 +404,7 @@ def get_meteonorm_tmy(
surface_tilt=0, surface_azimuth=180,
time_step="1h", horizon="auto", terrain_situation="open",
albedo=None, turbidity="auto", random_seed=None,
clear_sky_radiation_model="esra", data_version="latest",
clear_sky_radiation_model="esra", data_version=None,
future_scenario=None, future_year=None, interval_index=False,
map_variables=True, url=URL):
"""
Expand Down Expand Up @@ -448,8 +450,8 @@ def get_meteonorm_tmy(
with the same random seed will yield identical results.
clear_sky_radiation_model : str, default : 'esra'
Which clearsky model to use. Must be either `'esra'` or `'solis'`.
data_version : str, default : 'latest'
Version of Meteonorm climatological data to be used.
data_version : str, optional
Deprecated parameter. Has no effect.
future_scenario : str, optional
Comment thread
AdamRJensen marked this conversation as resolved.
Future climate scenario.
future_year : int, optional
Expand Down Expand Up @@ -494,11 +496,17 @@ def get_meteonorm_tmy(
.. [3] `Meteonorm API reference
<https://docs.meteonorm.com/api>`_
"""
if data_version is not None:
msg = (
"This parameter was removed from the Meteonorm API "
"and now has no effect."
)
warn_deprecated(since="0.15.2", removal="0.16.0", name="data_version",
addendum=msg)
additional_params = {
"situation": terrain_situation,
"turbidity": turbidity,
"clear_sky_radiation_model": clear_sky_radiation_model,
"data_version": data_version,
"random_seed": random_seed,
"future_scenario": future_scenario,
"future_year": future_year,
Expand Down
19 changes: 17 additions & 2 deletions tests/iotools/test_meteonorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import numpy as np
import pytest
import pvlib
from tests.conftest import RERUNS, RERUNS_DELAY
from tests.conftest import RERUNS, RERUNS_DELAY, fail_on_pvlib_version
from requests.exceptions import HTTPError

from pvlib._deprecation import pvlibDeprecationWarning


@pytest.fixture
def demo_api_key():
Expand Down Expand Up @@ -302,7 +304,6 @@ def test_get_meteonorm_tmy(
turbidity=[5.2, 4, 3, 3.1, 3.0, 2.8, 3.14, 3.0, 3, 3, 4, 5],
random_seed=100,
clear_sky_radiation_model='solis',
data_version='v9.0', # fix version
future_scenario='ssp1_26',
future_year=2030,
interval_index=True,
Expand All @@ -315,3 +316,17 @@ def test_get_meteonorm_tmy(
# calls. so we allow a small amount of variation with atol.
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_tmy_data,
check_exact=False, atol=1)


@fail_on_pvlib_version('0.16.0')
@pytest.mark.remote_data
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_get_meteonorm_tmy_data_version_deprecation(demo_url, demo_api_key):
with pytest.warns(pvlibDeprecationWarning):
_ = pvlib.iotools.get_meteonorm_tmy(
latitude=50,
longitude=10,
api_key=demo_api_key,
data_version="latest",
url=demo_url
)
Loading