def read_output_spreadsheet(filename): '''Read a fit result spreadsheet as starting point for a new fit This can be used to tweak parameters in the fit result in cases where the fit got stuck in a local minimum. Parameters ---------- filename : string Returns ------- regions : list of :class:`Region` instances ''' Abgrall93 = read_Abgrall93() regions = [] with open(filename) as f: header = f.readline() filecontent = f.readlines() filecontent = [line.strip().split(',') for line in filecontent] for name, region in groupby(filecontent, lambda x: x[0]): r = list(region) regions.append(Region(r, Abgrall93=Abgrall93)) return regions
def read_spreadsheet(filename): '''Read Gabriel's spreadsheet This spreadsheet lists which regions and which lines should be fitted together and where the lines are spaced far enough apart to be treated separately. ''' regions = [] Abgrall93 = read_Abgrall93() with open(filename) as f: header = f.readline() filecontent = f.readlines() for line in filecontent: newline = line.strip().split(',') regions.append(Region(newline, Abgrall93=Abgrall93, oldformat=True)) return regions
def __init__(self, region, plotpath='.', printfiletype='.png'): '''Read Gabriel's spreadsheet This spreadsheet lists which regions and which lines should be fitted together and where the lines are spaced far enough apart to be treated separately. ''' self.plotpath = plotpath self.printfiletype = printfiletype Abgrall93=read_Abgrall93() name = region[0][0] FN = region[0][1] if FN[0] == '"': FN = FN[1:-1] self.name = name self.FN = FN[0] self.detector = int(FN[2]) self.start = float(region[0][2]) self.stop = float(region[0][3]) self.const = region[0][5] self.H2lines = [] self.nonH2lines = [] for line in region: print line if len(line) > 0: name, wave, absorption = interpret_line_code(line[8], Abgrall93) if name[0:2] == 'H2': # ignore the pos value for H2 lines. # will be set from Abgrall line list self.H2lines.append({'name': name, 'wave': wave, 'abs': absorption, 'fwhm': line[11], 'ampl': line[12]}) else: self.nonH2lines.append({'name': name, 'wave': wave, 'abs': absorption, 'pos': line[10], 'fwhm': line[11], 'ampl': line[12]})