My aim is to plot the PSD of a complex vector x. I calculated the spectrum estimation using scipy.welch (version 1.4.1):
f, Px = scipy.signal.welch(**x**, return_onesided=False, detrend=False)
and then plotted:
plt.plot(f, 10*np.log10(Px),'.-')
plt.show()
The PSD was plotted fine, but I noticed an interpolation line from the last sample to the first on the plot. I then checked the frequency indices and noticed that they are ordered from DC(0) to half the sample rate(0.5 in this case) and then from -0.5 to almost zero. This is why the plot has a straight line across from Px(0.5) to Px(-0.5).
Why the returned f vector(and the appropriate Px) is not from -0.5 to 0.5 ? Can someone suggest a straight forward method? (I'm used to MATLAB and it is much simpler to plot a PSD there...) Thanks