Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/autopick.py: 35%

17 statements  

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

5 

6''' 

7Recursive STA/LTA. 

8''' 

9 

10from . import autopick_ext 

11import numpy as num 

12 

13 

14class AutopickError(Exception): 

15 pass 

16 

17 

18def recursive_stalta( 

19 tshort, tlong, kshort, klong, kderivative, energytrace, 

20 temp=None, inplace=True): 

21 

22 if not energytrace.ydata.dtype == num.float32: 

23 raise AutopickError( 

24 'energytrace given to recursive_stalta() must have data in ' 

25 'float32 format.') 

26 

27 ns = int(round(tshort/energytrace.deltat)) 

28 nl = int(round(tlong/energytrace.deltat)) 

29 

30 if temp is None: 

31 temp = num.zeros((ns+2,), dtype=num.float32) 

32 

33 if not inplace: 

34 energytrace = energytrace.copy() 

35 

36 autopick_ext.recursive_stalta( 

37 ns, nl, kshort/ns, klong/nl, kderivative, energytrace.ydata, 

38 temp, temp is None) 

39 

40 if inplace: 

41 return temp 

42 else: 

43 return energytrace, temp