Commit f50824db authored by Daniel Brown's avatar Daniel Brown
Browse files

adding lambda default wavelength property, also fixing q factor computations...

adding lambda default wavelength property, also fixing q factor computations that need to link to this value
parent 17b2b0f3
......@@ -61,6 +61,8 @@ class cavity(Command):
class gauss(object):
@staticmethod
def parseFinesseText(text, kat):
print "parsing gauss", kat.lambda0
values = text.split()
if not values[0].startswith("gauss") or (len(values) != 6 and len(values) != 8):
raise pkex.BasePyKatException("'{0}' not a valid Finesse gauss command".format(text))
......@@ -69,24 +71,24 @@ class gauss(object):
component = values[2]
node = values[3]
if values[0]:
if not values[0].endswith("*"):
if len(values) == 6:
gp = gauss_param(w0=values[-2], z=values[-1])
gp = gauss_param(kat.lambda0, w0=values[-2], z=values[-1])
elif len(values) == 8:
gpx = gauss_param(w0=values[-4], z=values[-3])
gpy = gauss_param(w0=values[-2], z=values[-1])
gpx = gauss_param(kat.lambda0, w0=values[-4], z=values[-3])
gpy = gauss_param(kat.lambda0, w0=values[-2], z=values[-1])
elif values[0].endswith("*"):
if len(values) == 6:
gp = gauss_param(z=values[-2], zr=values[-1])
gp = gauss_param(kat.lambda0, z=values[-2], zr=values[-1])
elif len(values) == 8:
gpx = gauss_param(z=values[-4], zr=values[-3])
gpy = gauss_param(z=values[-2], zr=values[-1])
gpx = gauss_param(kat.lambda0, z=values[-4], zr=values[-3])
gpy = gauss_param(kat.lambda0, z=values[-2], zr=values[-1])
elif values[0].endswith("**"):
if len(values) == 6:
gp = gauss_param(w=values[-2], rc=values[-1])
gp = gauss_param(kat.lambda0, w=values[-2], rc=values[-1])
elif len(values) == 8:
gpx = gauss_param(w=values[-4], rc=values[-3])
gpy = gauss_param(w=values[-2], rc=values[-1])
gpx = gauss_param(kat.lambda0, w=values[-4], rc=values[-3])
gpy = gauss_param(kat.lambda0, w=values[-2], rc=values[-1])
else:
raise pkex.BasePyKatException("Unexpected ending to gauss command '{0}'".format(text))
......
......@@ -390,6 +390,7 @@ class kat(object):
self.__noxaxis = None
self.__time_code = None
self.__yaxis = "abs" # default yaxis
self.__lambda0 = 1064e-9
if kat_code != None and kat_file != None:
raise pkex.BasePyKatException("Specify either a Kat file or some Kat code, not both.")
......@@ -428,6 +429,16 @@ class kat(object):
else:
self.__trace = value
@property
def lambda0(self): return self.__lambda0
@lambda0.setter
def lambda0(self, value):
self.__lambda0 = SIfloat(value)
for node in self.nodes.getNodes():
if self.nodes[node].q != None:
self.nodes[node].q.wavelength = self.__lambda0
@property
def maxtem(self): return self.__maxtem
@maxtem.setter
......@@ -610,6 +621,9 @@ class kat(object):
after_process.append(line)
elif(first == "noxaxis"):
self.noxaxis = True
elif(first == "lambda"):
v = line.split()
self.lambda0 = SIfloat(v[-1])
elif(first == "yaxis"):
v = line.split()
......
......@@ -22,6 +22,9 @@ class NodeNetwork(object):
cls = type(self)
self.__class__ = type(cls.__name__, (cls,), {})
@property
def kat(self): return self.__kat
def registerComponentNodes(self, comp, node_names, change_callback):
"""
......@@ -273,11 +276,11 @@ class Node(object):
self.__q_comp = component
if len(args) == 1:
self.__q_x = gauss_param(q=args[0])
self.__q_y = gauss_param(q=args[0])
self.__q_x = gauss_param(self._network.kat.lambda0, q=args[0])
self.__q_y = gauss_param(self._network.kat.lambda0, q=args[0])
elif len(args) == 2:
self.__q_x = gauss_param(q=args[0])
self.__q_y = gauss_param(q=args[1])
self.__q_x = gauss_param(self._network.kat.lambda0, q=args[0])
self.__q_y = gauss_param(self._network.kat.lambda0, q=args[1])
else:
raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams")
......
......@@ -25,8 +25,9 @@ class gauss_param(object):
def __init__(self, wavelength=1064e-9, nr=1, *args, **kwargs):
self.__q = None
self.__lambda = float(wavelength)
self.__nr = float(nr)
print "wavelength", wavelength, kwargs
self.__lambda = SIfloat(wavelength)
self.__nr = SIfloat(nr)
if len(args) == 1:
self.__q = complex(args[0])
......@@ -55,6 +56,8 @@ class gauss_param(object):
@property
def wavelength(self): return self.__lambda
@wavelength.setter
def wavelength(self,value): self.__lambda = SIfloat(value)
@property
def nr(self): return self.__nr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment