196
197 (4) Reading a compressed files.
198
199 >>> from obspy import read
200 >>> st = read("/path/to/tspair.ascii.gz")
201 >>> print(st) # doctest: +ELLIPSIS
202 1 Trace(s) in Stream:
203 XX.TEST..BHZ | 2008-01-15T00:00:00.025000Z - ... | 40.0 Hz, 635 samples
204
205 >>> st = read("https://examples.obspy.org/slist.ascii.bz2")
UNEXPECTED EXCEPTION: ConnectionError(MaxRetryError("HTTPSConnectionPool(host='examples.obspy.org', port=443): Max retries exceeded with url: /slist.ascii.bz2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000022015F70460>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))"))
Traceback (most recent call last):
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connection.py", line 199, in _new_conn
sock = connection.create_connection(
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
raise err
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connectionpool.py", line 490, in _make_request
raise new_e
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connection.py", line 693, in connect
self.sock = sock = self._new_conn()
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connection.py", line 214, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000022015F70460>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\urllib3\util\retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='examples.obspy.org', port=443): Max retries exceeded with url: /slist.ascii.bz2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000022015F70460>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\runneradmin\miniconda3\envs\test\lib\doctest.py", line 1336, in __run
exec(compile(example.source, filename, "single",
File "<doctest obspy.core.stream.read[15]>", line 1, in <module>
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\obspy\core\util\decorator.py", line 298, in _map_example_filename
return func(*args, **kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\obspy\core\stream.py", line 209, in read
st = _generic_reader(pathname_or_url, _read, **kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\obspy\core\util\base.py", line 637, in _generic_reader
download_to_file(url=pathname_or_url, filename_or_buffer=fh)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\obspy\core\util\base.py", line 596, in download_to_file
r = requests.get(url, stream=True)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\requests\adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='examples.obspy.org', port=443): Max retries exceeded with url: /slist.ascii.bz2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000022015F70460>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\obspy\core\stream.py:205: UnexpectedException