Sorry if this is a basic question, but suppose I have a signal that is locally periodic over short time intervals but is not globally of that period. As an example:
import numpy as np
import matplotlib.pyplot as plt
x_limit = 100
res = 50000
random_factor = 0.345
periods_per_slip = 4
x = np.linspace(-x_limit, x_limit, res)
y = np.sin(2*np.pi*x)
yp = 1.1*np.sin(2*np.pi*x - random_factor * (np.pi * np.floor(x/periods_per_slip)))
plt.plot(x,y)
plt.plot(x, yp)
plt.xlim(-10, 10)
The blue curve is a pure sinusoid of period 1, while the orange curve is locally a sinusoid of the same period but with occasional phase slips.
The Fourier transform is below
plt.figure()
plt.plot(np.linspace(-np.pi/(2*x_limit/res), np.pi/(2*x_limit/res), res), np.abs(np.fft.fftshift(np.fft.fft(y))))
plt.plot(np.linspace(-np.pi/(2*x_limit/res), np.pi/(2*x_limit/res), res), np.abs(np.fft.fftshift(np.fft.fft(yp))))
plt.xlim(-10, 10)
plt.ylim(-1000, 30000)
Here, the dominant frequency is not $\omega = 2\pi$ (as it is in the pure sinusoid) but is shifted slightly.
So my question is: what is a proper analysis method for extracting the local characteristic period ($2\pi/\omega = 1$) of this signal? Short-time Fourier transforms? Wavelets? Clearly, just taking the frequency with the highest FFT amplitude gives the "wrong" answer.
The example above is just a toy model. My actual application is image processing for crystallography, so I'm looking for a technique that generalizes to two dimensions.