Skip to content

Commit 1f90861

Browse files
Deprecate and disable data_version parameter in get_meteonorm_tmy (pvlib#2781)
* Remove data_version parameter from get_meteonorm_tmy * Add whatsnew entry * Remove data_version from tests * Apply suggestions from code review Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com> * Add triple quote - fix linter * Add test * Fix test * Use demo_url in test * Update whatsnew Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com> * Update fail_on_pvlib_version Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com> * Update docs/sphinx/source/whatsnew/v0.15.2.rst Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com> --------- Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
1 parent d8c706e commit 1f90861

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Bug fixes
3939
:py:mod:`csv` module instead of a naive ``str.split(',')``, so quoted column
4040
names containing commas (e.g. the material names in spectral-on-demand files)
4141
are no longer split into spurious columns. (:issue:`2736`, :pull:`2771`)
42+
* Update :py:func:`~pvlib.iotools.get_meteonorm_tmy` to comply
43+
with the updated Meteonorm API. As part of this, the ``data_version``
44+
parameter now has no effect and will be removed in the future. (:pull:`2781`)
4245

4346
Enhancements
4447
~~~~~~~~~~~~

pvlib/iotools/meteonorm.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from urllib.parse import urljoin
66
from pandas._libs.tslibs.parsing import DateParseError
77

8+
from pvlib._deprecation import warn_deprecated
9+
810
URL = "https://api.meteonorm.com/v1/"
911

1012
VARIABLE_MAP = {
@@ -402,7 +404,7 @@ def get_meteonorm_tmy(
402404
surface_tilt=0, surface_azimuth=180,
403405
time_step="1h", horizon="auto", terrain_situation="open",
404406
albedo=None, turbidity="auto", random_seed=None,
405-
clear_sky_radiation_model="esra", data_version="latest",
407+
clear_sky_radiation_model="esra", data_version=None,
406408
future_scenario=None, future_year=None, interval_index=False,
407409
map_variables=True, url=URL):
408410
"""
@@ -448,8 +450,8 @@ def get_meteonorm_tmy(
448450
with the same random seed will yield identical results.
449451
clear_sky_radiation_model : str, default : 'esra'
450452
Which clearsky model to use. Must be either `'esra'` or `'solis'`.
451-
data_version : str, default : 'latest'
452-
Version of Meteonorm climatological data to be used.
453+
data_version : str, optional
454+
Deprecated parameter. Has no effect.
453455
future_scenario : str, optional
454456
Future climate scenario.
455457
future_year : int, optional
@@ -494,11 +496,17 @@ def get_meteonorm_tmy(
494496
.. [3] `Meteonorm API reference
495497
<https://docs.meteonorm.com/api>`_
496498
"""
499+
if data_version is not None:
500+
msg = (
501+
"This parameter was removed from the Meteonorm API "
502+
"and now has no effect."
503+
)
504+
warn_deprecated(since="0.15.2", removal="0.16.0", name="data_version",
505+
addendum=msg)
497506
additional_params = {
498507
"situation": terrain_situation,
499508
"turbidity": turbidity,
500509
"clear_sky_radiation_model": clear_sky_radiation_model,
501-
"data_version": data_version,
502510
"random_seed": random_seed,
503511
"future_scenario": future_scenario,
504512
"future_year": future_year,

tests/iotools/test_meteonorm.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import numpy as np
33
import pytest
44
import pvlib
5-
from tests.conftest import RERUNS, RERUNS_DELAY
5+
from tests.conftest import RERUNS, RERUNS_DELAY, fail_on_pvlib_version
66
from requests.exceptions import HTTPError
77

8+
from pvlib._deprecation import pvlibDeprecationWarning
9+
810

911
@pytest.fixture
1012
def demo_api_key():
@@ -302,7 +304,6 @@ def test_get_meteonorm_tmy(
302304
turbidity=[5.2, 4, 3, 3.1, 3.0, 2.8, 3.14, 3.0, 3, 3, 4, 5],
303305
random_seed=100,
304306
clear_sky_radiation_model='solis',
305-
data_version='v9.0', # fix version
306307
future_scenario='ssp1_26',
307308
future_year=2030,
308309
interval_index=True,
@@ -315,3 +316,17 @@ def test_get_meteonorm_tmy(
315316
# calls. so we allow a small amount of variation with atol.
316317
pd.testing.assert_frame_equal(data.iloc[:12], expected_meteonorm_tmy_data,
317318
check_exact=False, atol=1)
319+
320+
321+
@fail_on_pvlib_version('0.16.0')
322+
@pytest.mark.remote_data
323+
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
324+
def test_get_meteonorm_tmy_data_version_deprecation(demo_url, demo_api_key):
325+
with pytest.warns(pvlibDeprecationWarning):
326+
_ = pvlib.iotools.get_meteonorm_tmy(
327+
latitude=50,
328+
longitude=10,
329+
api_key=demo_api_key,
330+
data_version="latest",
331+
url=demo_url
332+
)

0 commit comments

Comments
 (0)