0
$\begingroup$

I have a 2D Gaussian beam :

2D gaussian distribution

After doing FFT2 and angle I get strange results: fft2 angle

This is the code I'm using (Python 3)

import scipy.fftpack as fftpack
import numpy as np
import matplotlib.pyplot as plt

def finite2D(x,y, N, M, a, hx):
    f = np.array([[0.0]*N]*N)
    for i in range(len(x)):
        for k in range(len(y)):
            f[i][k] = np.exp(-(x[i]*x[i] + y[k]*y[k]))

    D1 = fftpack.fft2(f)
    D2 = fftpack.fftshift(D1)

    b = N*N/(4*a*M)
    x = np.linspace(-b, b, N)
    y = np.linspace(-b, b, N)
    xx, yy = np.meshgrid(x, y)
    plt.imshow(np.abs(D2))
    plt.show()

    plt.imshow(np.angle(D2))
    plt.show(True)
    return D2

a = 5
N = 128
M = 256
b = N*N/(4*a*M)
hx = 2*a/N
x = np.linspace(-a, a, N)
y = np.linspace(-a, a, N)
finite2D(x,y, N, M, a, hx)

I think the calculated phase should be 0 or close to 0.

$\endgroup$
  • $\begingroup$ Have you unwrapped the phase? $\endgroup$ – A_A Apr 8 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.