8000 Add sodapro.get_cams_radiation by AdamRJensen · Pull Request #1175 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

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
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
Minor updates to mock tests
Includes match keywords for tests that asserts warning and error messages.
  • Loading branch information
AdamRJensen committed Jun 7, 2021
commit e80cbde2f985c085afa2a48178e17a9037f37220
43 changes: 22 additions & 21 deletions pvlib/tests/iotools/test_sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
0.9897]])


# @pytest.fixture() # scope=?
# @pytest.fixture
def generate_expected_dataframe(values, columns, index, dtypes):
"""Create dataframe from arrays of values, columns and index, in order to
use this dataframe to compare to.
Expand Down Expand Up @@ -208,35 +208,34 @@ 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'http://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=arajen%2540byg.dtu.dk;verbose=false&Service=WPS&Request=Execute&Identifier=get_{identifier}&version=1.0.0&RawDataOutput=irradiation' # noqa: E501
url_test_cams = f'http://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

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

# Make API call - an error is raised if requested URI does not match
out, meta = sodapro.get_cams(
start_date=pd.Timestamp('2020-01-01'),
end_date=pd.Timestamp('2020-05-04'),
latitude=55.7906,
longitude=12.5251,
email='arajen@byg.dtu.dk',
email='pvlib-admin@googlegroups.com',
identifier=identifier,
altitude=80,
time_step='1M',
verbose=False,
integrated=False)

expected = generate_expected_dataframe(values, columns, index, dtypes)

assert_frame_equal(out, expected, check_less_precise=True)

# Test if Warning is raised if verbose mode is True and time_step != '1min'
with pytest.warns(UserWarning):
assert sodapro.get_cams(
with pytest.warns(UserWarning, match='Verbose mode only supports'):
_ = sodapro.get_cams(
start_date=pd.Timestamp('2020-01-01'),
end_date=pd.Timestamp('2020-05-04'),
latitude=55.7906,
longitude=12.5251,
email='arajen@byg.dtu.dk',
email='pvlib-admin@googlegroups.com',
identifier=identifier,
altitude=80,
time_step='1M',
Expand All @@ -245,7 +244,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"""
requests inputs. Also tests if the specified server url gets used"""

# Subset of an xml file returned for errornous requests
mock_response_bad = """<?xml version="1.0" encoding="utf-8"?>
Expand All @@ -259,36 +258,38 @@ def test_get_cams_bad_request(requests_mock):
requests_mock.get(url_cams_bad_request, text=mock_response_bad,
headers={'Content-Type': 'application/xml'})

# Test if HTTPError is raised if incorrect input is given
# in this example the end_date is errornously before the start_ 8000 date
with pytest.raises(requests.HTTPError):
assert sodapro.get_cams(
# Test if HTTPError is raised if incorrect input is specified
# In the below example a non-registrered email is specified
with pytest.raises(requests.HTTPError, match='Failed to execute WPS'):
_ = sodapro.get_cams(
start_date=pd.Timestamp('2020-01-01'),
end_date=pd.Timestamp('2020-05-04'),
latitude=55.7906,
longitude=12.5251,
email='test@test.com', # fake email
email='test@test.com', # a non-registrered email
identifier='mcclear',
time_ref='TST',
verbose=False,
time_step='1h',
server='pro.soda-is.com')
# Test if value error is raised if incorrect identifier is specified
with pytest.raises(ValueError):
assert sodapro.get_cams(
with pytest.raises(ValueError, match='Identifier must be either'):
_ = sodapro.get_cams(
start_date=pd.Timestamp('2020-01-01'),
end_date=pd.Timestamp('2020-05-04'),
latitude=55.7906,
longitude=12.5251,
email='test@test.com',
identifier='test') # incorrect identifier
identifier='test', # incorrect identifier
server='pro.soda-is.com')
# Test if value error is raised if incorrect time step is specified
with pytest.raises(ValueError):
assert sodapro.get_cams(
with pytest.raises(ValueError, match='Time step not recognized'):
_ = sodapro.get_cams(
start_date=pd.Timestamp('2020-01-01'),
end_date=pd.Timestamp('2020-05-04'),
latitude=55.7906,
longitude=12.5251,
email='test@test.com',
identifier='mcclear',
time_step='test') # incorrect time step
time_step='test', # incorrect time step
server='pro.soda-is.com')
0