diff --git a/pykat/utilities/maps.py b/pykat/utilities/maps.py index 22641cde471fbfd845110c58f22724a6803253b3..397cfe0772b5494a9427bd0fadaef7b7a207ba0e 100644 --- a/pykat/utilities/maps.py +++ b/pykat/utilities/maps.py @@ -56,11 +56,24 @@ class surfacemap(object): def ROMWeights(self): return self._rom_weights - def z_xy(self, wavelength=1064e-9): - - if "phase" in self.type: - k = math.pi * 2 / wavelength - return np.exp(2j * k * self.scaling * self.data) + def z_xy(self, wavelength=1064e-9, direction="reflection", nr1=1.0, nr2=1.0): + + if direction == "reflection": + if "phase" in self.type: + k = math.pi * 2 / wavelength + return np.exp(2j * k * self.scaling * self.data) + elif "absorption" in self.type: + return np.sqrt(1.0 - self.scaling * self.data) + else: + raise BasePyKatException("Map type needs handling") + elif direction == "transmission": + if "phase" in self.type: + k = math.pi * 2 / wavelength + return np.exp((nr1-nr2)*k * self.scaling * self.data) + elif "absorption" in self.type: + return np.sqrt(1.0 - self.scaling * self.data) + else: + raise BasePyKatException("Map type needs handling") else: raise BasePyKatException("Map type needs handling") @@ -143,12 +156,52 @@ class surfacemap(object): pylab.show() return fig - + +class aperturemap(surfacemap): + + def __init__(self, name, size, step_size, R): + surfacemap.__init__(self, name, "absorption both", size, (np.array(size)+1)/2.0, step_size, 1) + self.R = R + + @property + def R(self): + return self.__R + + @R.setter + def R(self, value): + self.__R = value + + xx, yy = np.meshgrid(self.x, self.y) + + radius = np.sqrt(xx**2 + yy**2) + + self.data = np.zeros(self.size) + self.data[radius > self.R] = 1.0 + + +class curvedmap(surfacemap): + + def __init__(self, name, size, step_size, Rc): + surfacemap.__init__(self, name, "phase reflection", size, (np.array(size)+1)/2.0, step_size, 1e-6) + self.Rc = Rc + + @property + def Rc(self): + return self.__Rc + + @Rc.setter + def Rc(self, value): + self.__Rc = value + + xx, yy = np.meshgrid(self.x, self.y) + + Rsq = xx**2 + yy**2 + self.data = (self.Rc - math.copysign(1.0, self.Rc) * np.sqrt(self.Rc**2 - Rsq))/ self.scaling class tiltmap(surfacemap): def __init__(self, name, size, step_size, tilt): - surfacemap.__init__(self, name, "phase", size, (np.array(size)+1)/2.0, step_size, 1) + surfacemap.__init__(self, name, "phase", size, (np.array(size)+1)/2.0, step_size, 1e-9) self.tilt = tilt @property @@ -161,7 +214,7 @@ class tiltmap(surfacemap): xx, yy = np.meshgrid(self.x, self.y) - self.data = xx * self.tilt[1] + yy * self.tilt[0] + self.data = (xx * self.tilt[1] + yy * self.tilt[0])/self.scaling diff --git a/pykat/utilities/optics/gaussian_beams.py b/pykat/utilities/optics/gaussian_beams.py index cd1f554349b352a682df73336048b734f9693f81..0ff65548a2db0b5be2eff7b40c2575b895e3ebf6 100644 --- a/pykat/utilities/optics/gaussian_beams.py +++ b/pykat/utilities/optics/gaussian_beams.py @@ -140,7 +140,7 @@ class gauss_param(object): @property def Rc(self): if self.__q.real != 0: - return abs(self.__q) / self.__q.real + return self.z * (1 + (self.zr/self.z)**2) else: return float("inf")