I have a circular telescope pupil, a magnifying optic, and a detector. I am trying to calculate the point spread function as a function of wavelength. I am running into the issue that Python's 2D FFT or matrix DFT declare their own spatial frequencies. Is there an obvious way to set my own spatial frequencies.

My "working" prototype is simply write my own matrix DFT:

numPixels = 1024 
pupilCenter     = numPixels / 2 
W, H            = np.meshgrid(np.arange(0, numPixels), np.arange(0, numPixels))
pupilMask       = np.sqrt((W - pupilCenter)**2 + (H - pupilCenter)**2) <= numPixels/2

def DFT_matrix(N, M):
    """Calculate dft matrix
    N : number of pixels
    M : magnification factor"""

    i, j = np.meshgrid(np.arange(N)-N/2, np.arange(N)-N/2)
    omega = np.exp( - 2 * np.pi * 1.J / N / M )
    W = np.power( omega, i * j ) / np.sqrt(N)
    return W

and to calculate the PSF by

W = DFT_matrix(numPixel, M)
dft_of_pupil = W.dot(pupilMask).dot(W)

Is this a solution or have I missed something?

  • 1
    $\begingroup$ Let $p$ be the pupil function, then $h = |FFT(p)|^2$ gives you the incoherent PSF right? You only need to scale the coordinates (i.e. to suit your own spatial frequencies). What you present here is a re-implementation of DFT but using matrix-vector multiplication... I do not see any difference compared to FFT, except the possibility that the computing speed is slower... $\endgroup$ – WDC Aug 16 '19 at 21:19
  • $\begingroup$ This is an excellent question for Scientific Computing SE and not a very good question for this site. I'd recommend you post this in SciComp. After that you should delete here since cross-posting is discouraged. $\endgroup$ – uhoh Aug 17 '19 at 6:06

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.