scipy - Filtering signal with Python lfilter -


I'm new to Python and I'm completely trapped when filtering the signal. This code is:

  Import NMP as import matplotlib.pyplot as SPC import signal from PLT = 105e6fin = 70.1a6n = NP.Range (0,21A3, 1) Create a CIC filter to define "B" and "A" polynomials (R = RO) = an input sin signal of 70 MHz 105 MHz x_in = np.sin (2 * np.pi * (wings) / FS) * N) 8, M = 2, N = 6) B = NP. Jereos (97) b [[16,32,48,64,80,96]] = [1, -6,15, -20,15, -6,1] a = np. joros (7) one [[0,1,2,3,4,5,6]] [[, 1, -6, 15, -20, 15, -6,1] w, h = signal frackage (b, a) plat. Plot (W / Max (W), 20 * NPLag 10 (ABS (H) / NPNMX (H)) Plat. ('CIC Filter Response') Output_nco_cic = signal.lfilter (b, a, x_in) plt.figure () plt.plot (x_in) plt.title ('input signal') plt.figure () plt.plot (output_nco_cic ) Plt.title ('Filter Signal')  

and plot:

As you can see, although the filter transfer function is correct, there is no output. And I can not see why my code is not working, I have just coded in Matlab and the output looks ok.

Thanks for the help!

I do not think it is misleading that it does not work with Python, but I am confused that It works with matlab.

CIC filter floating point number.

Update:

Interesting, at least with the version of wrapped me, lfilter does not work with integer arrays - I get a NotImplemented error here. The oval version is twice as fast as pure Python implementation on my machine:

  implements an in-memory CIC desimeter using # nmpy. Calculate the total number of bits used internally: Numpy import int32, int64, array def cic_decimator (source, decimation_factor = 32, order = 5, ibits = 1, obits = 16) from the math import log; Output # Shift and mask is required Numbits = order * int (round (log (decimation_factor) / log (2)) + ibits outshift = numbits - obits outmask = (1  obit) - 1 # If more than 64 bits is required, then we do not do this ... emphasis on curb & lt; Create a numpy array with array = = 64 # source result = array (source, int64 if numbits> 32 else int32) for the # range I do in the integration phase (sequence): Results Cumsum (outside = results) # decimal result = Array (Results [decimation_factor - 1 :: decimation_factor]) # What Combinational Stages Retracting backwards through the array, # Because we use each value before changing it. In the range (order): Results [Lenan (results) - 1: 0: -1] - = Results [lane (results) - 2 :: -1] # Normal output results & gt; = = External results & amp; ; = Outbound returns result  

Comments