If X is the time series of the x voltage from a QPD, sampling_f is the sampling frequency in experiment. Then do the following calculation:
fNyq = sampling_f / 2; #calculate the Nyquist frequency
delta_t = 1 / sampling_f; #time interval
time = np.arange(0, np.size(X))*delta_t ;
T = np.max(time);
f = ([1 : length(X)] / T
#do FFT to X and multiple by the time interval
FT = delta_t*fft(X);
P = FT * np.conj(FT) / T; # power spectrum
ind = find(f <= fNyq); # only to the Nyquist f
f = f(ind);
P = P(ind);
fNyq = sampling_f / 2; #calculate the Nyquist frequency
delta_t = 1 / sampling_f; #time interval
time = np.arange(0, np.size(X))*delta_t ;
T = np.max(time);
f = ([1 : length(X)] / T
#do FFT to X and multiple by the time interval
FT = delta_t*fft(X);
P = FT * np.conj(FT) / T; # power spectrum
ind = find(f <= fNyq); # only to the Nyquist f
f = f(ind);
P = P(ind);