def value(self, x, y, z): """ Value of complex amplitude at coordinates (x,y,z). (x,y,z) is a cartesian coordinate frame centered at the waist. z lies along the propagation axis. ========Input========= x : Radial horizontal distance from z axis y : Radial vertical distance from z axis z : Axial distance from waist ========Output======== u : Complex amplitude of beam at coordinates (x,y,z) """ q = self.q(z) W = self.width(z) env = 1j * self.zO * self.A * tl.exp(-0.5j * self.k * (x**2 + y**2) / q) / q env *= tl.eval_hermite(self.l, tl.sqrt(2) * x / W) * tl.eval_hermite( self.m, tl.sqrt(2) * y / W) * tl.exp( 1j * (self.l + self.m) * self.gouy_phase(z)) u = env * tl.exp(-1j * self.k * z) return u
def profile(self, z, f, dx=1.): """ Beam's complex amplitude at an axial distance z from waist. Plane lies perpendicular to z axis and has the same shape as f. ========Input========= z : Axial distance from waist f : 2D Array defining the output array shape dx : Pixel pitch (default value is unit of measurement) ========Raises======== TypeError: If f isn't a 2D array ========Output======== g : 2D complex array (complex amplitude at an axial distance z from waist centered at z axis) """ if (len(tl.shape(f)) != 2): raise TypeError('f must be a 2D array') n, m = tl.shape(f) x = tl.arange(-m * dx / 2, m * dx / 2, dx) y = tl.arange(-n * dx / 2, n * dx / 2, dx) X, Y = tl.meshgrid(x, y) R = tl.sqrt(X**2 + Y**2) g = self.value(R, z) return g
def QuadNormal(f, N=1., dx=1., dy=None): """ ~ Linearly normalizes f quadrature to N ========Input========= f : Input 2D array N : New quadrature value dx : Horizontal sampling interval (default value is unit of measurement) dy : Vertical sampling interval (default value for square sampling) ========Output======== g : Normalized input array """ if (dy == None): dy = dx P = Power(f, dx, dy) g = tl.sqrt(N / P) * f return g
def __init__(self, AO, WLO, bO, m): # These parameters define the units of measurement self.A = complex(AO) # Amplitude self.WL = float(WLO) # Central wavelength self.k = 2 * tl.pi / WLO # Central wave number self.b = bO # Axial wave number self.kT = tl.sqrt(self.k**2 - self.b**2) # Transverse wave number self.m = int(m) # Spin eigenvalue
def __init__(self, AO, WO, WLO, bO): # These parameters define the units of measurement self.A = complex(AO) # Amplitude self.W = float(WO) # Waist radius self.WL = float(WLO) # Central wavelength self.k = 2 * tl.pi / WLO # Central wave number self.b = bO # Axial wave number self.kT = tl.sqrt(self.k**2 - self.b**2) # Transverse wave number self.zO = tl.pi * WO**2 / WLO # Rayleight range
def __init__(self, AO, WLO, kxO=0, kyO=0): # These parameters define the units of measurement """ Plane wave with wavevector (2*pi/WLO)*[sqrt(kxO),sqrt(kyO),sqrt(1 - abs(kxO) - abs(kyO))] Default values for a plane wave propagating in the z axis. If |kxO| + |kyO| > 1 the wave is evanescent. """ self.A = complex(AO) # Amplitude self.WL = float(WLO) # Central wavelenght self.k = 2 * tl.pi / WLO # Central wavenumber self.kx = float(kxO) * self.k # x wavevector component self.ky = float(kyO) * self.k # y wavevector component self.kz = tl.sqrt(self.k**2 - self.kx**2 - self.ky**2) # z wavevector component
def CC(f, g): """ ~ Calculates correlation coefficient between two arrays ~ Works similar to corr2 MATLAB function ========input========= f : Input array 1 g : Input array 2 ========output======== cc : Correlation coefficient """ f = tl.array(f) g = tl.array(g) cr = tl.summ(abs((f - tl.mean(f)) * (g - tl.mean(g)))) cc = cr / tl.sqrt( (tl.summ(abs(f - tl.mean(f))**2)) * (tl.summ(abs(g - tl.mean(g))**2))) return cc
def width(self, z): # Width at axial distance z from waist return self.W * tl.sqrt(1 + (z / self.zO)**2)