1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

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

5from __future__ import absolute_import 

6 

7from . import autopick_ext 

8import numpy as num 

9 

10 

11class AutopickError(Exception): 

12 pass 

13 

14 

15def recursive_stalta( 

16 tshort, tlong, kshort, klong, kderivative, energytrace, 

17 temp=None, inplace=True): 

18 

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

20 raise AutopickError( 

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

22 'float32 format.') 

23 

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

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

26 

27 if temp is None: 

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

29 

30 if not inplace: 

31 energytrace = energytrace.copy() 

32 

33 autopick_ext.recursive_stalta( 

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

35 temp, temp is None) 

36 

37 if inplace: 

38 return temp 

39 else: 

40 return energytrace, temp