# Error handle\_request while downloadng surface albedo data

**URL:** <https://forum.ecmwf.int/t/error-handle-request-while-downloadng-surface-albedo-data/1694>\
**Category:** Other - Software and tools\
**Tags:** c3s, toolbox\
**Created:** [24 February 2023 03:45 UTC](https://forum.ecmwf.int/t/error-handle-request-while-downloadng-surface-albedo-data/1694 "2023-02-24T03:45:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![User\_akanksha\_dot\_ba](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/u/b5a626/32.png) [@User\_akanksha\_dot\_ba](https://forum.ecmwf.int/u/User_akanksha_dot_ba)\
**Post date:** [24 February 2023 03:45 UTC](https://forum.ecmwf.int/t/error-handle-request-while-downloadng-surface-albedo-data/1694/1 "2023-02-24T03:45:49Z")

</div>

&nbsp; While calculating mean and standard deviation of surface albedo data for few years (as it is unable to plot long time series), whenever I try to run the code, it gives me following error. Can anyone please help me in resolving it. (The code which I am using is mentioned at the bottom)

```
Error:

Traceback (most recent call last):
  File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 59, in handle_request
    result = cached(context.method, proc, context, context.args, context.kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/caching.py", line 108, in cached
    result = proc(context, *context.args, **context.kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 124, in __call__
    return p(*args, **kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 60, in __call__
    return self.proc(context, *args, **kwargs)
  File "/home/cds/cdsservices/services/retrieve.py", line 197, in execute
    remote = context.call_resource(name, request, update_specific_metadata={'app_scope': 'adaptor'})
  File "/opt/cdstoolbox/cdscompute/cdscompute/context.py", line 307, in call_resource
    return c.call_resource(service, *args, **kwargs).value
  File "/opt/cdstoolbox/cdsworkflows/cdsworkflows/future.py", line 76, in value
    raise self._result
cdsworkflows.error.ClientError: {'traceback': 'Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.6/http/client.py", line 1346, in getresponse
    response.begin()
  File "/usr/lib64/python3.6/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.6/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib64/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib64/python3.6/ssl.py", line 971, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib64/python3.6/ssl.py", line 833, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib64/python3.6/ssl.py", line 590, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/usr/local/lib/python3.6/site-packages/requests/adapters.py”, line 450, in send  
timeout=timeout  
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 788, in urlopen  
method, url, error=e, \_pool=self, \_stacktrace=sys.exc\_info()[2]  
File “/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py”, line 550, in increment  
raise six.reraise(type(error), error, \_stacktrace)  
File “/usr/local/lib/python3.6/site-packages/urllib3/packages/six.py”, line 769, in reraise  
raise value.with\_traceback(tb)  
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 710, in urlopen  
chunked=chunked,  
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 449, in \_make\_request  
six.raise\_from(e, None)  
File “\<string\>”, line 3, in raise\_from  
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 444, in \_make\_request  
httplib\_response = conn.getresponse()  
File “/usr/lib64/python3.6/http/client.py”, line 1346, in getresponse  
response.begin()  
File “/usr/lib64/python3.6/http/client.py”, line 307, in begin  
version, status, reason = self.\_read\_status()  
File “/usr/lib64/python3.6/http/client.py”, line 268, in \_read\_status  
line = str(self.fp.readline(\_MAXLINE + 1), “iso-8859-1”)  
File “/usr/lib64/python3.6/socket.py”, line 586, in readinto  
return self.\_sock.recv\_into(b)  
File “/usr/lib64/python3.6/ssl.py”, line 971, in recv\_into  
return self.read(nbytes, buffer)  
File “/usr/lib64/python3.6/ssl.py”, line 833, in read  
return self.\_sslobj.read(len, buffer)  
File “/usr/lib64/python3.6/ssl.py”, line 590, in read  
v = self.\_sslobj.read(len, buffer)  
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/opt/cds/cdsinf/python/lib/cdsclient/brokerclient.py”, line 570, in make\_request  
\*\*kwargs  
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 75, in get  
return request(‘get’, url, params=params, \*\*kwargs)  
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 61, in request  
return session.request(method=method, url=url, \*\*kwargs)  
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 529, in request  
resp = self.send(prep, \*\*send\_kwargs)  
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 645, in send  
r = adapter.send(request, \*\*kwargs)  
File “/usr/local/lib/python3.6/site-packages/requests/adapters.py”, line 501, in send  
raise ConnectionError(err, request=request)  
requests.exceptions.ConnectionError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “/opt/cds/cdsinf/python/lib/cdsinf/runner/dispatcher.py”, line 617, in handle\_request  
context.get(“method\_config”, None))  
File “/opt/cds/adaptor/cdshandlers/adaptorlib/adaptorrequesthandler.py”, line 68, in handle\_request  
return super().handle\_request(cdsinf, data\_request, self.config)  
File “/opt/cds/cdsinf/python/lib/cdsinf/runner/requesthandler.py”, line 170, in handle\_request  
return handler(cdsinf, request, config)  
File “/opt/cds/adaptor/cdshandlers/archivecombiner/handler.py”, line 63, in handle\_retrieve  
config)  
File “/opt/cds/adaptor/cdshandlers/adaptorlib/url\_fetch.py”, line 103, in combine  
di)  
File “/opt/cds/adaptor/cdshandlers/adaptorlib/url\_fetch.py”, line 189, in process\_one\_input\_archive  
di, extractor\_class)  
File “/opt/cds/adaptor/cdshandlers/adaptorlib/url\_fetch.py”, line 170, in dataitem\_to\_extractor  
allocation = di.as\_file(use\_server\_filename=self.use\_server\_filenames)  
File “/opt/cds/cdsinf/python/lib/cdsinf/brokerclient.py”, line 209, in as\_file  
response\_info = self.\_write\_to(tmp\_name, allocation.handle\_out\_of\_space)  
File “/opt/cds/cdsinf/python/lib/cdsclient/brokerclient.py”, line 346, in \_write\_to  
return self.\_build\_requester(filename, handle\_out\_of\_space).make\_request(None)  
File “/opt/cds/cdsinf/python/lib/cdsclient/requesterchain.py”, line 311, in make\_request  
result = self.next\_in\_chain.make\_request(request)  
File “/opt/cds/cdsinf/python/lib/cdsclient/brokerclient.py”, line 589, in make\_request  
“[http://copernicus-climate.eu/exc/data-connection](http://copernicus-climate.eu/exc/data-connection)”) from e  
cdsclient.exceptions.DataProviderFailed: Failed to connect to data source: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))  
'}  
  
  
  
Code:
```

Import cdstoolbox as ct

layout = { 'input\_ncols': 2,  
 'input\_align': 'bottom'  
 }

variables = { 'Broadband directional surface albedo': 'albb\_dh',  
 }

tip = 'Changing value will restart the processing.'

@ct.application(title='Calculate Mean and Stdev', layout=layout)

@ct.input.dropdown('variable', label='Variable', values=variables.keys(), help=tip)

@ct.input.dropdown('year', label='Year', values=range(2014, 2017), help=tip)

@ct.input.text('lon', type=float, label='Longitude', default=-121.5, help=tip)

@ct.input.text('lat', type=float, label='Latitude', default=69.4, help=tip)

@ct.output.livefigure()  
  
 def mean\_standard\_deviation(

variable,

year,

lon,

lat,

):

data = ct.catalogue.retrieve(

'satellite-albedo',

{

'variable': variables[variable],

'grid': ['3', '3'],

'product\_type': 'satellite-albedo',

'satellite': 'Proba',

'sensor': 'VGT',

'product\_version': 'v1',

'horizontal\_resolution': '1km',

'year': [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '2014', '2015',  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '2016'  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],  
'month': [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '01', '04',  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '07', '10'  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],  
'nominal\_day': [  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '03'  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],  
 &nbsp; &nbsp; &nbsp; &nbsp; }  
 &nbsp; &nbsp; )

data\_location = ct.geo.extract\_point(ct.cube.select(data, time=year), lon=lon, lat=lat)  
  
monthly\_mean = ct.climate.monthly\_mean(data\_location)

monthly\_std = ct.climate.monthly\_std(data\_location)

daily\_mean = ct.climate.daily\_mean(data\_location)

daily\_std = ct.climate.daily\_std(data\_location)

fig = ct.chart.line(  
 daily\_mean,

error\_y=daily\_std,

scatter\_dict={'name': 'daily'},

layout\_dict={'title': 'Monthly/Daily mean with standard deviation'}  
)

fig = ct.chart.line(  
 monthly\_mean,

fig=fig,

error\_y=monthly\_std,

scatter\_dict={'name': 'Monthly'}  
 )

return fig
