Commit 61d5c32d authored by Daniel Brown's avatar Daniel Brown
Browse files

Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat

parents 05386a19 32d715e3
...@@ -9,24 +9,24 @@ def SIfloat(value): ...@@ -9,24 +9,24 @@ def SIfloat(value):
return convertToFloat(value) return convertToFloat(value)
def convertToFloat(value): def convertToFloat(value):
__prefix = {'y': 1e-24, # yocto __prefix = {'y': 'e-24', # yocto
'z': 1e-21, # zepto 'z': 'e-21', # zepto
'a': 1e-18, # atto 'a': 'e-18', # atto
'f': 1e-15, # femto 'f': 'e-15', # femto
'p': 1e-12, # pico 'p': 'e-12', # pico
'n': 1e-9, # nano 'n': 'e-9', # nano
'u': 1e-6, # micro 'u': 'e-6', # micro
'm': 1e-3, # mili 'm': 'e-3', # mili
'c': 1e-2, # centi 'c': 'e-2', # centi
'd': 1e-1, # deci 'd': 'e-1', # deci
'k': 1e3, # kilo 'k': 'e3', # kilo
'M': 1e6, # mega 'M': 'e6', # mega
'G': 1e9, # giga 'G': 'e9', # giga
'T': 1e12, # tera 'T': 'e12', # tera
'P': 1e15, # peta 'P': 'e15', # peta
'E': 1e18, # exa 'E': 'e18', # exa
'Z': 1e21, # zetta 'Z': 'e21', # zetta
'Y': 1e24, # yotta 'Y': 'e24', # yotta
} }
value = str(value) value = str(value)
for i, j in __prefix.iteritems(): for i, j in __prefix.iteritems():
......
...@@ -51,53 +51,48 @@ class Detector(object) : ...@@ -51,53 +51,48 @@ class Detector(object) :
class photodiode(Detector): class photodiode(Detector):
class F: class __F(list):
def __init__(self, values=None): def __init__(self, values=None):
if values is None: if values==None:
self.values = [] values = []
else: list.__init__(self,[SIfloat(value) for value in values])
self.values = values
def __len__(self):
return len(self.values)
def __getitem__(self, key):
# if key is of invalid type or value, the list values will raise the error
return self.values[key]
def __setitem__(self, key, value): def __setitem__(self, key, value):
print "setting" list.__setitem__(self,key, SIfloat(value))
self.values[key] = SIfloat(value)
### todo add append with SIfloat
class Phi():
def __init__(self, values=None): class __Phi(list):
print values def __convertValue(self, value):
if values is None: if value=="max":
self.values = [] return value
else: else:
self.values = values return SIfloat(value)
def __init__(self, values=None):
if values==None:
values = []
list.__init__(self,[self.__convertValue(value) for value in values])
def __getitem__(self, key): # probably not needed def __getitem__(self, key): # probably not needed
print "boom" if list.__getitem__(self,key)=="max":
if self.values[key]=="max": return list.__getitem__(self,key)
return self.values[key]
else: else:
return float(self.values[key]) return float(list.__getitem__(self,key))
def __setitem__(self,key,value): def __setitem__(self,key,value):
if value=="max": list.__setitem__(self,key, self.__convertValue(value))
self.values[key] = value
else:
self.values[key] = SIfloat(value)
def append(self, value):
self.values.append(value)
### todo add append with convertValue
@property @property
def f(self): return self.F('f', self.__f) def f(self): return self.__f
@f.setter
def f(self, key, value): self.__f[key]=value
@property
def phi(self): return self.__phi
def __init__(self, name, node, senstype=None, num_demods=0, demods=[]): def __init__(self, name, node, senstype=None, num_demods=0, demods=[]):
Detector.__init__(self, name, node) Detector.__init__(self, name, node)
if num_demods>2: if num_demods>2:
...@@ -106,15 +101,12 @@ class photodiode(Detector): ...@@ -106,15 +101,12 @@ class photodiode(Detector):
self.senstype = senstype self.senstype = senstype
# every second element into f (starting at 1) # every second element into f (starting at 1)
self.__f = self.F(demods[::2]) self.__f = self.__F(demods[::2])
# Every second element into phi (starting at 2) # Every second element into phi (starting at 2)
self.__phi = self.Phi() self.__phi = self.__Phi()
for i in demods[1::2]: for i in demods[1::2]:
self.__phi.append(i) self.__phi.append(i)
print self.__phi
print self.__phi[0]
@staticmethod @staticmethod
def parseFinesseText(text): def parseFinesseText(text):
......
Supports Markdown
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