diff --git a/pykat/SIfloat.py b/pykat/SIfloat.py index 4276cc42ad16bd5a33b5e4f607398d38485ac098..23e863f1cf33edae1703b8f959a45c5191e7229b 100644 --- a/pykat/SIfloat.py +++ b/pykat/SIfloat.py @@ -3,6 +3,8 @@ import re #staticmethod def SIfloat(value): + if value==None: + return value if type(value)==list: return [convertToFloat(s) for s in value] else: diff --git a/pykat/components.py b/pykat/components.py index 3bb5dd50d101d5448f21cfe9453f7361b3643fd9..dd8262bae9349acbb315040e7185eaa7d48e929b 100644 --- a/pykat/components.py +++ b/pykat/components.py @@ -155,7 +155,7 @@ class Component(object): class AbstractMirrorComponent(Component): __metaclass__ = abc.ABCMeta - def __init__(self, name, R=0, T=0, phi=0, Rcx=0, Rcy=0, xbeta=0, ybeta=0, mass=0, r_ap=0): + def __init__(self, name, R=0, T=0, phi=0, Rcx=None, Rcy=None, xbeta=None, ybeta=None, mass=None, r_ap=None): super(AbstractMirrorComponent, self).__init__(name) self.__R = Param("R", self, SIfloat(R)) @@ -166,7 +166,7 @@ class AbstractMirrorComponent(Component): self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="x") self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="y") self.__mass = AttrParam("mass", self, SIfloat(mass)) - self.__r_ap = AttrParam("r_ap", self, SIfloat(r_ap)) + self.__r_ap = AttrParam("r_ap", self, SIfloat(r_ap)) @property def r_ap(self): return self.__r_ap @@ -226,7 +226,7 @@ class AbstractMirrorComponent(Component): self.Rcy.value = SIfloat(value) class mirror(AbstractMirrorComponent): - def __init__(self,name,node1,node2,R=0,T=0,phi=0,Rcx=0,Rcy=0,xbeta=0,ybeta=0,mass=0, r_ap=0): + def __init__(self,name,node1,node2,R=0,T=0,phi=0,Rcx=None,Rcy=None,xbeta=None,ybeta=None,mass=None, r_ap=None): super(mirror, self).__init__(name, R, T, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap) self._requested_node_names.append(node1) @@ -272,7 +272,7 @@ class mirror(AbstractMirrorComponent): return self._svgItem class beamSplitter(AbstractMirrorComponent): - def __init__(self, name, node1, node2, node3, node4, R = 0, T = 0, phi = 0, alpha = 0, Rcx = 0, Rcy = 0, xbeta = 0, ybeta = 0, mass = 0, r_ap = 0): + def __init__(self, name, node1, node2, node3, node4, R = 0, T = 0, phi = 0, alpha = 0, Rcx = None, Rcy = None, xbeta = None, ybeta = None, mass = None, r_ap = None): super(beamSplitter, self).__init__(name, R, T, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap) self._requested_node_names.append(node1) @@ -335,7 +335,7 @@ class beamSplitter(AbstractMirrorComponent): return self._svgItem class space(Component): - def __init__(self, name, node1, node2, L = 0, n = 1, g = 0, gx = 0, gy = 0): + def __init__(self, name, node1, node2, L = 0, n = 1, g = None, gx = None, gy = None): Component.__init__(self, name) self._requested_node_names.append(node1) @@ -344,9 +344,9 @@ class space(Component): self.__L = Param("L", self, SIfloat(L)) self.__n = Param("n", self, SIfloat(n)) - self.__g = AttrParam("g", self, SIfloat(g)) - self.__gx = AttrParam("gx", self, SIfloat(gx)) - self.__gy = AttrParam("gy", self, SIfloat(gy)) + self.__g = AttrParam("g", self, g) + self.__gx = AttrParam("gx", self, gx) + self.__gy = AttrParam("gy", self, gy) @property def L(self): return self.__L @@ -408,7 +408,7 @@ class space(Component): return self._QItem class grating(Component): - def __init__(self, name, node1, node2, node3 = None, node4 = None, n = 2, d = 0, eta_0 = 0, eta_1 = 0, eta_2 = 0, eta_3 = 0, rho_0 = 0, alpha = 0): # TODO: implement Rcx, Rcy and Rc + def __init__(self, name, node1, node2, node3 = None, node4 = None, n = 2, d = 0, eta_0 = None, eta_1 = None, eta_2 = None, eta_3 = None, rho_0 = None, alpha = None): # TODO: implement Rcx, Rcy and Rc Component.__init__(self, name) self._requested_node_names.append(node1) @@ -706,7 +706,7 @@ class laser(Component): self.__power = Param("P", self, SIfloat(P), canFsig=True, fsig_name="amp") self.__f_offset = Param("f", self, SIfloat(f_offset), canFsig=True, fsig_name="f") self.__phase = Param("phase", self, SIfloat(phase), canFsig=True, fsig_name="phase") - self.__noise = AttrParam("noise", self, 0) + self.__noise = AttrParam("noise", self, None) @property def power(self): return self.__power diff --git a/pykat/param.py b/pykat/param.py index 52a5fc88554f8ce86990f5d672a8ec652fd65c09..798535afd103226921d0cd5eec9e19f3663e8b7d 100644 --- a/pykat/param.py +++ b/pykat/param.py @@ -173,7 +173,7 @@ class AttrParam(Param): def getFinesseText(self): rtn = [] - if self.value != 0: + if self.value != None: rtn.append("attr {0} {1} {2}".format(self._owner.name, self.name, self.value)) rtn.extend(super(AttrParam, self).getFinesseText())