In short, I am coding an optics simulation for an experiment I am running. There is a point where I perform a Fourier transform on my incoming signal and want to extract the phase; however, I get unexpected results.
More specifically, I want to unwrap the phase from the signal below:
def phase_extractor(fourier, t_max, t):
phase = np.angle(fourier)
# Unwrap the phase to remove jumps or discontinuities
phase_spectrum = np.unwrap(phase)
#proper_phase = torch.from_numpy(phase_realtime)
Ignore the t_max and t inputs - they aren't of interest for now
After running the function on this input data and simply plotting the phase spectrum, I get the following result:
I was expecting it to have discrete steps at pi intervals (i.e., it would look like a staircase with steps of height pi).
So far in terms of debugging, I have done the following:
- After using np.angle() I checked the difference between consecutive elements in a list and the maximum was pi, so that tells me resolution isn't an issue.
- I've tried doing an fftshift of my data so that unwrapping starts at the zero-frequency; however that doesn't change much - the only notable difference is a small bump in the centre of the output.
If anyone knows about phase unwrapping and could help me out that'd be great. I am not too familiar with phase unwrapping and have had some major difficulty debugging this
Edit: Sorry for any clarity issues, this is very crudely what I was expecting (i.e., a staircase type function with height of ~pi):