Excessive FFT Failure on Mesh Networks?

I ran into an odd issue using meshgrids Numpy with FFT features. In particular, either the fft2 function or the ifft2 function seem to fail when used in an array constructed using meshgrids.

x = np.arange(-4, 4, .08)
y = np.arange(-4, 4, .08)
X, Y = np.meshgrid(x, y)
field = (X + i*Y)*np.exp(X**2 + Y**2)

As a check, before I continued my project, I did

fieldCheck1 = np.fft.fft2(field)
fieldCheck2 = np.fft.ifft2(fieldCheck1)

which should give back its original array, but actually removes the real part (the abs(fieldCheck2)**2flat zero section , where it was originally Gaussian) and completely encrypts the phase information (the phase section fieldCheck2looks like a static, not a phase ramp)

I checked the documentation, but I see nothing there to explain this. Any understanding of the source of the problem would be helpful.

+4
2

( ^ ** ) , 30 :

>>> abs(field).max() / abs(field).min()
8.8904389513698014e+28

, , , . :

>>> x = 1
>>> y = 1e30
>>> z = x + y

>>> x == z - y
False

- , , : , , , , .

+2

, @jakevdp, , , ( ^ ** )

field = (X + 1.0j*Y)*np.exp(X**2 + Y**2)

, , :

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X,Y,np.abs(field));

enter image description here

2D- , :

x = np.arange(-4, 4, .08)
y = np.arange(-4, 4, .08)
X, Y = np.meshgrid(x, y)
field = np.exp(-(X**2 + Y**2))  # notice "-" sign in the exponent

:

enter image description here

np.abs(fieldCheck2-field) round trip as ( ):

enter image description here

0

Source: https://habr.com/ru/post/1629450/


All Articles