How to calculate Signal-To-Noise Ratio I am doing some analysis in python working with a photodiode. The signal is more or less periodic with some phase shifting in certain areas that give rise to faster or slower periods but overall still very periodic. 

I am trying to see how "good" our signal is by computing the Signal-to-Noise ratio (SNR), but so far I have only read from a book on DSP that SNR is defined only as the mean divided by the standard deviation of the signal. Also the book defines Coefficient of variation (CV) as the standard deviation divided by the mean, multiplied by 100. They say a good signal has high SNR and low CV.

Is this simply the definition of SNR or is it something that should be adjusted depending on the signal? How would i go about calculating SNR for my signal?
If you can get input signal when it doesn't contain any useful signal (I mean only noise is presented), you can estimate average noise power at first. Simply find a power of such a signal:


$P_n=1/N \cdot \displaystyle\sum_{k=0}^{N-1}|s(k)|^2$.


Choose $N$ in $2^{12}\ldots 2^{15}$ range for example.

Then you can measure a power of $signal+noise$ mixture, $P_s$, by the same way, when input signal is presented at the input. Caution: the measurement of $P_s$ is only valid if the signal exists all the measurement time. SNR could be calculated by:


$SNR=10 \cdot \log_{10} \frac {P_s - P_n}{P_n}$.


If your noise is stationary and white it's possible to measure it once in the setup and use $P_n$ as a constant. 

If you can't measure noise power at any reason, you can try to estimate SNR in the frequency domain via FFT. But you have to know your signal's band. The point is the same but you should use FFT frequency indexes instead of sample numbers $k$ while estimating integral power. $P_s$ is now power of $signal+noise$ in the band of interest, while $P_n$ is the noise power in total band ($0...fs$). In this case power spectral density of the noise in your system should be evaluated at first. This method could be far too complex for your task.

Both methods show you pointless result in the case of low SNR in the signal band (not total band in general). Frequency domain method will be preferable if your signal's band is quite less than $f_s$, otherwise time domain method will be good enough. To estimate SNR of the order of 5 dB or lower it's better to know signal and noise power (or power spectral density) a priory. So the task has robust analitical solution.

Hope this helps.