Changeset 12948 for fact/tools/pyscripts
- Timestamp:
- 02/28/12 17:37:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/fir_filter.py
r12947 r12948 17 17 18 18 """ 19 20 19 self.a = a 21 20 self.b = b … … 23 22 24 23 def __call__(self, data): 25 return signal.lfilter(self.b, self.a, data) 24 length = max(len(self.a),len(self.b))-1 25 initial = np.ones(length) 26 initial *= data[0] 27 filtered, zf = signal.lfilter(self.b, self.a, data, zi=initial) 28 return filtered 26 29 27 30 def __str__(self): 28 31 s = self.name + '\n' 32 s += 'initial condition for filter: signal@rest = 1st sample\n' 29 33 s += 'filter, coefficients:\n' 30 34 s += 'nominator ' + str(self.b) + '\n' … … 42 46 43 47 """ 44 45 48 b = np.ones(length) 46 a = len(b) 49 a = np.zeros(length) 50 a[0] = len(b) 47 51 FirFilter.__init__(self, b, a, 'sliding average') 48 52 … … 70 74 71 75 b = np.array((-0.5, 1., -0.5)) 72 a = 1. 76 a = np.zeros(len(b)) 77 a[0] = 1.0 73 78 FirFilter.__init__(self, b, a, 'remove signal') 74 79
Note:
See TracChangeset
for help on using the changeset viewer.