Numpy signal processing: Efficiently summarize subarrays of consecutive nonzero elements

so, I’m working with FFT data that when thoroughly cleaned should look like many many zeros and an occasional large number. What I have at the moment is many zeros and an occasional short subarray of largish numbers. as an example, ydata=np.array([0,0,0,0,1,2,3,0,0,9,3, 1, 0, 2, 9, 0]) xdata=np.array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) I’m using an array of consecutive integers… Read More Numpy signal processing: Efficiently summarize subarrays of consecutive nonzero elements

Is there a way to generate multiple sine waves without using loop in Python?

I am trying to generate multiple sine waves, but I want to avoid using loops. Is there a way to do it as in MATLAB? Here is what I tried: fs =250 n = np.linspace(0,2,int(fs*2),endpoint=False) frequencies = [1,3,4,12,70] sines = np.sin(2*np.pi*frequencies*n) When I tried this code I got the following error: ValueError: operands could not… Read More Is there a way to generate multiple sine waves without using loop in Python?