'How to make a Velocity Autocorrelation function in 3D [python]

Im trying to figure out a way of autocorrelating a data set that contains velocity arrays in the x,y,z direction using FFT. My funciton below uses numpy's fft.fftn function (https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.fft.fftn.html) and this doesnt seem to plot the autocorrelation in 3D but rather the autocorrelation of x,y,z seperatly.

t=len(data)
lag=linspace(0,t-1,t)
result = np.fft.fftn(data)
plt.plot(lag,result)

Anybody help me how to get this to work or suggest a better method?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source