1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6from __future__ import absolute_import, print_function 

7 

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

9from ... import model 

10 

11 

12def provided_formats(): 

13 return ['tdms_idas'] 

14 

15 

16def detect(first512): 

17 from pyrocko.io import tdms_idas 

18 

19 if tdms_idas.detect(first512): 

20 return 'tdms_idas' 

21 else: 

22 return None 

23 

24 

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

26 assert format == 'tdms_idas' 

27 

28 from pyrocko.io import tdms_idas 

29 

30 load_data = 'waveform' in content 

31 

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

33 

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

35 

36 nut = model.make_waveform_nut( 

37 file_segment=0, 

38 file_element=itr, 

39 codes=tr.codes, 

40 tmin=tr.tmin, 

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

42 deltat=tr.deltat) 

43 

44 if 'waveform' in content: 

45 nut.content = tr 

46 

47 yield nut