Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/squirrel/io/backends/tdms_idas.py: 50%

20 statements  

« 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---------- 

5 

6''' 

7Squirrel IO adaptor to :py:mod:`pyrocko.io.tdms_idas`. 

8''' 

9 

10from pyrocko.io.io_common import get_stats, touch # noqa 

11from ... import model 

12 

13 

14def provided_formats(): 

15 return ['tdms_idas'] 

16 

17 

18def detect(first512): 

19 from pyrocko.io import tdms_idas 

20 

21 if tdms_idas.detect(first512): 

22 return 'tdms_idas' 

23 else: 

24 return None 

25 

26 

27def iload(format, file_path, segment, content): 

28 assert format == 'tdms_idas' 

29 

30 from pyrocko.io import tdms_idas 

31 

32 load_data = 'waveform' in content 

33 

34 for itr, tr in enumerate(tdms_idas.iload(file_path, load_data=load_data)): 

35 

36 nsamples = int(round((tr.tmax - tr.tmin) / tr.deltat)) + 1 

37 

38 nut = model.make_waveform_nut( 

39 file_segment=0, 

40 file_element=itr, 

41 codes=tr.codes, 

42 tmin=tr.tmin, 

43 tmax=tr.tmin + tr.deltat * nsamples, 

44 deltat=tr.deltat) 

45 

46 if 'waveform' in content: 

47 nut.content = tr 

48 

49 yield nut