diff --git a/pykat/components.py b/pykat/components.py index f4ed356940f8e8306ec71c540fe8e4911f15fe31..2b3b9b69eec86b7601d974f7e60f458be9f6af1a 100644 --- a/pykat/components.py +++ b/pykat/components.py @@ -32,21 +32,21 @@ class NodeGaussSetter(object): @q.setter def q(self, value): - self.__node.setGauss(self.__comp, value) + self.__node.setGauss(self.__comp, complex(value)) @property def qx(self): return self.__node.qx @qx.setter def qx(self, value): - self.__node.setGauss(self.__comp, value) + self.__node.setGauss(self.__comp, complex(value)) @property def qy(self): return self.__node.qy @qy.setter def qy(self, value): - self.__node.setGauss(self.__comp, self.qx, value) + self.__node.setGauss(self.__comp, self.qx, complex(value)) class Component(object) : def __init__(self, name): diff --git a/pykat/node_network.py b/pykat/node_network.py index 0e915d767d76a6998a07f1bce096b025a2704ef9..8c6a50addaec89f7423f56b616a853a12c9534e9 100644 --- a/pykat/node_network.py +++ b/pykat/node_network.py @@ -9,6 +9,7 @@ import pykat.gui.graphics import pykat.exceptions as pkex from pykat.components import Component from pykat.detectors import Detector +from pykat.utilities.optics.gaussian_beams import gauss_param class NodeNetwork(object): def __init__(self, kat): @@ -241,11 +242,11 @@ class Node(object): self.__q_comp = component if len(args) == 1: - self.__q_x = args[0] - self.__q_y = args[0] + self.__q_x = gauss_param(q=args[0]) + self.__q_y = gauss_param(q=args[0]) elif len(args) == 2: - self.__q_x = args[0] - self.__q_y = args[1] + self.__q_x = gauss_param(q=args[0]) + self.__q_y = gauss_param(q=args[1]) else: raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams") diff --git a/pykat/utilities/optics/gaussian_beams.py b/pykat/utilities/optics/gaussian_beams.py index 568dbd5f29c2ac18faaafc371ae22acad4940104..f5efa4cc1422a211ec25424c146f7e0d7744bbf6 100644 --- a/pykat/utilities/optics/gaussian_beams.py +++ b/pykat/utilities/optics/gaussian_beams.py @@ -14,6 +14,7 @@ class gauss_param(object): q = gauss_param(w0=w0, z=z) q = gauss_param(z=z, zr=zr) q = gauss_param(wz=wz, rc=rc) + q = gauss_param(q=a) # where a is a complex number or change default wavelength and refractive index with: @@ -27,6 +28,13 @@ class gauss_param(object): if len(args) == 1: self.__q = args[0] + + elif len(kwargs) == 1: + if "q" in kwargs: + self.__q = complex(kwargs["q"]) + else: + raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and wz, to define the beam parameter") + elif len(kwargs) == 2: if "w0" in kwargs and "z" in kwargs: