Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ft():
data = numpy.random.random((100))
ft_data = fouriertransform.ft(data, 0.1)
assert ft_data.shape == data.shape
def test_rft():
data = numpy.zeros((100))
data_width = len(data)
rft_data = fouriertransform.rft(data, 1.)
width, = rft_data.shape
rescaled_width = (width-1)*2
assert rescaled_width == data_width
#Observation Plane Co-ords
x2,y2 = numpy.meshgrid( outputSpacing*numpy.arange(-N/2,N/2),
outputSpacing*numpy.arange(-N/2,N/2) )
r2sq = x2**2 + y2**2
#Quadratic phase factors
Q1 = numpy.exp( 1j * k/2. * (1-mag)/z * r1sq)
Q2 = numpy.exp(-1j * numpy.pi**2 * 2 * z/mag/k*fsq)
Q3 = numpy.exp(1j * k/2. * (mag-1)/(mag*z) * r2sq)
#Compute propagated field
outputComplexAmp = Q3 * fouriertransform.ift2(
Q2 * fouriertransform.ft2(Q1 * inputComplexAmp/mag,inputSpacing), df1)
return outputComplexAmp
#Evaluate Fresnel-Kirchhoff integral
A = 1./(1j * wvl * Dz1)
B = numpy.exp(1j * k/(2*Dz1) * (x1a**2 + y1a**2) )
C = fouriertransform.ft2(Uin * numpy.exp(1j * k/(2*Dz1) * (x1**2 + y1**2)), d1)
Uitm = A*B*C
#Observation plane
Dz2 = z - Dz1
#coordinates
x2,y2 = numpy.meshgrid( numpy.arange(-N/2., N/2.) * d2,
numpy.arange(-N/2., N/2.) * d2 )
#Evaluate the Fresnel diffraction integral
A = 1. / (1j * wvl * Dz2)
B = numpy.exp( 1j * k/(2 * Dz2) * (x2**2 + y2**2) )
C = fouriertransform.ft2(Uitm * numpy.exp( 1j * k/(2*Dz2) * (x1a**2 + y1a**2)), d1a)
Uout = A*B*C
return Uout