@@ -57,8 +57,10 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
57
57
Access: free, but requires registration, see [2]_
58
58
59
59
Requests: max. 100 per day
60
+
60
61
Geographical coverage: worldwide for CAMS McClear and approximately -66° to
61
- 66° in both latitude and longitude for CAMS Radiation.
62
+ 66° in latitude and -66° to 180° in longitude for CAMS Radiation. See [3]_
63
+ for a map of the geographical coverage.
62
64
63
65
Parameters
64
66
----------
@@ -157,6 +159,9 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
157
159
<https://atmosphere.copernicus.eu/solar-radiation>`_
158
160
.. [2] `CAMS Radiation Automatic Access (SoDa)
159
161
<https://www.soda-pro.com/help/cams-services/cams-radiation-service/automatic-access>`_
162
+ .. [3] A. R. Jensen et al., pvlib iotools — Open-source Python functions
163
+ for seamless access to solar irradiance data. Solar Energy. 2023. Vol
164
+ 266, pp. 112092. :doi:`10.1016/j.solener.2023.112092`
160
165
"""
161
166
try :
162
167
time_step_str = TIME_STEPS_MAP [time_step ]
@@ -215,14 +220,16 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
215
220
res = requests .get (base_url + '?DataInputs=' + data_inputs , params = params ,
216
221
timeout = timeout )
217
222
218
- # Invalid requests returns an XML error message and the HTTP staus code 200
219
- # as if the request was successful. Therefore, errors cannot be handled
220
- # automatic (e.g. res.raise_for_status()) and errors are handled manually
221
- if res .headers ['Content-Type' ] == 'application/xml' :
223
+ # Response from CAMS follows the status and reason format of PyWPS4
224
+ # If an error occurs on server side, it will return error 400 - bad request
225
+ # Additional information is available in the response text, so it is added
226
+ # to the error displayed to facilitate users effort to fix their request
227
+ if not res .ok :
222
228
errors = res .text .split ('ows:ExceptionText' )[1 ][1 :- 2 ]
223
- raise requests .HTTPError (errors , response = res )
229
+ res .reason = "%s: <%s>" % (res .reason , errors )
230
+ res .raise_for_status ()
224
231
# Successful requests returns a csv data file
225
- elif res . headers [ 'Content-Type' ] == 'application/csv' :
232
+ else :
226
233
fbuf = io .StringIO (res .content .decode ('utf-8' ))
227
234
data , metadata = parse_cams (fbuf , integrated = integrated , label = label ,
228
235
map_variables = map_variables )
0 commit comments