Example #1
0
 def loadFromFile(self, filename, want_fixed=False):
     textFileLines = self.fileList(filename)
     first = textFileLines[0].strip().split('=')
     if first[0].strip() == 'weight':
         self.weight = float(first[1].strip())
         del(textFileLines[0])
         first = textFileLines[0].strip().split('=')
     if first[0].strip() != '-log(Like)': raise Exception('Error in format of parameter (best fit) file')
     self.logLike = float(first[1].strip())
     isFixed = False
     isDerived = False
     self.chiSquareds = []
     chunks = 0
     if len(textFileLines[1].strip()) > 0: del(textFileLines[1])  # if it has chi2 line as well
     for ix in range(2, len(textFileLines)):
         line = textFileLines[ix]
         if len(line.strip()) == 0:
             chunks += 1
             isFixed = not isFixed
             isDerived = True
             if chunks == 3:
                 if ix + 2 >= len(textFileLines): break
                 for likePart in textFileLines[ix + 2:]:
                     if len(likePart.strip()) != 0:
                         (chisq, name) = [s.strip() for s in likePart.split(None, 2)][1:]
                         name = [s.strip() for s in name.split(':', 1)]
                         if len(name) > 1:
                             (kind, name) = name
                         else: kind = ''
                         chi2 = likelihoodChi2()
                         if '=' in name: chi2.tag, chi2.name = [s.strip() for s in name.split('=')]
                         else: chi2.tag, chi2.name = None, name
                         chi2.chisq = float(chisq)
                         self.chiSquareds.append((kind, chi2))
                 break
             continue
         if not isFixed or want_fixed:
             param = paramNames.paramInfo()
             param.isFixed = isFixed
             param.isDerived = isDerived
             (param.number, param.best_fit, param.name, param.label) = [s.strip() for s in line.split(None, 3)]
             param.number = int(param.number)
             param.best_fit = float(param.best_fit)
             self.names.append(param)
Example #2
0
 def loadFromFile(self, filename):
     textFileLines = self.fileList(filename)
     lims = textFileLines[0].split(':')[1]
     self.limits = [float(s.strip()) for s in lims.split(';')]
     self.hasBestFit = False
     for line in textFileLines[3:]:
         if len(line.strip()) == 0: break
         param = paramNames.paramInfo()
         items = [s.strip() for s in line.split(None, len(self.limits) * 3 + 3)]
         param.name = items[0]
         if param.name[-1] == '*':
             param.isDerived = True
             param.name = param.name[:-1]
         param.mean = float(items[1])
         param.err = float(items[2])
         param.label = items[-1]
         param.limits = []
         for i in range(len(self.limits)):
             param.limits.append(paramLimit([float(s) for s in items[3 + i * 3:5 + i * 3] ], items[5 + i * 3]))
         self.names.append(param)