<p>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. </p>

<p>My "working" prototype is simply write my own matrix DFT:</p>



<pre><code>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) &lt;= 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
</code></pre>

<p>and to calculate the PSF by</p>



<pre><code>M=25
W = DFT_matrix(numPixel, M)
dft_of_pupil = W.dot(pupilMask).dot(W)
</code></pre>

<p>Is this a solution or have I missed something?</p>

CC BY-SA 4.0
2019-08-16T21:19:09.143Z
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...
WDC
CC BY-SA 4.0
2019-08-17T06:06:05.333Z
This is an excellent question for [Scientific Computing SE](https://scicomp.stackexchange.com/questions) 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.
uhoh
<optics>
PSF magnification
voidedbowel
# PSF magnification

(Asked by: username_0 on 2019-08-16)

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
M=25
W = DFT_matrix(numPixel, M)
dft_of_pupil = W.dot(pupilMask).dot(W)

Is this a solution or have I missed something?

**Tags:** optics
> **Comments:**
> **username_1**: 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...  
> **username_2**: This is an excellent question for [Scientific Computing SE](https://scicomp.stackexchange.com/questions) 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.  

---

## 0 answers

