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

fixing gauss param naming

parent bc77f025
......@@ -61,7 +61,6 @@ class cavity(Command):
class gauss(object):
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):
......@@ -71,6 +70,21 @@ class gauss(object):
component = values[2]
node = values[3]
# setting the name of the gauss parameter is slightly convoluted
# as we don't explicitly store gauss paramters as an object, they
# are simply just complex numbers stored at each node. To fix this
# the name is stored in the NodeGaussSetter object for each component
if component in kat.components:
c = kat.components[component]
if hasattr(c, node):
ns = getattr(c, node) = name
raise pkex.BasePyKatException("Component '{0}' is not attached to node {1}".format(component, node))
raise pkex.BasePyKatException("Component '{0}' was not found".format(component))
if not values[0].endswith("*"):
if len(values) == 6:
gp = beam_param(kat.lambda0, w0=values[-2], z=values[-1])
......@@ -25,6 +25,15 @@ class NodeGaussSetter(object):
def __init__(self, component, node):
self.__comp = weakref.ref(component)
self.__node = weakref.ref(node)
self.__name = None
def name(self):
return self.__name
def name(self, value):
self.__name = str(value)
def node(self):
......@@ -433,13 +433,27 @@ class Node(object):
return []
rtn = []
# to get the name of the gauss parameter is a bit convoluted...
# firstly the name is set in the NodeGaussSetter object which is
# connected to each component, so this has to be retrieved and
# then applied.
if hasattr(self.__q_comp,
ns = getattr(self.__q_comp,
# if no name is present give it a default one
if != None:
name =
name = "g_%s" %
raise pkex.BasePyKatException("Node {0} is not connected to {1}".format(,
if self.__q_x == self.__q_y:
rtn.append("gauss g_{node} {comp} {node} {w0:.15g} {z:.15g}".format(,, w0=self.__q_x.w0, z=self.__q_x.z))
#rtn.append("gauss* g_{node} {comp} {node} {z} {zr}".format(,, z=self.__q_x.real, zr=self.__q_x.imag))
rtn.append("gauss {name} {comp} {node} {w0:.15g} {z:.15g}".format(name=name,,, w0=self.__q_x.w0, z=self.__q_x.z))
rtn.append("gauss g_{node} {comp} {node} {w0x:.15g} {zx:.15g} {w0y:.15g} {zy:.15g}".format(,, w0x=self.__q_x.w0, zx=self.__q_x.z, w0y=self.__q_y.w0, zy=self.__q_y.z))
#rtn.append("gauss* g_{node} {comp} {node} {zx} {zrx} {zy} {zry}".format(,, zx=self.__q_x.real, zrx=self.__q_x.imag, zy=self.__q_y.real, zry=self.__q_y.imag))
rtn.append("gauss {name} {comp} {node} {w0x:.15g} {zx:.15g} {w0y:.15g} {zy:.15g}".format(name=name,,, w0x=self.__q_x.w0, zx=self.__q_x.z, w0y=self.__q_y.w0, zy=self.__q_y.z))
return rtn
......@@ -29,12 +29,20 @@ class surfacemap:
mapfile.write("%.15g " %[i,j])
def x(self):
return self.step_size[0] * (numpy.array(range(0,[0]))-[0])
def y(self):
return self.step_size[1] * (numpy.array(range(0,[1]))-[1])
def plot(self, show=True, clabel=None):
import pylab
xrange = 100*self.step_size[0] * (numpy.array(range(0,[0]))-[0])
yrange = 100*self.step_size[1] * (numpy.array(range(0,[1]))-[1])
xrange = 100*self.x
yrange = 100*self.y
fig = pylab.figure()
axes = pylab.imshow(, extent=[min(xrange),max(xrange),min(yrange),max(yrange)])
......@@ -66,7 +74,7 @@ def read_map(filename):
data = numpy.loadtxt(filename, dtype=numpy.float64, skiprows=9,ndmin=2)
data = numpy.loadtxt(filename, dtype=numpy.float64,ndmin=2,comments='%')
return surfacemap(name,maptype,size,center,step,scaling,data)
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