I am a newbie in signal processing and would like to know the significance of using the abs()
function and squaring the values received as an output of fft()
function of Python's scipy.fftpack
library, used when trying to plot a power spectral density for a dataset. I have found that many of code examples to plot a power spectral density do use an abs()
and then square the values obtained thereafter.
- Can anyone please provide me a reason for doing so?
- Can't we just directly plot the values obtained from
fft()
function in Python'sscipy.fftpack
library?
Here is the code I have written till now to plot a power spectral density by referring some of the code examples,
import scipy.io as sio
import numpy as np
Import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("denoised.csv")
data = df.values
from scipy.fftpack import fft,fftfreq
dft= fft(data)
PSD = np.abs(dft) ** 2