Should we divide the power at 0Hz by two for Single-Sided Power Spectrum with FFT?

To make my question as clear as possible I will go through an example. I want to plot one sided power spectrum of a signal. As an example my signal is sum of "50Hz sine with and amplitude of 1V" and "DC offset voltage of 1V". I create this signal and plot FFT of it where I define the power as amplitude square divided by two.

Here is my code:

import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
import scipy.fftpack

f = 50 #signal freq
D = 1 #duration
fs = 800 #sampling freq
T = 1/f #signal period
N = int((D/(1/fs))+1) #number of smaples

t = np.linspace(0, D, num=N, endpoint=True) #time vector
dc = 1
y = np.sin(2*np.pi*f*t) + dc

plt.plot(t, y,'-b')
plt.plot(t, y,'.r')
plt.title('~ Sinusoid ~')
plt.xlabel('time [s]')
plt.ylabel('Voltage [V]')
plt.grid()
plt.show()

#FFT
plt.figure()
y = y
T = t[2]-t[1]
sampling_rate = 1/T
N = len(y)
yf = scipy.fftpack.fft(y)
xf = np.linspace(0.0, 1.0/(2.0*T), N//2)
amplitude = 2.0/N * np.abs(yf[:N//2])
pow = amplitude*amplitude/2

plt.plot(xf, pow,'b')
plt.grid()
plt.xlabel('Frequency [Hz]')
plt.ylabel('Power [W]')


Now the rms power for the sine component can be calculated as (amplitude square)/2 which is 0.5W and this is what we see at the plot above.

And for the 1V DC component, I would say the rms power is (amplitude square) which is 1W. But the plot shows twice of it namely 2W.

My question is: Should I divide the power by two at 0Hz at FFT plot in my code or am I interpreting something wrong?

• Your DC component produces 1 W. Your sine wave is 0.5 W, since the RMS of a sine wave with amplitude 1 is $\sqrt 2$ and the square of this is 0.5. Total power is 1.5W. If you look at it two-sided you should see 1 W at 0Hz and 0.25 W at 50Hz and -50Hz each. If you look at it one-sided you should 1 W at 0Hz and 0.5W at 50 Hz. However the total power sum must match the power in the time domain, i.e. 1.5W total power – Hilmar Jan 14 at 17:16