I do np.fft.fft() to decompose discrete-signal to frequencies. Then I pick top N freqs and now I want to draw a signal of the sum of those frequencies using the following formula :
amp * np.sin( 2 * np.pi * freq * time + phase )
I extract the freqs based on their position in the array (fftfreqs), amplitudes with np.abs(complex_num) and phases with np.angle(complex_num, deg=True), from the data I got from from fft() call.
It does not seem to work very well.
What I'm doing wrong ? Do I understand correctly that the complex-num contains the amp&phase of sinusoid ? Do I have to use sin&cos for the drawing ? The documentation is very sparse on exact interpretation of the result of fft().
PS> I know I can use np.fft.ifft() to draw close approximation, but this way of doing it is limited to the time-frame of the original signal. I want to draw/fit the original signal with the top N freqs in the original timeframe, but also to draw the "continuation" of the signal after this timeframe using those freqs i.e. the extended signal.
deg=True
parameter normally does not play well withsin()
. Posting some runnable code would ease to investigate what is not working well. – Dietrich