Skip to content
Snippets Groups Projects
Commit 4a93bd25 authored by Daniel Toyra's avatar Daniel Toyra
Browse files

Fixed issue with the noplot command. Now it works for detectors and functions...

Fixed issue with the noplot command. Now it works for detectors and functions when using the pykat plotting method.
parent ab4ea4e4
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,14 @@ class func(Command):
self.noplot = False
def getFinesseText(self):
return "func {name} = {value}".format(name=self.name, value=str(self.value))
rtn = []
if self.noplot:
rtn.append("noplot " + self.name)
rtn.append("func {name} = {value}".format(name=self.name, value=str(self.value)))
return rtn
@staticmethod
def parseFinesseText(line, kat):
......
......@@ -134,7 +134,12 @@ class BaseDetector(object) :
def getFinesseText(self):
""" Base class for individual finesse optical components """
raise NotImplementedError("This function is not implemented")
#raise NotImplementedError("This function is not implemented")
if self.noplot:
return ["noplot " + self.name]
else:
return []
def getQGraphicsItem(self):
if not USE_GUI:
......@@ -258,7 +263,7 @@ class beam(Detector1):
raise pkex.BasePyKatException('Beam detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.alternate_beam:
alt = '*'
......@@ -321,7 +326,7 @@ class cp(Detector0):
raise pkex.BasePyKatException('Cavity parameter detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
rtn.append("cp {name} {cavity} {direction} {parameter}".format(name=self.name,
cavity=str(self.cavity),
......@@ -348,7 +353,7 @@ class xd(Detector0):
raise pkex.BasePyKatException('Motion detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
rtn.append("xd {name} {component} {motion}".format(name=self.name,
component=self.component,
......@@ -394,7 +399,7 @@ class ad(Detector1):
raise pkex.BasePyKatException('Amplitude detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.alternate_beam:
alt = '*'
......@@ -448,7 +453,7 @@ class gouy(Detector1):
raise pkex.BasePyKatException('Gouy detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
rtn.append("gouy {name} {dir} {spaces}".format(name=self.name, dir=str(self.direction), spaces=" ".join(self.spaces)))
......@@ -500,7 +505,7 @@ class bp(Detector1):
raise pkex.BasePyKatException('Gouy detector code "{0}" is not a valid FINESSE command'.format(text))
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.alternate_beam:
alt = "*"
......@@ -721,7 +726,7 @@ class pd(Detector1):
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.enabled:
alt_str = ""
......@@ -833,7 +838,7 @@ class qnoised(pd):
return qnoised(values[1], demods, node, senstype=sens, alternate_beam=alt_beam, **dict)
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.enabled:
alt_str = ""
......@@ -931,7 +936,7 @@ class qshot(pd):
return qshot(values[1], demods, node, senstype=sens, alternate_beam=alt_beam, **dict)
def getFinesseText(self) :
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.enabled:
alt_str = ""
......@@ -993,7 +998,7 @@ class hd(Detector2):
return hd(values[1], float(values[2]), str(values[3]), str(values[4]))
def getFinesseText(self):
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.enabled:
n1 = self.node1.name
......@@ -1052,7 +1057,7 @@ class qhd(Detector2):
return qhd(values[1], float(values[2]), str(values[3]), str(values[4]), sensitivity = sens)
def getFinesseText(self):
rtn = []
rtn = BaseDetector.getFinesseText(self)
if self.enabled:
n1 = self.node1.name
......
......@@ -375,6 +375,7 @@ class katRun(object):
for det in detectors:
if not hasattr(kat, det) or (hasattr(kat, det) and not getattr(kat, det).noplot):
if dual_plot:
ax = pyplot.subplot(2,1,1)
......@@ -1147,6 +1148,12 @@ class kat(object):
self.add(obj, block=self.__currentTag)
# Before processing the rest, all "noplot" commands are moved to the
# end of the list to make sure they are after all "func" commands.
for k in range(len(after_process)-1,-1,-1):
if after_process[k][0].split(" ", 1)[0] == "noplot":
after_process.append(after_process.pop(k))
# now process all the varous gauss/attr etc. commands which require
# components to exist first before they can be processed
for item in after_process:
......@@ -1168,6 +1175,7 @@ class kat(object):
elif (first == "variable"):
self.add(pykat.commands.variable.parseFinesseText(line, self), block=block)
elif (first == "noplot"):
if not hasattr(self, rest):
raise pkex.BasePyKatException("noplot command `{0}` refers to non-existing detector".format(line))
......@@ -1964,6 +1972,7 @@ class kat(object):
writeBlock()
out.append("%%% FTend " + key + "\n")
# write the NO_BLOCK blocks
for key in self.__blocks:
objs = self.__blocks[key].contents
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment