Skip to content

Update SoDa Pro / CAMS url #1740

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
May 22, 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
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Deprecations

Enhancements
~~~~~~~~~~~~
* Update the URL used in the :py:func:`pvlib.iotools.get_cams` function. The new URL supports load-balancing
and redirects to the fastest server. (:issue:`1688`, :pull:`1740`)


Bug fixes
Expand Down
14 changes: 8 additions & 6 deletions pvlib/iotools/sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import warnings


URL = 'api.soda-solardata.com'

CAMS_INTEGRATED_COLUMNS = [
'TOA', 'Clear sky GHI', 'Clear sky BHI', 'Clear sky DHI', 'Clear sky BNI',
'GHI', 'BHI', 'DHI', 'BNI',
Expand Down Expand Up @@ -44,7 +46,7 @@
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='www.soda-is.com', timeout=30):
server=URL, timeout=30):
"""
Retrieve time-series of radiation and/or clear-sky global, beam, and
diffuse radiation from CAMS (see [1]_). Data is retrieved from SoDa [2]_.
Expand Down Expand Up @@ -91,8 +93,8 @@ 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: 'www.soda-is.com'
Main server (www.soda-is.com) or backup mirror server (pro.soda-is.com)
server: 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 @@ -344,13 +346,13 @@ def read_cams(filename, integrated=False, label=None, map_variables=True):
all time steps except for '1M' which has a default of 'right'.
map_variables: bool, default: True
When true, renames columns of the Dataframe to pvlib variable names
where applicable. See variable VARIABLE_MAP.
where applicable. See variable :const:`VARIABLE_MAP`.

Returns
-------
data: pandas.DataFrame
Timeseries data from CAMS Radiation or McClear
:func:`pvlib.iotools.get_cams` for fields
Timeseries data from CAMS Radiation or McClear.
See :func:`pvlib.iotools.get_cams` for fields.
metadata: dict
Metadata available in the file.

Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/iotools/test_sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_get_cams(requests_mock, testfile, index, columns, values, dtypes,
mock_response = test_file.read()
# Specify the full URI of a specific example, this ensures that all of the
# inputs are passing on correctly
url_test_cams = f'https://www.soda-is.com/service/wps?DataInputs=latitude=55.7906;longitude=12.5251;altitude=80;date_begin=2020-01-01;date_end=2020-05-04;time_ref=UT;summarization=P01M;username=pvlib-admin%2540googlegroups.com;verbose=false&Service=WPS&Request=Execute&Identifier=get_{identifier}&version=1.0.0&RawDataOutput=irradiation' # noqa: E501
url_test_cams = f'https://api.soda-solardata.com/service/wps?DataInputs=latitude=55.7906;longitude=12.5251;altitude=80;date_begin=2020-01-01;date_end=2020-05-04;time_ref=UT;summarization=P01M;username=pvlib-admin%2540googlegroups.com;verbose=false&Service=WPS&Request=Execute&Identifier=get_{identifier}&version=1.0.0&RawDataOutput=irradiation' # noqa: E501

requests_mock.get(url_test_cams, text=mock_response,
headers={'Content-Type': 'application/csv'})
Expand Down