Skip to content

Change server parameter to url in get_cams #2463

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 4 commits into from
May 27, 2025
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
4 changes: 4 additions & 0 deletions docs/sphinx/source/whatsnew/v0.12.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Deprecations
- :py:func:`~pvlib.iotools.parse_psm3`
- :py:func:`~pvlib.iotools.parse_cams`

* The ``server`` parameter in :py:func:`~pvlib.iotools.get_cams` has been renamed
to ``url`` to be consistent with the other iotools.
:pull:`2463`


Bug fixes
~~~~~~~~~
Expand Down
13 changes: 9 additions & 4 deletions pvlib/iotools/sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import warnings
from pvlib import tools

from pvlib._deprecation import deprecated
from pvlib._deprecation import deprecated, renamed_kwarg_warning

URL = 'api.soda-solardata.com'

Expand Down Expand Up @@ -45,10 +45,15 @@
'0 year 1 month 0 day 0 h 0 min 0 s': '1M'}


@renamed_kwarg_warning(
since='0.13.0',
old_param_name='server',
new_param_name='url',
removal="0.14.0")
def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
altitude=None, time_step='1h', time_ref='UT', verbose=False,
integrated=False, label=None, map_variables=True,
server=URL, timeout=30):
url=URL, timeout=30):
"""Retrieve irradiance and clear-sky time series from CAMS.

Time-series of radiation and/or clear-sky global, beam, and
Expand Down Expand Up @@ -98,7 +103,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
map_variables: bool, default: True
When true, renames columns of the DataFrame to pvlib variable names
where applicable. See variable :const:`VARIABLE_MAP`.
server: str, default: :const:`pvlib.iotools.sodapro.URL`
url: str, default: :const:`pvlib.iotools.sodapro.URL`
Base url of the SoDa Pro CAMS Radiation API.
timeout : int, default: 30
Time in seconds to wait for server response before timeout
Expand Down Expand Up @@ -199,7 +204,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
email = email.replace('@', '%2540') # Format email address
identifier = 'get_{}'.format(identifier.lower()) # Format identifier str

base_url = f"https://{server}/service/wps"
base_url = f"https://{url}/service/wps"

data_inputs_dict = {
'latitude': latitude,
Expand Down
8 changes: 4 additions & 4 deletions tests/iotools/test_sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_get_cams(requests_mock, testfile, index, columns, values, dtypes,

def test_get_cams_bad_request(requests_mock):
"""Test that a the correct errors/warnings ares raised for invalid
requests inputs. Also tests if the specified server url gets used"""
requests inputs. Also tests if the specified url gets used"""

# Subset of an xml file returned for errornous requests
mock_response_bad_text = """<?xml version="1.0" encoding="utf-8"?>
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_get_cams_bad_request(requests_mock):
time_ref='TST',
verbose=False,
time_step='1h',
server='pro.soda-is.com')
url='pro.soda-is.com')
# Test if value error is raised if incorrect identifier is specified
with pytest.raises(ValueError, match='Identifier must be either'):
_ = sodapro.get_cams(
Expand All @@ -291,7 +291,7 @@ def test_get_cams_bad_request(requests_mock):
longitude=12.5251,
email='[email protected]',
identifier='test', # incorrect identifier
server='pro.soda-is.com')
url='pro.soda-is.com')
# Test if value error is raised if incorrect time step is specified
with pytest.raises(ValueError, match='Time step not recognized'):
_ = sodapro.get_cams(
Expand All @@ -302,4 +302,4 @@ def test_get_cams_bad_request(requests_mock):
email='[email protected]',
identifier='mcclear',
time_step='test', # incorrect time step
server='pro.soda-is.com')
url='pro.soda-is.com')
Loading