Skip to content
Snippets Groups Projects
Commit f9929e7c authored by Andreas Freise's avatar Andreas Freise
Browse files

adding handling of scale command.

parent 350c61ce
Branches
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ class xaxis(Command): ...@@ -57,7 +57,7 @@ class xaxis(Command):
self.mx = putter("mx1") self.mx = putter("mx1")
if scale == "lin": if scale == "lin":
scale = Scale.linear scale = cale.linear
elif scale == "log": elif scale == "log":
scale = Scale.logarithmic scale = Scale.logarithmic
elif isinstance(scale, str): elif isinstance(scale, str):
......
...@@ -10,7 +10,7 @@ import pykat.gui.resources ...@@ -10,7 +10,7 @@ import pykat.gui.resources
from pykat.utils import * from pykat.utils import *
from pykat.gui.graphics import * from pykat.gui.graphics import *
from pykat.node_network import * from pykat.node_network import *
from pykat.param import Param, ScaleParam from pykat.param import Param
class Detector(object) : class Detector(object) :
...@@ -24,7 +24,7 @@ class Detector(object) : ...@@ -24,7 +24,7 @@ class Detector(object) :
self.__node = None self.__node = None
self._params = [] self._params = []
self._mask = {} self._mask = {}
self.__scale = ScaleParam("scale", self, SIfloat(1.0)) self.__scale = ""
if node.find('*'): if node.find('*'):
self._alternate_beam = True self._alternate_beam = True
...@@ -49,12 +49,11 @@ class Detector(object) : ...@@ -49,12 +49,11 @@ class Detector(object) :
def getQGraphicsItem(self): def getQGraphicsItem(self):
return None return None
@property @property
def scale(self): return self.__scale def scale(self): return self.__scale
@scale.setter @scale.setter
def sclae(self, value): def scale(self, value):
self.__scale = SIfloat(value) self.__scale = value
@property @property
def node(self): return self.__node def node(self): return self.__node
...@@ -303,6 +302,9 @@ class photodiode(Detector): ...@@ -303,6 +302,9 @@ class photodiode(Detector):
else: else:
rtn.append("pd{0}{1} {2} {3} {4}*".format(self.senstype, self.num_demods, self.name, __f_phi_str, self.node.name)) rtn.append("pd{0}{1} {2} {3} {4}*".format(self.senstype, self.num_demods, self.name, __f_phi_str, self.node.name))
if self.scale !=1.0 and self.scale != None:
rtn.append("scale {0} {1}".format(self.name, self.scale))
if self.noplot: if self.noplot:
rtn.append("noplot {0}".format(self.name)) rtn.append("noplot {0}".format(self.name))
......
...@@ -39,6 +39,7 @@ from pykat.detectors import Detector ...@@ -39,6 +39,7 @@ from pykat.detectors import Detector
from pykat.components import Component from pykat.components import Component
from pykat.commands import Command, xaxis from pykat.commands import Command, xaxis
from pykat.gui.gui import pyKatGUI from pykat.gui.gui import pyKatGUI
from pykat.SIfloat import *
import pykat.exceptions as pkex import pykat.exceptions as pkex
...@@ -145,6 +146,7 @@ class kat(object): ...@@ -145,6 +146,7 @@ class kat(object):
# and have no name attached to them. # and have no name attached to them.
self.retrace = None self.retrace = None
self.deriv_h = None self.deriv_h = None
self.scale = None
self.__phase = None self.__phase = None
self.__maxtem = None self.__maxtem = None
self.__noxaxis = None self.__noxaxis = None
...@@ -279,6 +281,8 @@ class kat(object): ...@@ -279,6 +281,8 @@ class kat(object):
obj = pykat.commands.x2axis.parseFinesseText(line) obj = pykat.commands.x2axis.parseFinesseText(line)
elif(first == "gauss" or first == "gauss*" or first == "gauss**"): elif(first == "gauss" or first == "gauss*" or first == "gauss**"):
after_process.append(line) after_process.append(line)
elif(first == "scale"):
after_process.append(line)
elif(first == "noxaxis"): elif(first == "noxaxis"):
self.noxaxis = True self.noxaxis = True
elif(first == "phase"): elif(first == "phase"):
...@@ -314,9 +318,22 @@ class kat(object): ...@@ -314,9 +318,22 @@ class kat(object):
# components to exist first before they can be processed # components to exist first before they can be processed
for line in after_process: for line in after_process:
first = line.split(" ",1)[0] first = line.split(" ",1)[0]
if first == "gauss" or first == "gauss*" or first == "gauss**": if first == "gauss" or first == "gauss*" or first == "gauss**":
pykat.commands.gauss.parseFinesseText(line) pykat.commands.gauss.parseFinesseText(line)
elif (first == "scale"):
v = line.split(" ")
if len(v) == 3:
component_name = v[2]
if component_name in self.__detectors :
self.__detectors[component_name].scale = SIfloat(v[1])
else:
raise pkex.BasePyKatException("scale command `{0}` refers to non-existing output".format(text))
elif len(values) == 2:
self.scale = SIfloat(v[1])
else:
raise pkex.BasePyKatException("scale command `{0}` is incorrect.".format(text))
self.__currentTag = NO_BLOCK self.__currentTag = NO_BLOCK
...@@ -623,6 +640,8 @@ class kat(object): ...@@ -623,6 +640,8 @@ class kat(object):
else: else:
out.append(txt + "\n") out.append(txt + "\n")
if self.scale != None and self.scale !=1.0: out.append("scale {0}\n".format(self.scale))
if self.phase != None: out.append("phase {0}\n".format(self.phase)) if self.phase != None: out.append("phase {0}\n".format(self.phase))
if self.maxtem != None: out.append("maxtem {0}\n".format(self.maxtem)) if self.maxtem != None: out.append("maxtem {0}\n".format(self.maxtem))
......
from pykat.SIfloat import SIfloat
import abc import abc
import pykat.exceptions as pkex import pykat.exceptions as pkex
...@@ -166,23 +165,4 @@ class AttrParam(Param): ...@@ -166,23 +165,4 @@ class AttrParam(Param):
return rtn return rtn
class ScaleParam(Param):
"""
The scale parameter of a detector is set using the Finesse `scale` command.
This inherits directly from a Param object so can be set whether this attribute
is putable or a putter.
If the value pf the parameter is not 1.0 the scale command will be printed.
"""
def getFinesseText(self):
rtn = []
if self.value != 1.0:
rtn.append("scale {0} {1}".format(self._owner.name, self.value))
rtn.extend(super(ScaleParam, self).getFinesseText())
return rtn
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment