def GenerateTwoScreens(nfft, r0):
    """

      Generate phase screens with a Kolmogorov spectrum of atmospheric
      disturbances [c.f. Tatarski 1961,1971], such that the phase structure
      function is given by

           D(r) = <[phi(r')-phi(r'+r)]**2>
                = 6.88*(r/r0)**5/3

       where r0 is the Fried parameter.

       This version returns two screens, because it's easier to do it that
       way.
    """
    C = sqrt(0.0229*(float(nfft)/r0)**(5.0/3.0))
    # Generate a 2-d array populated with rsquared=xsquared+ysquared
    r = arange(nfft)
    r[nfft/2:] = nfft-r[nfft/2:]
    rsq = r**2
    rsq = add.outer(rsq,rsq)
    rsq[0, 0] = 1.0 # To solve pole at origin problem
    sample = random.normal(size=(nfft, nfft))+1j*random.normal(size=(nfft, nfft))
    sample *= C*rsq**(-11.0/12.0)
    result = fft.fft2(sample)
    return(result.real, result.imag)
def GenerateTwoScreens ( nfft , r0 ) : C = sqrt ( 0.0229 * ( float ( nfft ) / r0 ) ** ( 5.0 / 3.0 ) ) r = arange ( nfft ) r [ nfft / 2 : ] = nfft - r [ nfft / 2 : ] rsq = r ** 2 rsq = add . outer ( rsq , rsq ) rsq [ 0 , 0 ] = 1.0 sample = random . normal ( size = ( nfft , nfft ) ) + 1j * random . normal ( size = ( nfft , nfft ) ) sample *= C * rsq ** ( - 11.0 / 12.0 ) result = fft . fft2 ( sample ) return ( result . real , result . imag )
Generate phase screens with a Kolmogorov spectrum of atmospheric
      disturbances [c.f. Tatarski 1961,1971], such that the phase structure
      function is given by

           D(r) = <[phi(r')-phi(r'+r)]**2>
                = 6.88*(r/r0)**5/3

       where r0 is the Fried parameter.

       This version returns two screens, because it's easier to do it that
       way.