Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add sodapro.get_cams_radiation #1175

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 59 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d7deb80
Add cams.get_cams_radiation function
Feb 22, 2021
510f08e
Revert "Add cams.get_cams_radiation function"
Feb 22, 2021
84e820c
Add cams.get_cams_mcclear
Feb 22, 2021
0a92f72
Update v0.9.0.rst
Feb 22, 2021
e8d1098
Reference correct pull request in whatsnew
Feb 23, 2021
2092f8b
Add test file for monthly data
Feb 23, 2021
ff9cece
Create sub-functions parse and read
Feb 23, 2021
0c28299
Fixed stickler
Feb 23, 2021
75e575f
Update constants names
Feb 25, 2021
1f2ec30
Fixed monthly integration of values
Feb 25, 2021
641fc97
Improvement to meta-data parsing
Feb 25, 2021
527fa1c
Update test file to be during the day
Feb 26, 2021
673bf3b
Convert to get_cams to add support for CAMS Radiation
Feb 26, 2021
c6764d3
Fixed stickler issues
Feb 26, 2021
225b0e1
Update function names to just 'cams'
Feb 26, 2021
924c58a
Update return description
Feb 27, 2021
cbc116d
Rename to cams_radiation
Feb 27, 2021
294c14a
Convert print statements to warnings
Feb 27, 2021
d28143a
Update function names
Feb 27, 2021
f263184
Fixed stickler
Feb 27, 2021
9b26d91
Fixed stickler
Feb 27, 2021
e3cb60d
Improvements to documentation
Feb 27, 2021
af66bbe
Raise warning for unrecognized time step
AdamRJensen Feb 27, 2021
2949cb1
Reworked URL formatting & comments on HTTP status
Mar 6, 2021
19fcdb8
Fixed stickler
Mar 6, 2021
328c86e
Add tests for cams.read_cams_radiation
Mar 7, 2021
1df6830
Add tests coverage for metadata
AdamRJensen Mar 7, 2021
f518246
Update docs/sphinx/source/whatsnew/v0.9.0.rst
AdamRJensen Mar 7, 2021
96e3719
Add reference to parsing function in whatsnew
AdamRJensen Mar 7, 2021
5f952c0
Update module and function names
AdamRJensen May 31, 2021
b4a686d
Update iotools init file with new names
AdamRJensen May 31, 2021
1ccbe70
update test file name
AdamRJensen May 31, 2021
5c9ef69
Add ".." to conftest import and update function documentation
AdamRJensen Jun 4, 2021
bb34a25
Change asterisk to † in documentation
AdamRJensen Jun 4, 2021
7c7ec0b
Merge branch 'master' into cams_mcclear
AdamRJensen Jun 4, 2021
71c3a64
Update from master
AdamRJensen Jun 4, 2021
9f6195e
Merge remote-tracking branch 'upstream/master' into cams_mcclear
AdamRJensen Jun 4, 2021
e335730
Add mock tests
AdamRJensen Jun 4, 2021
5a018ca
Stickler fixes and add import of requests_mock
AdamRJensen Jun 4, 2021
d0a2571
Remove import request_mock in test_sodapro.py
AdamRJensen Jun 4, 2021
e642399
Added requests-mock to setup.py and CI requirements files
AdamRJensen Jun 4, 2021
9e69d3e
Add requests-mock to ci\azure\posix.yml
AdamRJensen Jun 4, 2021
e085373
Move requests-mock to pip install section
AdamRJensen Jun 4, 2021
51b6ab9
Move requests-mock to pip install section for py36 and py36-min
AdamRJensen Jun 5, 2021
9814cae
Add additional tests for full coverage
AdamRJensen Jun 5, 2021
1d28d1a
Update stickler
AdamRJensen Jun 5, 2021
1d115db
Add timeout option to get_cams
AdamRJensen Jun 7, 2021
8e53165
Add timeout option to get_cams
AdamRJensen Jun 7, 2021
3714e62
Extent tests to cover label, integrated, map_variables arguments
AdamRJensen Jun 7, 2021
cc5347d
Fix stickler
AdamRJensen Jun 7, 2021
9fc945f
Updates to documentation
AdamRJensen Jun 7, 2021
8d85f0b
Update to documentation
AdamRJensen Jun 7, 2021
857bd91
Reformat data inputs, set index name to None
AdamRJensen Jun 7, 2021
15e097c
Remove rounding when converting from integrated values
AdamRJensen Jun 7, 2021
e80cbde
Minor updates to mock tests
AdamRJensen Jun 7, 2021
6aadd5c
Remove round(4)
AdamRJensen Jun 7, 2021
f194905
Change meta variable name to metadata
AdamRJensen Jun 11, 2021
128c3f9
Change start_date/end_date to start/end
AdamRJensen Jun 11, 2021
1e6d262
Make stickler happy
AdamRJensen Jun 11, 2021
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
Prev Previous commit
Next Next commit
Rename to cams_radiation
And minor updates to the  documentation
  • Loading branch information
AdamRJensen committed Feb 27, 2021
commit cbc116dd80773a20061cfac04da54b7f10ff7b8c
6 changes: 3 additions & 3 deletions 6 docs/sphinx/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ relevant to solar energy modeling.
iotools.get_pvgis_tmy
iotools.read_pvgis_tmy
iotools.read_bsrn
iotools.get_cams
iotools.read_cams
iotools.parse_cams
iotools.get_cams_radiation
iotools.read_cams_radiation
iotools.parse_cams_radiation

A :py:class:`~pvlib.location.Location` object may be created from metadata
in some files.
Expand Down
5 changes: 3 additions & 2 deletions 5 docs/sphinx/source/whatsnew/v0.9.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ Enhancements
~~~~~~~~~~~~
* Add :func:`~pvlib.iotools.read_bsrn` for reading BSRN solar radiation data
files. (:pull:`1145`, :issue:`1015`)
* Add :func:`~pvlib.iotools.get_cams` and :func:`~pvlib.iotools.read_cams`
for retrieving and reading CAMS Radiation and McClear radiation time series
* Add :func:`~pvlib.iotools.get_cams_radiatoin` and
AdamRJensen marked this conversation as resolved.
Show resolved Hide resolved
:func:`~pvlib.iotools.read_cams_radiation`
for retrieving and reading CAMS Radiation and McClear time-series
files. (:pull:`1175`)
* In :py:class:`~pvlib.modelchain.ModelChain`, attributes which contain
output of models are now collected into ``ModelChain.results``.
Expand Down
2 changes: 1 addition & 1 deletion 2 pvlib/iotools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
from pvlib.iotools.psm3 import parse_psm3 # noqa: F401
from pvlib.iotools.pvgis import get_pvgis_tmy, read_pvgis_tmy # noqa: F401
from pvlib.iotools.bsrn import read_bsrn # noqa: F401
from pvlib.iotools.cams import get_cams, read_cams, parse_cams # noqa: F401
from pvlib.iotools.cams import get_cams_radiation, read_cams_radiation, parse_cams_radiation # noqa: F401
51 changes: 29 additions & 22 deletions 51 pvlib/iotools/cams.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import io


CAMS_INTEGRATED_COLUMNS = ['TOA', 'Clear sky GHI', 'Clear sky BHI',
'Clear sky DHI', 'Clear sky BNI',
'GHI', 'BHI', 'DHI', 'BNI', 'GHI no corr',
'BHI no corr', 'DHI no corr', 'BNI no corr']
CAMS_RADIATION_INTEGRATED_COLUMNS = [
'TOA', 'Clear sky GHI', 'Clear sky BHI', 'Clear sky DHI', 'Clear sky BNI',
'GHI', 'BHI', 'DHI', 'BNI',
'GHI no corr', 'BHI no corr', 'DHI no corr', 'BNI no corr']

# Dictionary mapping CAMS McClear and Radiation variables to pvlib names
CAMS_VARIABLE_MAP = {
CAMS_RADIATION_VARIABLE_MAP = {
'TOA': 'ghi_extra',
'Clear sky GHI': 'ghi_clear',
'Clear sky BHI': 'bhi_clear',
Expand All @@ -41,20 +41,20 @@
'0 year 1 month 0 day 0 h 0 min 0 s': '1M'}


def get_cams(start_date, end_date, latitude, longitude, email,
service='mcclear', altitude=None, time_step='1h', time_ref='UT',
verbose=False, integrated=False, label=None, map_variables=True,
server='www.soda-is.com'):
def get_cams_radiation(start_date, end_date, latitude, longitude, email,
service='mcclear', altitude=None, time_step='1h',
time_ref='UT', verbose=False, integrated=False,
label=None, map_variables=True,
server='www.soda-is.com'):
"""
Retrieve time-series of radiation and/or clear-sky global, beam, and
diffuse radiation CAMS [2]_ using the WGET service [3]_.
diffuse radiation from CAMS [2]_ using the WGET service [3]_.


Geographical coverage: Wordwide for CAMS McClear and -66 to 66 for both
latitude and longitude for CAMS Radiation
Time coverage: 2004-01-01 to two days ago
Access: free, but requires registration, see [1]_
Requests: max. 100 per day
Geographical coverage: Wordwide for CAMS McClear and -66° to 66° in both
latitude and longitude for CAMS Radiation


Parameters
Expand Down Expand Up @@ -102,11 +102,11 @@ def get_cams(start_date, end_date, latitude, longitude, email,
Metadata for the requested time-series

Notes
----------
-----
In order to use the CAMS services, users must registre for a free SoDa
account using an email addres [1]_.

The returned data Dataframe includes the following fields:
The returned data DataFrame includes the following fields:

======================= ====== ==========================================
Key, mapped key Format Description
Expand Down Expand Up @@ -144,6 +144,12 @@ def get_cams(start_date, end_date, latitude, longitude, email,
--------
pvlib.iotools.read_cams, pvlib.iotools.parse_cams

Raises
------
requests.HTTPError
If the request is invalid, then an XML file is returned by the CAMS
service and the error message will be raised as an expcetion.

References
----------
.. [1] `CAMS Radiation Service Info
Expand All @@ -153,7 +159,6 @@ def get_cams(start_date, end_date, latitude, longitude, email,
.. [3] `CAMS McClear Automatic Access
<http://www.soda-pro.com/help/cams-services/cams-mcclear-service/automatic-access>`_
"""

if time_step in TIME_STEPS_MAP.keys():
time_step_str = TIME_STEPS_MAP[time_step]
else:
Expand Down Expand Up @@ -204,8 +209,8 @@ def get_cams(start_date, end_date, latitude, longitude, email,

def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
"""
Parse a CAMS Radiation or McClear file. The CAMS Radiation and McClear
services are described in [1]_ and [2]_.
Parse a file-like buffer with data in the format of a CAMS Radiation or
McClear file. The CAMS servicess are described in [1]_ and [2]_.

Parameters
----------
Expand Down Expand Up @@ -286,7 +291,8 @@ def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
data.index = data.index - pd.Timedelta(days=1)

if not integrated: # Convert radiation values from Wh/m2 to W/m2
integrated_cols = [c for c in CAMS_INTEGRATED_COLUMNS if c in data.columns] # noqa
integrated_cols = [c for c in CAMS_RADIATION_INTEGRATED_COLUMNS
if c in data.columns]

if time_step == '1M':
time_delta = (pd.to_datetime(obs_period.str[1])
Expand All @@ -299,15 +305,15 @@ def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
TIME_STEPS_IN_HOURS[time_step])

if map_variables:
data = data.rename(columns=CAMS_VARIABLE_MAP)
data = data.rename(columns=CAMS_RADIATION_VARIABLE_MAP)

return data, meta


def read_cams(filename, integrated=False, label=None, map_variables=True):
"""
Read a CAMS Radiation or McClear file. CAMS radiation and McClear is
described in [1]_ and [2]_, respectively.
Read a CAMS Radiation or McClear file into a pandas DataFrame. CAMS
radiation and McClear is described in [1]_ and [2]_, respectively.

Parameters
----------
Expand All @@ -327,6 +333,7 @@ def read_cams(filename, integrated=False, label=None, map_variables=True):
-------
data: pandas.DataFrame
Timeseries data from CAMS Radiation or McClear
:func:`pvlib.iotools.get_cams` for fields
meta: dict
Metadata avaiable in the file.

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.