Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/squirrel/io/backends/datacube.py: 100%
20 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-04 09:52 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-04 09:52 +0000
1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6'''
7Squirrel IO adaptor to :py:mod:`pyrocko.io.datacube`.
8'''
11from pyrocko.io.io_common import get_stats, touch # noqa
12from ... import model
15def provided_formats():
16 return ['datacube']
19def detect(first512):
20 from pyrocko.io import datacube
22 if datacube.detect(first512):
23 return 'datacube'
24 else:
25 return None
28def iload(format, file_path, segment, content):
29 assert format == 'datacube'
31 from pyrocko.io import datacube
33 load_data = 'waveform' in content
35 for itr, tr in enumerate(datacube.iload(file_path, load_data=load_data)):
37 nsamples = int(round((tr.tmax - tr.tmin) / tr.deltat)) + 1
39 nut = model.make_waveform_nut(
40 file_segment=0,
41 file_element=itr,
42 codes=tr.codes,
43 tmin=tr.tmin,
44 tmax=tr.tmin + tr.deltat * nsamples,
45 deltat=tr.deltat)
47 if 'waveform' in content:
48 nut.content = tr
50 yield nut