Skip to content
Snippets Groups Projects
Commit 2fecc0f6 authored by Daniel Brown's avatar Daniel Brown
Browse files

can now do kat.m1.n1.q = 1+100j and it converts it correctly into a gaussian beam parameter object

parent de03e236
Branches
No related tags found
No related merge requests found
...@@ -32,21 +32,21 @@ class NodeGaussSetter(object): ...@@ -32,21 +32,21 @@ class NodeGaussSetter(object):
@q.setter @q.setter
def q(self, value): def q(self, value):
self.__node.setGauss(self.__comp, value) self.__node.setGauss(self.__comp, complex(value))
@property @property
def qx(self): def qx(self):
return self.__node.qx return self.__node.qx
@qx.setter @qx.setter
def qx(self, value): def qx(self, value):
self.__node.setGauss(self.__comp, value) self.__node.setGauss(self.__comp, complex(value))
@property @property
def qy(self): def qy(self):
return self.__node.qy return self.__node.qy
@qy.setter @qy.setter
def qy(self, value): def qy(self, value):
self.__node.setGauss(self.__comp, self.qx, value) self.__node.setGauss(self.__comp, self.qx, complex(value))
class Component(object) : class Component(object) :
def __init__(self, name): def __init__(self, name):
......
...@@ -9,6 +9,7 @@ import pykat.gui.graphics ...@@ -9,6 +9,7 @@ import pykat.gui.graphics
import pykat.exceptions as pkex import pykat.exceptions as pkex
from pykat.components import Component from pykat.components import Component
from pykat.detectors import Detector from pykat.detectors import Detector
from pykat.utilities.optics.gaussian_beams import gauss_param
class NodeNetwork(object): class NodeNetwork(object):
def __init__(self, kat): def __init__(self, kat):
...@@ -241,11 +242,11 @@ class Node(object): ...@@ -241,11 +242,11 @@ class Node(object):
self.__q_comp = component self.__q_comp = component
if len(args) == 1: if len(args) == 1:
self.__q_x = args[0] self.__q_x = gauss_param(q=args[0])
self.__q_y = args[0] self.__q_y = gauss_param(q=args[0])
elif len(args) == 2: elif len(args) == 2:
self.__q_x = args[0] self.__q_x = gauss_param(q=args[0])
self.__q_y = args[1] self.__q_y = gauss_param(q=args[1])
else: else:
raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams") raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams")
......
...@@ -14,6 +14,7 @@ class gauss_param(object): ...@@ -14,6 +14,7 @@ class gauss_param(object):
q = gauss_param(w0=w0, z=z) q = gauss_param(w0=w0, z=z)
q = gauss_param(z=z, zr=zr) q = gauss_param(z=z, zr=zr)
q = gauss_param(wz=wz, rc=rc) 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: or change default wavelength and refractive index with:
...@@ -27,6 +28,13 @@ class gauss_param(object): ...@@ -27,6 +28,13 @@ class gauss_param(object):
if len(args) == 1: if len(args) == 1:
self.__q = args[0] 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: elif len(kwargs) == 2:
if "w0" in kwargs and "z" in kwargs: if "w0" in kwargs and "z" in kwargs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment