Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/squirrel/io/backends/mseed.py: 100%
32 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +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.mseed`.
8'''
10from pyrocko.io.io_common import get_stats, touch # noqa
11from ... import model
13SEGMENT_SIZE = 1024*1024
16def provided_formats():
17 return ['mseed']
20def detect(first512):
21 from pyrocko.io import mseed
23 if mseed.detect(first512):
24 return 'mseed'
25 else:
26 return None
29def iload(format, file_path, segment, content):
30 assert format == 'mseed'
31 from pyrocko.io import mseed
33 load_data = 'waveform' in content
35 if segment is None:
36 offset = 0
37 nsegments = 0
38 else:
39 offset = segment
40 nsegments = 1
42 file_segment = None
43 itr = 0
44 for tr in mseed.iload(
45 file_path, load_data=load_data,
46 offset=offset, segment_size=SEGMENT_SIZE, nsegments=nsegments):
48 if file_segment != tr.meta['offset_start']:
49 itr = 0
50 file_segment = tr.meta['offset_start']
52 nsamples = int(round((tr.tmax - tr.tmin) / tr.deltat)) + 1
53 nut = model.make_waveform_nut(
54 file_segment=file_segment,
55 file_element=itr,
56 codes=tr.codes,
57 tmin=tr.tmin,
58 tmax=tr.tmin + tr.deltat * nsamples,
59 deltat=tr.deltat)
61 if 'waveform' in content:
62 nut.content = tr
64 yield nut
65 itr += 1