@@ -57,8 +57,10 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
5757 Access: free, but requires registration, see [2]_
5858
5959 Requests: max. 100 per day
60+
6061 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.
6264
6365 Parameters
6466 ----------
@@ -157,6 +159,9 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
157159 <https://atmosphere.copernicus.eu/solar-radiation>`_
158160 .. [2] `CAMS Radiation Automatic Access (SoDa)
159161 <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`
160165 """
161166 try :
162167 time_step_str = TIME_STEPS_MAP [time_step ]
@@ -215,14 +220,16 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
215220 res = requests .get (base_url + '?DataInputs=' + data_inputs , params = params ,
216221 timeout = timeout )
217222
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 :
222228 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 ()
224231 # Successful requests returns a csv data file
225- elif res . headers [ 'Content-Type' ] == 'application/csv' :
232+ else :
226233 fbuf = io .StringIO (res .content .decode ('utf-8' ))
227234 data , metadata = parse_cams (fbuf , integrated = integrated , label = label ,
228235 map_variables = map_variables )
0 commit comments