Changeset 12983
- Timestamp:
- 03/01/12 14:46:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/fir_filter.py
r12953 r12983 23 23 def __call__(self, data): 24 24 length = max(len(self.a),len(self.b))-1 25 26 #print data 27 #print data.ndim 28 #print data.shape 29 if ( data.ndim == 1): 30 initial = np.ones(length) 31 initial *= data[0] 32 elif ( data.ndim == 2): 33 initial = np.ones( (data.shape[0], length) ) 34 for i in range(data.shape[0]): 35 initial[i,:] *= data[i,0] 25 if length > 0: 26 if ( data.ndim == 1): 27 initial = np.ones(length) 28 initial *= data[0] 29 elif ( data.ndim == 2): 30 initial = np.ones( (data.shape[0], length) ) 31 for i in range(data.shape[0]): 32 initial[i,:] *= data[i,0] 33 else: 34 print 'HELP.' 35 pass 36 37 filtered, zf = signal.lfilter(self.b, self.a, data, zi=initial) 36 38 else: 37 print 'HELP.' 38 pass 39 40 #print 'initial:\n' , initial 41 filtered, zf = signal.lfilter(self.b, self.a, data, zi=initial) 42 #filtered= signal.lfilter(self.b, self.a, data) 39 filtered= signal.lfilter(self.b, self.a, data) 43 40 return filtered 44 41 … … 63 60 b = np.ones(length) 64 61 a = np.zeros(length) 65 a[0] = len(b) 62 if length > 0: 63 a[0] = len(b) 66 64 FirFilter.__init__(self, b, a, 'sliding average') 67 65 … … 73 71 b = np.zeros(length) 74 72 a = np.zeros(length) 75 76 b[0] = -1. * ratio77 b[length-1] = 1.78 a[0] = 1.73 if length > 0: 74 b[0] = -1. * ratio 75 b[length-1] = 1. 76 a[0] = 1. 79 77 FirFilter.__init__(self, b, a, 'constant fraction discriminator') 80 78
Note:
See TracChangeset
for help on using the changeset viewer.