import scipy.optimize as opt
def fun1(u,es):
theta = u[0]
ret = (np.fft.fft(es_storex.flatten()+1j*es_storey.flatten()))*np.exp(1j*theta)
return (ret)
x = np.array([3.])
results = opt.minimize(fun1, x)
I'm trying to do a phase correction to my FFT signal. esx_store[0] and esy_store[0] are arrays of data. Is there a way I can use scipy.optimize.minimize to minimize these data, and get the optimal value for theta to perform phase correction to my data?
With flatten() it still gives the error " ValueError: The user-provided objective function must return a scalar value."