Fourier Transform

xr-scipy wraps numpy.fft, for more convenient data analysis with xarray. Let us consider an example DataArray

In [1]: arr = xr.DataArray(np.sin(np.linspace(0, 15.7, 30)) ** 2,
   ...:                    dims=('x'), coords={'x': np.linspace(0, 5, 30)})
   ...: 

In [2]: arr
Out[2]: 
<xarray.DataArray (x: 30)>
array([0.00000000e+00, 2.65553207e-01, 7.80138804e-01, 9.97157371e-01,
       6.86089001e-01, 1.77354508e-01, 1.13381944e-02, 3.64384719e-01,
       8.61483534e-01, 9.74609903e-01, 5.83599545e-01, 1.03788678e-01,
       4.48385590e-02, 4.69366760e-01, 9.26433982e-01, 9.30537558e-01,
       4.77318618e-01, 4.81921327e-02, 9.89817591e-02, 5.75738105e-01,
       9.72044464e-01, 8.66939139e-01, 3.72066354e-01, 1.30863288e-02,
       1.71312250e-01, 6.78674515e-01, 9.96246419e-01, 7.86699011e-01,
       2.72616236e-01, 6.34122960e-05])
Coordinates:
  * x        (x) float64 0.0 0.1724 0.3448 0.5172 ... 4.483 4.655 4.828 5.0

Our fft() takes an xarray object (possibly high dimensional) and a coordinate name which direction we compute the Fourier transform.

In [3]: fft = xrscipy.fft.fft(arr, 'x')

In [4]: fft
Out[4]: 
<xarray.DataArray (x: 30)>
array([ 1.45066531e+01+0.j        , -5.08969487e-01-0.05277866j,
       -5.64134191e-01-0.11825163j, -6.97777394e-01-0.22340666j,
       -1.09493558e+00-0.47978099j, -6.34538952e+00-3.59910605j,
        1.08016447e+00+0.76901603j,  4.01404487e-01+0.35285112j,
        2.07930614e-01+0.22420945j,  1.19289778e-01+0.15804858j,
        7.02940829e-02+0.11554961j,  4.06345993e-02+0.08441817j,
        2.20354770e-02+0.05946099j,  1.05946593e-02+0.03803481j,
        4.35028404e-03+0.01857428j,  2.36237341e-03+0.j        ,
        4.35028404e-03-0.01857428j,  1.05946593e-02-0.03803481j,
        2.20354770e-02-0.05946099j,  4.06345993e-02-0.08441817j,
        7.02940829e-02-0.11554961j,  1.19289778e-01-0.15804858j,
        2.07930614e-01-0.22420945j,  4.01404487e-01-0.35285112j,
        1.08016447e+00-0.76901603j, -6.34538952e+00+3.59910605j,
       -1.09493558e+00+0.47978099j, -6.97777394e-01+0.22340666j,
       -5.64134191e-01+0.11825163j, -5.08969487e-01+0.05277866j])
Coordinates:
  * x        (x) float64 0.0 0.1933 0.3867 0.58 ... -0.58 -0.3867 -0.1933

The coordinate x is also converted to frequency.

In [5]: plt.figure(figsize=(10, 4))
Out[5]: <Figure size 1000x400 with 0 Axes>

In [6]: plt.subplot(1, 2, 1)
Out[6]: <matplotlib.axes._subplots.AxesSubplot at 0x7fdc22a12f90>

In [7]: arr.plot()
Out[7]: [<matplotlib.lines.Line2D at 0x7fdc22286250>]

In [8]: plt.subplot(1, 2, 2)
Out[8]: <matplotlib.axes._subplots.AxesSubplot at 0x7fdc22273f90>

In [9]: np.abs(fft).plot()
Out[9]: [<matplotlib.lines.Line2D at 0x7fdc22243cd0>]

In [10]: plt.show()
_images/fft.png

Note

The coordinate values must be evenly spaced for FFT.

Multidimensional Fourier transform

xr-scipy also wraps the multidimensional Fourier transform, such as rfftn()

Their usage is very similar to the above, where we just need to specify coordinates.

In [11]: arr = xr.DataArray(np.random.randn(30, 20) ** 2,
   ....:                    dims=('x', 'y'),
   ....:                    coords={'x': np.linspace(0, 5, 30),
   ....:                            'y': np.linspace(0, 5, 20)})
   ....: 

In [12]: fftn = xrscipy.fft.fftn(arr, 'x', 'y')

In [13]: fftn
Out[13]: 
<xarray.DataArray (x: 30, y: 20)>
array([[ 6.80147367e+02+0.00000000e+00j, -5.40888999e+01-1.48914052e+01j,
         2.24071878e+01-6.83472672e+00j, -1.05248506e+01-1.98086495e+01j,
         3.30186673e+01+2.47699470e+01j, -4.10255035e+01+1.25478518e+01j,
         2.07742440e+01-2.10698675e+01j,  1.12280731e+01+8.16514918e+00j,
        -6.15766306e+01+1.53389009e+01j,  1.68000520e+01+3.08873987e+01j,
         6.91096924e+01+0.00000000e+00j,  1.68000520e+01-3.08873987e+01j,
        -6.15766306e+01-1.53389009e+01j,  1.12280731e+01-8.16514918e+00j,
         2.07742440e+01+2.10698675e+01j, -4.10255035e+01-1.25478518e+01j,
         3.30186673e+01-2.47699470e+01j, -1.05248506e+01+1.98086495e+01j,
         2.24071878e+01+6.83472672e+00j, -5.40888999e+01+1.48914052e+01j],
       [-9.78304942e+00-2.00060691e+01j, -3.01214418e+01-6.86851691e-01j,
         3.65704485e+01+2.64031486e+01j, -1.65402379e+01+5.18006959e+00j,
         5.75308280e+00+2.73910712e+01j, -2.48612360e+01-1.19071034e+01j,
        -1.90295095e+01+5.25959400e+01j, -7.66929151e+00-4.16255367e+00j,
        -3.41801537e+01+4.29905149e+01j,  1.23190320e+01+1.63252604e+01j,
        -4.84907294e+01-4.16601947e+01j,  1.07657876e+01-1.41656999e+01j,
        -3.39807068e+01+9.65027977e+00j,  5.89818080e+01-1.58963695e+00j,
        -2.24569277e+01+4.78807494e+00j,  2.29408613e+00-2.10730557e+01j,
         1.20560230e+00+2.45535230e+01j, -2.64074189e+01-1.52314832e+01j,
        -3.75456761e+00+6.28466305e+01j,  1.28963968e+01-3.01513717e+01j],
       [ 1.18390109e+01+1.69615481e+01j, -1.03891185e+01+3.07147965e+01j,
         3.48168720e+00+3.93232365e+01j,  1.51573868e+01+8.87107641e-02j,
        -3.26843493e+01+2.78910788e+01j, -7.38998869e+00+5.92937093e+00j,
         1.99909029e+01-2.37322857e+01j,  6.89571773e+00-7.65203935e+00j,
        -2.41167969e+01+8.25647322e+00j,  2.60820207e+01-1.08850196e+01j,
        -2.91364141e+01-4.57237154e+01j,  4.48110583e+01+2.09499730e+00j,
        -5.77461281e+00-2.23819916e+01j,  2.27092738e+01+1.09230345e+01j,
        -3.63069591e+01+2.63605337e+01j,  1.49904457e+01+1.62863784e+00j,
         5.18844566e+01-3.92437600e+01j, -6.17481319e+00+1.43282178e+01j,
         8.93965329e+00+1.28033963e+01j,  2.23641363e+01-2.98647685e-02j],
       [-3.00756470e+01-2.02311653e+01j, -1.52199079e+01+6.12960304e+01j,
         4.71762598e+01-8.72739590e+00j,  3.95568373e+01-8.28074518e+00j,
         2.05435690e+00+1.04214009e+01j,  1.26375702e+00+5.25047677e+00j,
        -2.30835820e+01+2.65438675e+01j, -2.16237997e+01-1.94507161e+01j,
         1.62248018e+01+4.73648432e+00j,  3.91626381e+00-1.85662042e+00j,
        -5.02314992e+01-1.11478363e+01j,  1.44147644e+01+2.88680317e+01j,
         4.52215055e+01-3.12928417e+01j, -1.10414273e+01-7.78928074e+00j,
         1.17154656e+01-3.47452516e+01j, -2.36212076e+01+5.93467176e+01j,
        -1.80884532e+00-3.35852750e+01j,  3.10571817e+00+4.66607518e+01j,
         2.03781124e+01-1.49895411e+01j, -2.13363900e+01+1.58769170e+01j],
       [ 7.15150886e+00+1.25220177e+01j, -1.64656200e+01-8.80436886e+00j,
         2.35781124e+01-3.03692665e+01j, -2.21190855e+01-4.34572687e-02j,
         1.81568112e+01+1.23120934e+01j,  4.94153737e+01-9.78063668e+00j,
        -7.49789987e+00+1.57377970e+01j, -2.29754969e+01-1.78710672e+01j,
        -1.92307775e+00-2.94975177e+01j, -3.11790029e+01-2.11839622e+01j,
         3.04358949e+01+6.36528460e+01j,  5.50489436e+00-1.22197283e+01j,
         4.22534702e+01-1.06789983e+01j, -7.06272713e+01-1.11875490e+01j,
         3.27265622e+01+2.80609377e+00j, -3.95286687e+01-9.60118722e+00j,
         5.75318857e+00-2.22803596e+00j, -4.14294443e+01-1.48474337e+01j,
         3.23407481e+01-6.68717454e+01j, -3.92473335e+01+2.68505554e+01j],
       [ 1.06523934e+01+1.73673192e+01j, -1.95164660e+01-7.43979407e+01j,
        -4.93971463e+01+2.09266660e+01j,  2.60177333e+01+1.53278026e+01j,
        -3.60650217e+01+6.05873460e-01j,  8.12464287e+00+2.22765043e+00j,
        -1.40264564e+01+4.29802397e+01j,  4.70004035e+01-1.22464039e+01j,
        -2.85868251e+01+3.59036353e+01j, -3.44036489e+01-3.06603442e+01j,
         4.30603867e+00+2.01927339e+00j, -1.20910217e+01-4.36106228e+01j,
        -3.22237081e+01+2.25641449e+00j,  2.88057312e+01+2.37735569e+00j,
         3.53326051e+01+1.81494418e+01j, -2.47154470e+00-2.07686708e+01j,
         2.58992505e+00+2.03285531e+01j, -2.42399929e+00+3.57250326e+01j,
         2.18422788e+01+3.21744430e+00j, -1.65841241e+01-2.38798773e+01j],
       [-1.07818296e+00-1.47849666e+01j,  4.47886848e+01+2.34594148e+01j,
         3.79211155e-01+1.61643017e+01j, -4.39314574e+01-2.09381347e+01j,
        -1.52437785e+01-8.43433973e+00j,  2.35262485e+01+4.98147526e+01j,
        -6.11206007e+00+2.25673610e+01j,  3.30809693e+01-9.34850620e+00j,
         1.71673780e+01-3.47696707e+01j,  3.68696602e+01+3.59515289e+01j,
         1.65210470e+01-7.33123761e+01j,  1.02898229e+01-1.29941840e+01j,
        -2.82417266e+01-3.39720714e+01j,  3.41384511e+00+2.09842327e+01j,
        -3.62093944e+01-8.93102919e+01j, -1.47845148e+01-2.05218191e+01j,
         4.05592205e+00-2.11454331e+01j,  3.89740324e+01-3.17500007e+01j,
         6.45552327e+00+2.69100506e+01j,  5.70284748e+01+3.43547254e+01j],
       [-5.58110611e+00+4.40670582e+01j, -2.94205956e+00-4.12300389e+01j,
        -2.31106044e+01-1.65055492e+00j,  4.56543207e+01-1.42979937e+01j,
        -2.17746984e+01+7.18592405e+01j, -4.78639712e+01+4.14072434e-01j,
         1.98169103e+00-7.22053259e+00j, -4.08850966e+01-2.60055911e+00j,
        -6.06693803e+00+2.07656749e+01j,  5.41040083e-01-1.81124148e+01j,
         1.80817697e+01-2.95532249e+01j, -2.25934944e+01+2.84674795e+01j,
         2.43658059e+01-2.55621553e+01j,  7.95868211e+00+5.65582314e+01j,
        -1.43962466e+01+2.65526852e+01j, -1.73257338e+01+5.30225228e+01j,
         4.85320648e+01+5.60596237e+00j, -3.19274861e+01+7.80041966e+00j,
        -2.34627949e+00-8.89046635e+00j,  1.54083249e+01+2.00649186e+01j],
       [ 1.18824392e+01-3.22445034e+01j, -1.90338418e+01+1.51946428e+01j,
        -5.37257684e+00+4.98413122e+01j, -9.94112937e+00-8.26233410e+01j,
        -2.64544431e+01+3.55722370e+01j, -8.81439084e-01-1.06270574e+01j,
        -2.69432497e+01-3.13403552e+00j, -1.79272987e+01-5.37861863e+01j,
        -1.16715093e+01+2.20421542e+01j,  2.45644090e+01+3.12855452e+01j,
         1.06994721e+01-5.91144258e+01j, -1.83299526e+01+1.41597367e+01j,
         3.02689172e+01-1.20605584e+00j, -1.71615097e+01-2.65530672e+01j,
         7.12788455e+00-1.01466482e+01j,  8.95293832e+00+3.02611311e+01j,
         4.82976884e+01-5.07935313e+00j,  1.56397075e+00-5.98568234e+00j,
        -1.69562981e+01+2.69981446e+01j, -1.63233034e+01+3.07002636e+00j],
       [-3.07316501e+01+3.93892519e+01j,  4.37522412e+01-2.58679396e+01j,
         8.14578399e+00+3.67631795e+01j, -3.66511012e+00-1.63464859e+01j,
        -2.58192580e+01-6.89101643e+00j,  4.91499643e+01+1.65418913e+01j,
        -5.77409216e+01+1.60540597e+01j, -6.73505251e+00+1.98416837e+00j,
         2.35079633e+01+7.50280198e+00j, -1.39586815e+01-1.93893701e+01j,
         3.33511180e+00+1.94216403e+01j,  6.37599026e+01-4.38710211e+00j,
         4.12779068e+00+2.93916104e+00j, -2.00550737e+01-9.79395414e+00j,
         2.26950448e+01+1.38349923e+01j,  1.54237181e+01-8.05481446e+00j,
        -4.53686973e+00+1.45217067e+01j, -5.63117259e+01+1.11153064e+01j,
        -1.81651373e+01+3.26587070e+01j, -8.70958377e-01+9.02082150e-01j],
       [-1.70526169e+00+1.92163372e+01j,  2.97034824e+01-2.79547749e+01j,
        -1.85369575e+01-2.35003882e+01j, -6.64633008e+00-4.38510142e+00j,
         4.97460634e+01-2.32829438e+01j, -4.05256849e+01-1.34379916e+01j,
        -2.21996880e+01-5.72145390e+01j,  7.13148018e+01+3.63742781e+01j,
        -5.86853908e+01-4.98184864e+00j,  1.30386761e+01+1.50867127e+01j,
        -1.79552477e+01+1.19034968e+00j,  3.70133743e+01+5.49322284e+01j,
        -1.89551153e+01-2.96675488e+00j,  1.69927163e+01-5.46139595e+00j,
        -2.67284300e+00-3.00440969e+01j, -2.74936090e+01+1.67932310e+01j,
        -4.84984905e+01+4.44450945e+00j, -3.25168875e+01+3.05116544e+01j,
         2.77952349e+01+7.37147443e+00j, -4.67295936e+01-1.68476993e+01j],
       [ 3.20962594e-01-5.06835211e+00j,  2.19888129e+00-3.84687654e+01j,
         6.29856157e+01+5.11739533e+00j, -1.24628564e+01+1.01651712e+01j,
        -1.55673493e+01+2.14876071e+01j, -2.42030910e+00+7.35438393e+01j,
         3.15126654e+01-1.06852728e+01j, -1.26190710e+01+5.65750088e+00j,
         4.85206624e+01-5.74968092e+01j, -3.06979577e+01-1.49209380e+01j,
        -5.81901559e+01-1.92046694e+01j,  9.83142621e+00+3.45841898e+00j,
         1.65440668e+01+1.20444372e+01j, -3.08074399e+01+1.70928994e+01j,
         2.41874283e+00+8.27550100e+00j, -5.74958635e+00+5.93517320e+01j,
        -2.22563818e+01+4.74525652e+01j,  2.22153223e+01-4.70607883e+01j,
        -1.80254890e+01+1.68658665e+01j, -3.79819554e+01-1.09610326e+01j],
       [-5.53260189e-01-3.33642332e+00j, -3.36865318e+01-5.67699005e+01j,
        -2.61418425e+01+6.74386221e+00j, -8.56095964e+00-8.15590602e+00j,
         9.83735030e+00-3.69410893e+00j,  3.95641923e+01-1.82508937e+01j,
         4.82363622e+01+6.80687760e+01j,  5.85350225e+00-1.55203019e+01j,
        -4.18423517e+01+7.67380731e+00j,  3.72751167e+00-4.04047009e+00j,
         3.52998209e+01-9.15896876e+00j, -5.08422850e+01+7.73216775e+00j,
        -5.75851523e+01-1.61377363e+01j,  7.72403168e+00-2.65696480e+01j,
         2.33187751e+00+1.53364881e+01j,  4.29016562e+01-2.77208110e+01j,
         2.40399719e+01+1.60354310e+01j,  3.99123661e+01-1.40791608e+01j,
        -7.79934151e+00+3.38929659e+01j,  5.17194527e+01+5.66418081e-01j],
       [-2.42445557e+00-1.52927059e+01j, -1.74865873e+01+3.95124060e+01j,
         1.50253414e+01+4.68022072e+01j,  4.83083325e+01+3.88306999e+01j,
        -1.93474045e+01+3.09792374e+01j, -9.14912144e+00-2.14527482e+00j,
        -1.67661069e+00-1.34034137e+01j,  1.10542525e+01-4.34099936e+00j,
         2.51257491e-01+4.18618670e+00j,  3.64910931e+00+3.90753262e-01j,
         4.15379418e+01+1.21990746e+00j, -2.57463428e+01+1.07618398e+01j,
        -7.84762169e+00+3.58774714e+01j,  2.23354935e+01-1.18006751e+01j,
         1.22580500e+01-3.25180329e+00j,  1.32792638e+01+8.14105169e+00j,
        -1.29989388e+01-9.99264531e+00j,  8.74145820e-01-2.16671479e+00j,
        -1.13623186e+01+1.46572477e+01j,  2.06068442e+01-4.91914400e+00j],
       [-5.24122435e+01-2.57484452e+01j,  7.88456072e+00+1.36192049e+01j,
        -4.69476119e+01-4.19065872e+01j, -2.51337731e+01+5.04668321e+01j,
        -5.27983284e+01-2.20977238e+01j,  2.83922223e+01-1.59345822e+01j,
         3.99972852e+00-1.14365015e+01j, -6.67169831e+01+6.45536117e+01j,
        -1.85524904e+01+2.25721542e+01j,  5.71189562e+01-2.12050702e+01j,
        -3.62001794e+01-9.38292577e+00j, -1.82433660e+01-5.44240126e+01j,
         2.37075183e+00-1.96054108e+01j, -3.85231231e+00+1.79861160e+01j,
        -2.25027517e+01+2.48013014e+01j,  4.26317210e+01-1.00091783e+01j,
        -1.69716555e+01-4.53089458e+00j, -2.56628360e+01+5.40797707e+01j,
        -7.58375000e+00+1.48726709e+01j,  1.49239103e+01+7.38038464e+00j],
       [ 1.40162448e+01-3.55271368e-15j, -1.71506677e+01+2.17743955e+01j,
         3.20915788e+01-4.21927434e+00j,  1.65585338e-02-9.93002000e+00j,
        -1.16510556e+01-1.77476509e+01j, -5.16221513e+01+9.35723183e+00j,
         2.25243755e+01-2.38435501e+01j,  4.77310092e+01+5.20077481e+01j,
         4.86248231e+01-1.74894997e+00j,  1.66786364e+01+1.33522786e+01j,
        -8.69681785e+00+3.55271368e-15j,  1.66786364e+01-1.33522786e+01j,
         4.86248231e+01+1.74894997e+00j,  4.77310092e+01-5.20077481e+01j,
         2.25243755e+01+2.38435501e+01j, -5.16221513e+01-9.35723183e+00j,
        -1.16510556e+01+1.77476509e+01j,  1.65585338e-02+9.93002000e+00j,
         3.20915788e+01+4.21927434e+00j, -1.71506677e+01-2.17743955e+01j],
       [-5.24122435e+01+2.57484452e+01j,  1.49239103e+01-7.38038464e+00j,
        -7.58375000e+00-1.48726709e+01j, -2.56628360e+01-5.40797707e+01j,
        -1.69716555e+01+4.53089458e+00j,  4.26317210e+01+1.00091783e+01j,
        -2.25027517e+01-2.48013014e+01j, -3.85231231e+00-1.79861160e+01j,
         2.37075183e+00+1.96054108e+01j, -1.82433660e+01+5.44240126e+01j,
        -3.62001794e+01+9.38292577e+00j,  5.71189562e+01+2.12050702e+01j,
        -1.85524904e+01-2.25721542e+01j, -6.67169831e+01-6.45536117e+01j,
         3.99972852e+00+1.14365015e+01j,  2.83922223e+01+1.59345822e+01j,
        -5.27983284e+01+2.20977238e+01j, -2.51337731e+01-5.04668321e+01j,
        -4.69476119e+01+4.19065872e+01j,  7.88456072e+00-1.36192049e+01j],
       [-2.42445557e+00+1.52927059e+01j,  2.06068442e+01+4.91914400e+00j,
        -1.13623186e+01-1.46572477e+01j,  8.74145820e-01+2.16671479e+00j,
        -1.29989388e+01+9.99264531e+00j,  1.32792638e+01-8.14105169e+00j,
         1.22580500e+01+3.25180329e+00j,  2.23354935e+01+1.18006751e+01j,
        -7.84762169e+00-3.58774714e+01j, -2.57463428e+01-1.07618398e+01j,
         4.15379418e+01-1.21990746e+00j,  3.64910931e+00-3.90753262e-01j,
         2.51257491e-01-4.18618670e+00j,  1.10542525e+01+4.34099936e+00j,
        -1.67661069e+00+1.34034137e+01j, -9.14912144e+00+2.14527482e+00j,
        -1.93474045e+01-3.09792374e+01j,  4.83083325e+01-3.88306999e+01j,
         1.50253414e+01-4.68022072e+01j, -1.74865873e+01-3.95124060e+01j],
       [-5.53260189e-01+3.33642332e+00j,  5.17194527e+01-5.66418081e-01j,
        -7.79934151e+00-3.38929659e+01j,  3.99123661e+01+1.40791608e+01j,
         2.40399719e+01-1.60354310e+01j,  4.29016562e+01+2.77208110e+01j,
         2.33187751e+00-1.53364881e+01j,  7.72403168e+00+2.65696480e+01j,
        -5.75851523e+01+1.61377363e+01j, -5.08422850e+01-7.73216775e+00j,
         3.52998209e+01+9.15896876e+00j,  3.72751167e+00+4.04047009e+00j,
        -4.18423517e+01-7.67380731e+00j,  5.85350225e+00+1.55203019e+01j,
         4.82363622e+01-6.80687760e+01j,  3.95641923e+01+1.82508937e+01j,
         9.83735030e+00+3.69410893e+00j, -8.56095964e+00+8.15590602e+00j,
        -2.61418425e+01-6.74386221e+00j, -3.36865318e+01+5.67699005e+01j],
       [ 3.20962594e-01+5.06835211e+00j, -3.79819554e+01+1.09610326e+01j,
        -1.80254890e+01-1.68658665e+01j,  2.22153223e+01+4.70607883e+01j,
        -2.22563818e+01-4.74525652e+01j, -5.74958635e+00-5.93517320e+01j,
         2.41874283e+00-8.27550100e+00j, -3.08074399e+01-1.70928994e+01j,
         1.65440668e+01-1.20444372e+01j,  9.83142621e+00-3.45841898e+00j,
        -5.81901559e+01+1.92046694e+01j, -3.06979577e+01+1.49209380e+01j,
         4.85206624e+01+5.74968092e+01j, -1.26190710e+01-5.65750088e+00j,
         3.15126654e+01+1.06852728e+01j, -2.42030910e+00-7.35438393e+01j,
        -1.55673493e+01-2.14876071e+01j, -1.24628564e+01-1.01651712e+01j,
         6.29856157e+01-5.11739533e+00j,  2.19888129e+00+3.84687654e+01j],
       [-1.70526169e+00-1.92163372e+01j, -4.67295936e+01+1.68476993e+01j,
         2.77952349e+01-7.37147443e+00j, -3.25168875e+01-3.05116544e+01j,
        -4.84984905e+01-4.44450945e+00j, -2.74936090e+01-1.67932310e+01j,
        -2.67284300e+00+3.00440969e+01j,  1.69927163e+01+5.46139595e+00j,
        -1.89551153e+01+2.96675488e+00j,  3.70133743e+01-5.49322284e+01j,
        -1.79552477e+01-1.19034968e+00j,  1.30386761e+01-1.50867127e+01j,
        -5.86853908e+01+4.98184864e+00j,  7.13148018e+01-3.63742781e+01j,
        -2.21996880e+01+5.72145390e+01j, -4.05256849e+01+1.34379916e+01j,
         4.97460634e+01+2.32829438e+01j, -6.64633008e+00+4.38510142e+00j,
        -1.85369575e+01+2.35003882e+01j,  2.97034824e+01+2.79547749e+01j],
       [-3.07316501e+01-3.93892519e+01j, -8.70958377e-01-9.02082150e-01j,
        -1.81651373e+01-3.26587070e+01j, -5.63117259e+01-1.11153064e+01j,
        -4.53686973e+00-1.45217067e+01j,  1.54237181e+01+8.05481446e+00j,
         2.26950448e+01-1.38349923e+01j, -2.00550737e+01+9.79395414e+00j,
         4.12779068e+00-2.93916104e+00j,  6.37599026e+01+4.38710211e+00j,
         3.33511180e+00-1.94216403e+01j, -1.39586815e+01+1.93893701e+01j,
         2.35079633e+01-7.50280198e+00j, -6.73505251e+00-1.98416837e+00j,
        -5.77409216e+01-1.60540597e+01j,  4.91499643e+01-1.65418913e+01j,
        -2.58192580e+01+6.89101643e+00j, -3.66511012e+00+1.63464859e+01j,
         8.14578399e+00-3.67631795e+01j,  4.37522412e+01+2.58679396e+01j],
       [ 1.18824392e+01+3.22445034e+01j, -1.63233034e+01-3.07002636e+00j,
        -1.69562981e+01-2.69981446e+01j,  1.56397075e+00+5.98568234e+00j,
         4.82976884e+01+5.07935313e+00j,  8.95293832e+00-3.02611311e+01j,
         7.12788455e+00+1.01466482e+01j, -1.71615097e+01+2.65530672e+01j,
         3.02689172e+01+1.20605584e+00j, -1.83299526e+01-1.41597367e+01j,
         1.06994721e+01+5.91144258e+01j,  2.45644090e+01-3.12855452e+01j,
        -1.16715093e+01-2.20421542e+01j, -1.79272987e+01+5.37861863e+01j,
        -2.69432497e+01+3.13403552e+00j, -8.81439084e-01+1.06270574e+01j,
        -2.64544431e+01-3.55722370e+01j, -9.94112937e+00+8.26233410e+01j,
        -5.37257684e+00-4.98413122e+01j, -1.90338418e+01-1.51946428e+01j],
       [-5.58110611e+00-4.40670582e+01j,  1.54083249e+01-2.00649186e+01j,
        -2.34627949e+00+8.89046635e+00j, -3.19274861e+01-7.80041966e+00j,
         4.85320648e+01-5.60596237e+00j, -1.73257338e+01-5.30225228e+01j,
        -1.43962466e+01-2.65526852e+01j,  7.95868211e+00-5.65582314e+01j,
         2.43658059e+01+2.55621553e+01j, -2.25934944e+01-2.84674795e+01j,
         1.80817697e+01+2.95532249e+01j,  5.41040083e-01+1.81124148e+01j,
        -6.06693803e+00-2.07656749e+01j, -4.08850966e+01+2.60055911e+00j,
         1.98169103e+00+7.22053259e+00j, -4.78639712e+01-4.14072434e-01j,
        -2.17746984e+01-7.18592405e+01j,  4.56543207e+01+1.42979937e+01j,
        -2.31106044e+01+1.65055492e+00j, -2.94205956e+00+4.12300389e+01j],
       [-1.07818296e+00+1.47849666e+01j,  5.70284748e+01-3.43547254e+01j,
         6.45552327e+00-2.69100506e+01j,  3.89740324e+01+3.17500007e+01j,
         4.05592205e+00+2.11454331e+01j, -1.47845148e+01+2.05218191e+01j,
        -3.62093944e+01+8.93102919e+01j,  3.41384511e+00-2.09842327e+01j,
        -2.82417266e+01+3.39720714e+01j,  1.02898229e+01+1.29941840e+01j,
         1.65210470e+01+7.33123761e+01j,  3.68696602e+01-3.59515289e+01j,
         1.71673780e+01+3.47696707e+01j,  3.30809693e+01+9.34850620e+00j,
        -6.11206007e+00-2.25673610e+01j,  2.35262485e+01-4.98147526e+01j,
        -1.52437785e+01+8.43433973e+00j, -4.39314574e+01+2.09381347e+01j,
         3.79211155e-01-1.61643017e+01j,  4.47886848e+01-2.34594148e+01j],
       [ 1.06523934e+01-1.73673192e+01j, -1.65841241e+01+2.38798773e+01j,
         2.18422788e+01-3.21744430e+00j, -2.42399929e+00-3.57250326e+01j,
         2.58992505e+00-2.03285531e+01j, -2.47154470e+00+2.07686708e+01j,
         3.53326051e+01-1.81494418e+01j,  2.88057312e+01-2.37735569e+00j,
        -3.22237081e+01-2.25641449e+00j, -1.20910217e+01+4.36106228e+01j,
         4.30603867e+00-2.01927339e+00j, -3.44036489e+01+3.06603442e+01j,
        -2.85868251e+01-3.59036353e+01j,  4.70004035e+01+1.22464039e+01j,
        -1.40264564e+01-4.29802397e+01j,  8.12464287e+00-2.22765043e+00j,
        -3.60650217e+01-6.05873460e-01j,  2.60177333e+01-1.53278026e+01j,
        -4.93971463e+01-2.09266660e+01j, -1.95164660e+01+7.43979407e+01j],
       [ 7.15150886e+00-1.25220177e+01j, -3.92473335e+01-2.68505554e+01j,
         3.23407481e+01+6.68717454e+01j, -4.14294443e+01+1.48474337e+01j,
         5.75318857e+00+2.22803596e+00j, -3.95286687e+01+9.60118722e+00j,
         3.27265622e+01-2.80609377e+00j, -7.06272713e+01+1.11875490e+01j,
         4.22534702e+01+1.06789983e+01j,  5.50489436e+00+1.22197283e+01j,
         3.04358949e+01-6.36528460e+01j, -3.11790029e+01+2.11839622e+01j,
        -1.92307775e+00+2.94975177e+01j, -2.29754969e+01+1.78710672e+01j,
        -7.49789987e+00-1.57377970e+01j,  4.94153737e+01+9.78063668e+00j,
         1.81568112e+01-1.23120934e+01j, -2.21190855e+01+4.34572687e-02j,
         2.35781124e+01+3.03692665e+01j, -1.64656200e+01+8.80436886e+00j],
       [-3.00756470e+01+2.02311653e+01j, -2.13363900e+01-1.58769170e+01j,
         2.03781124e+01+1.49895411e+01j,  3.10571817e+00-4.66607518e+01j,
        -1.80884532e+00+3.35852750e+01j, -2.36212076e+01-5.93467176e+01j,
         1.17154656e+01+3.47452516e+01j, -1.10414273e+01+7.78928074e+00j,
         4.52215055e+01+3.12928417e+01j,  1.44147644e+01-2.88680317e+01j,
        -5.02314992e+01+1.11478363e+01j,  3.91626381e+00+1.85662042e+00j,
         1.62248018e+01-4.73648432e+00j, -2.16237997e+01+1.94507161e+01j,
        -2.30835820e+01-2.65438675e+01j,  1.26375702e+00-5.25047677e+00j,
         2.05435690e+00-1.04214009e+01j,  3.95568373e+01+8.28074518e+00j,
         4.71762598e+01+8.72739590e+00j, -1.52199079e+01-6.12960304e+01j],
       [ 1.18390109e+01-1.69615481e+01j,  2.23641363e+01+2.98647685e-02j,
         8.93965329e+00-1.28033963e+01j, -6.17481319e+00-1.43282178e+01j,
         5.18844566e+01+3.92437600e+01j,  1.49904457e+01-1.62863784e+00j,
        -3.63069591e+01-2.63605337e+01j,  2.27092738e+01-1.09230345e+01j,
        -5.77461281e+00+2.23819916e+01j,  4.48110583e+01-2.09499730e+00j,
        -2.91364141e+01+4.57237154e+01j,  2.60820207e+01+1.08850196e+01j,
        -2.41167969e+01-8.25647322e+00j,  6.89571773e+00+7.65203935e+00j,
         1.99909029e+01+2.37322857e+01j, -7.38998869e+00-5.92937093e+00j,
        -3.26843493e+01-2.78910788e+01j,  1.51573868e+01-8.87107641e-02j,
         3.48168720e+00-3.93232365e+01j, -1.03891185e+01-3.07147965e+01j],
       [-9.78304942e+00+2.00060691e+01j,  1.28963968e+01+3.01513717e+01j,
        -3.75456761e+00-6.28466305e+01j, -2.64074189e+01+1.52314832e+01j,
         1.20560230e+00-2.45535230e+01j,  2.29408613e+00+2.10730557e+01j,
        -2.24569277e+01-4.78807494e+00j,  5.89818080e+01+1.58963695e+00j,
        -3.39807068e+01-9.65027977e+00j,  1.07657876e+01+1.41656999e+01j,
        -4.84907294e+01+4.16601947e+01j,  1.23190320e+01-1.63252604e+01j,
        -3.41801537e+01-4.29905149e+01j, -7.66929151e+00+4.16255367e+00j,
        -1.90295095e+01-5.25959400e+01j, -2.48612360e+01+1.19071034e+01j,
         5.75308280e+00-2.73910712e+01j, -1.65402379e+01-5.18006959e+00j,
         3.65704485e+01-2.64031486e+01j, -3.01214418e+01+6.86851691e-01j]])
Coordinates:
  * x        (x) float64 0.0 0.1933 0.3867 0.58 ... -0.58 -0.3867 -0.1933
  * y        (y) float64 0.0 0.19 0.38 0.57 0.76 ... -0.76 -0.57 -0.38 -0.19
In [14]: plt.figure(figsize=(10, 4))
Out[14]: <Figure size 1000x400 with 0 Axes>

In [15]: plt.subplot(1, 2, 1)
Out[15]: <matplotlib.axes._subplots.AxesSubplot at 0x7fdc2221a8d0>

In [16]: arr.plot()
Out[16]: <matplotlib.collections.QuadMesh at 0x7fdc2215ac50>

In [17]: plt.subplot(1, 2, 2)
Out[17]: <matplotlib.axes._subplots.AxesSubplot at 0x7fdc2215afd0>

In [18]: np.abs(fftn.sortby('x').sortby('y')).plot()
Out[18]: <matplotlib.collections.QuadMesh at 0x7fdc22104650>

In [19]: plt.show()
_images/fftn.png