Determine phase and magnitude of an oscillating signal I'm studying mechanical engineering and I would like to determine the magnitude and phase of a signal. Fourier analysis has been mentioned many times during my study and I think I know what it is about but I never had to apply it myself, which is (as usual) way more difficult than following the analysis someone else did;) I tried to find answers to my questions, but haven't been successful so far. I started to get more confused the more I read so I decided to ask somebody for help. I don't expect a final solution, like source code, but could please someone point me in the right direction?
Technical background:
I would like to analyze the bending moment of the rotor mast of a helicopter. The bending moment is calculated from the signal of a strain gauge, which rotates with the rotor. Apparently, the signal of the bending moment is overlain by the rotor revolution. What I need is the phase and the magnitude of the signal.
Approach:
I have time-discrete flight test data of the bending moment and a signal, which indicates, when rotor blade number one is located above the tailboom. I applied a fast fourier transformation to the data of one revolution and would like to determine phase and magnitude from the imaginary and real part of the fourier coefficients. The computations are done by a python script. 
Questions:
As far as I understood, the first fourier coefficent equals the mean value of the signal and the next coefficients equals the coefficient of the first harmonic frequency, which would be the rotor frequency, since I analyse the data of one revolution. If I change the number of terms considered, the coefficents change. This makes perfectly sense to me, but affects phase and magnitude as well. So choosing the second coefficient returned by my fft-function can't be right. What am I missing?
Thanks in advance!
Johannes

How do I choose N? Does N equal the number of measured values?
Never heard of atan2, but I found information about it... 
If the frequency of the coefficient equals k/N, I know, that the coefficient with k=1 stands for the rotor rpm. I did the calculation for 36 revolutions and in 7 cases, the coefficient with k=0 has had the larges magnitude by far. So I'll increase the sampling rate. Fortunately, the raw flight test data is sampled with 25kHz and the data I used unitl now is sampled with 1kHz.
Does it affect the quality of the result, if I calculate the phase and magnitude for every revolution seperately and calculate the mean afterwards instead of calculating the phase and magnitude for the whole flight at once? I decided to calculate the phase and magnitude for each revolution to be able to calculate the standard deviation to asses the quality.
thanks alot!

Here some final notes:


*

*the time for the signal calculated from the fourier coefficients starts at t=0s no matter what time the actual signal starts. This is what leads to the phase shift in the diagramm ("Signals") I posted above.

*calculating the mean of all phases for each revolution leads to a tremendous standard deviation (up to 180°). This is caused by the discontinuity of arctan. It can be solved by calculating the mean of the real and imaginary part of the fourier coefficients befor calculting the phase. I'm not yet sure under which circumstances calculating the mean of the fourier coefficients is valid...

*arctan2 from python expects the arguments in a different order than posted above or as other programms like excel... I used numpy.angle(imaginary number) and numpy.abs(imaginary number) in the end anyway...
Thanks alot for your help!
Johannes
 A: Here's the algorithm I would use: 


*

*Take the DFT/FFT of your sinusoidal signal. If your sinusoidal signal is $x_{n}$, then your transformed signal is 
$$X_{k}=\sum_{n=0}^{N-1}\left[x_{n} \cdot e^{-2\pi ikn/N}\right].$$

*You want the basic amplitude and phase of the strongest frequency component of your signal. So, find $\displaystyle \max_{k} |X_{k}|$, call it $X_{\max}$. 

*The amplitude of the strongest component of your signal is given by
$$\frac{|X_{\max}|}{N}=\frac{\sqrt{\text{Re}^{2}(X_{\max})+\text{Im}^{2}(X_{\max})}}{N},$$
and the phase is given by 
$$\arg(X_{\max})=\text{atan2}(\text{Im}(X_{\max}),\text{Re}(X_{\max})),$$
where you may need to offset this value by the signal that tells you when the rotor blade one is located above the tailboom. I don't know if you're familiar with the $\text{atan2}$ function, but it's basically the arctangent function without the $\pi$ ambiguity that it normally has. I'm pretty sure Python has this function natively. 


If you happen to be interested in the frequency of the sinusoid represented by $X_{\max}$, it is $k/N$ cycles per sample, where $k$ is the index of this component. 
Incidentally, if you find that the first component of your transformed signal is by far the strongest, that's probably an indication that you're not sampling fast enough.
