This is my first ever question here so the help is really appreciated.
I am performing FFT on a signal. I want to perform windowing, 50% overlapping and averaging to the signal. There is a function
scipy.signal.welch to perform this automatically but the output is in power spectral density. I want the output in magnitude and phase shift both, but from power spectral density only magnitude is achievable. Is there a way to compute phase shift from power spectral density or a simple way to do this analysis in the form of FFT rather than in power spectral density?
I know how to apply windowing in python but I do not know how to do overlapping and averaging manually.
Below is my code:
import numpy as np from numpy.fft import fft, ifft, fftshift, fftfreq import pandas as pd import matplotlib.pyplot as plt from scipy import signal import scipy.fft data = pd.read_csv('lucid_1p34g_1024fps_5mins.csv') ref = data.loc[:,"Input 0"] sensor1x = data.loc[:,"Input 1"] sensor1y = data.loc[:,"Input 2"] sensor1z = data.loc[:,"Input 3"] fs = 1024 blockSize = 1024 f, Pxx = signal.welch(sensor1z, 1024, window='hann', nperseg=blockSize, noverlap=512) plt.plot(f, Pxx) # power spectral density plot plt.show() """Manual Calculation""" N = len(sensor1z) n = np.arange(N) T = N/fs freq = n/T window = np.hanning(N) f1z = fft(sensor1z) #fft transform of input 3 plt.plot(freq, np.abs(f1z)) plt.show()