Beispiel #1
0
 def importAscii(self):
     self.qfd = QFileDialog(self)
     self.qfd.setMode(QFileDialog.ExistingFiles)
     if self.qfd.exec_loop() == 1:
         for f in self.qfd.selectedFiles():
             w = project.new_worksheet(os.path.splitext(os.path.split(str(f))[1])[0], [])
             w.import_ascii(str(f))
Beispiel #2
0
 def importAscii(self):
     self.qfd = QFileDialog (self)
     self.qfd.setMode (QFileDialog.ExistingFiles)
     if self.qfd.exec_loop() == 1:
         for f in self.qfd.selectedFiles():
             w = project.new_worksheet(os.path.splitext(os.path.split(str(f))[1])[0], [])
             w.import_ascii (str(f))
def make_isochronal(e1_f, e2_f):
    all_temperatures = [wsname_to_temp(n) for n in [c.name for c in e1_f][1:]]
    e1_T = project.new_worksheet('_e1_T')
    e2_T = project.new_worksheet('_e2_T')
    e1_T.temp = e2_T.temp = all_temperatures
    project.mainwin.statusBar().message ("Creating e1_T")
    project.mainwin.progressbar.setTotalSteps(len(e1_f.array))
    for prog, line in enumerate(e1_f.array):
        e1_T[freq_to_name(line[0])] = line[1:]
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog+1)

    project.mainwin.statusBar().message ("Creating e2_T")
    project.mainwin.progressbar.setTotalSteps(len(e2_f.array))
    for prog, line in enumerate(e2_f.array):
        e2_T[freq_to_name(line[0])] = line[1:]
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog+1)
Beispiel #4
0
def make_isochronal(e1_f, e2_f):
    all_temperatures = [wsname_to_temp(n) for n in [c.name for c in e1_f][1:]]
    e1_T = project.new_worksheet('_e1_T')
    e2_T = project.new_worksheet('_e2_T')
    e1_T.temp = e2_T.temp = all_temperatures
    project.mainwin.statusBar().message("Creating e1_T")
    project.mainwin.progressbar.setTotalSteps(len(e1_f.array))
    for prog, line in enumerate(e1_f.array):
        e1_T[freq_to_name(line[0])] = line[1:]
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog + 1)

    project.mainwin.statusBar().message("Creating e2_T")
    project.mainwin.progressbar.setTotalSteps(len(e2_f.array))
    for prog, line in enumerate(e2_f.array):
        e2_T[freq_to_name(line[0])] = line[1:]
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog + 1)
Beispiel #5
0
    def pencil(self):
        if self.resultsws not in [w.name for w in project.worksheets]:
            project.new_worksheet(self.resultsws)

        if len(project[self.resultsws]) == 0:
            last = 0
        else:
            last = max([len(c) for c in project[self.resultsws]])

        for name in self.extra_properties:
            value, ok = QInputDialog.getText("Grafit", name, QLineEdit.Normal,
                                             None, self)
            if ok:
                value = float(str(value))
                if name not in project[self.resultsws].column_names:
                    project[self.resultsws][name] = []
                project[self.resultsws][name][last] = value

        for value, name in zip(self.params_func_to_flat()[0],
                               self.flat_names()):
            if name not in project[self.resultsws].column_names:
                project[self.resultsws][name] = []
            project[self.resultsws][name][last] = value

        for fnum, fn in enumerate(self.functions):
            if hasattr(fn, 'extra'):
                if fn.inst_name is not None:
                    fname = fn.inst_name
                else:
                    fname = 'f' + str(fnum)

                calldict = {}
                calldict.update(project.main_dict)
                calldict.update(fn.__dict__)
                for p, v in fn.extra.iteritems():
                    value = eval(v, calldict)
                    name = fname + '_' + p

                    if name not in project[self.resultsws].column_names:
                        project[self.resultsws][name] = []
                    project[self.resultsws][name][last] = value
Beispiel #6
0
    def pencil (self):
        if self.resultsws not in [w.name for w in project.worksheets]:
            project.new_worksheet(self.resultsws)

        if len(project[self.resultsws]) == 0:
            last = 0
        else:
            last = max([len(c) for c in project[self.resultsws]])

        for name in self.extra_properties:
            value, ok =  QInputDialog.getText ("Grafit", name, QLineEdit.Normal, None, self)
            if ok:
                value = float(str(value))
                if name not in project[self.resultsws].column_names:
                    project[self.resultsws][name] = []
                project[self.resultsws][name][last] = value
        
        for value, name in zip (self.params_func_to_flat()[0], self.flat_names ()):
            if name not in project[self.resultsws].column_names:
                project[self.resultsws][name] = []
            project[self.resultsws][name][last] = value

        for fnum, fn in enumerate(self.functions):
            if hasattr(fn, 'extra'):
                if fn.inst_name is not None:
                    fname = fn.inst_name
                else:
                    fname = 'f'+str(fnum)

                calldict = {}
                calldict.update(project.main_dict)
                calldict.update(fn.__dict__)
                for p, v in fn.extra.iteritems():
                    value = eval(v, calldict)
                    name = fname + '_' + p
     
                    if name not in project[self.resultsws].column_names:
                        project[self.resultsws][name] = []
                    project[self.resultsws][name][last] = value
def make_e2deriv(e1_f):
    all_temperatures = [wsname_to_temp(n) for n in [c.name for c in e1_f][1:]]

    project.mainwin.statusBar().message ("Creating deriv")
    project.mainwin.progressbar.setTotalSteps(len(e1_f)-1)
    deriv = project.new_worksheet('e2deriv_f')
    deriv.freq = e1_f.freq
    
    for prog, e1 in enumerate(e1_f[1:]):
        r = 1./(10*math.log(e1_f.freq[4]/e1_f.freq[5]))

        deriv[e1.name] = None

        for i in range(len(e1))[2:-3]:
            deriv[e1.name][i] = 2*r*(e1[i+2] - e1[i-2]) + r*(e1[i+1] - e1[i-1])
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog+1)
Beispiel #8
0
def make_e2deriv(e1_f):
    all_temperatures = [wsname_to_temp(n) for n in [c.name for c in e1_f][1:]]

    project.mainwin.statusBar().message("Creating deriv")
    project.mainwin.progressbar.setTotalSteps(len(e1_f) - 1)
    deriv = project.new_worksheet('e2deriv_f')
    deriv.freq = e1_f.freq

    for prog, e1 in enumerate(e1_f[1:]):
        r = 1. / (10 * math.log(e1_f.freq[4] / e1_f.freq[5]))

        deriv[e1.name] = None

        for i in range(len(e1))[2:-3]:
            deriv[e1.name][i] = 2 * r * (e1[i + 2] - e1[i - 2]) + r * (
                e1[i + 1] - e1[i - 1])
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog + 1)
Beispiel #9
0
 def add_fit_curve_to_graph(self, function):
     try:
         project['fitcurves']
     except IndexError, KeyError:
         project.new_worksheet ('fitcurves')
def process_windeta_dir(dir, worksheet_names):
    project.lock_undo()
    files = [dir + '/' + fil for fil in os.listdir(dir) if os.path.splitext(fil)[1] in ('.txt', '.TXT')]
    wsheets = []

    project.mainwin.statusBar().message ("Reading ASCII files")
    project.mainwin.progressbar.show()
    project.main_dict['app'].processEvents()
    project.mainwin.progressbar.setTotalSteps(len(files))

    for prog, f in enumerate(files):
        w = project.new_worksheet()
        w.import_ascii(f)
        name = windeta_wstemp(w, 1)
        if name is None:
            name = windeta_wstemp(w, 2)
            if name is None:
                p = Page(None, ('Could not determine temperature\n for ascii file '+f, ['Temperature']))
                p.run()
                try:
                    name = float(p['Temperature'])
                except ValueError:
                    continue
        name = temp_to_wsname(name)
        while name in [s.name for s in wsheets]:
            name += 'a'
        w.name = name
        wsheets.append(w)
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog+1)
    e1_f = project.new_worksheet('_e1_f')
    e2_f = project.new_worksheet('_e2_f')
    e1_f.freq = e2_f.freq = None

    new_wsheets = [(windeta_wstemp(w), w) for w in wsheets]
    new_wsheets.sort()
    wsheets = [w[1] for w in new_wsheets]

    project.mainwin.statusBar().message ("Creating e1_f and e2_f")
    project.mainwin.progressbar.setTotalSteps(len(files))

    for prog, w in enumerate(wsheets):
        if len(w[0]) > len(e1_f.freq):
            e1_f.freq = w[0]
            e2_f.freq = w[0]
        e1_f[w.name] = w[1]
        e2_f[w.name] = w[2]
        project.remove(w)
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog+1)

    if 'e1(T)' in worksheet_names or 'e2(T)' in worksheet_names:
        make_isochronal(e1_f, e2_f)
    	if 'e1(T)' in worksheet_names: project.w._e1_T.name = 'e1_T'
    	else: project.remove(project.w._e1_T)
    	if 'e2(T)' in worksheet_names: project.w._e2_T.name = 'e2_T'
    	else: project.remove(project.w._e2_T)
    if 'e2deriv(f)' in worksheet_names:
        make_e2deriv(e1_f)

    if 'e1(f)' in worksheet_names: project.w._e1_f.name = 'e1_f'
    else: project.remove(project.w._e1_f)
    if 'e2(f)' in worksheet_names: project.w._e2_f.name = 'e2_f'
    else: project.remove(project.w._e2_f)

    project.unlock_undo()
    project.mainwin.progressbar.hide()
Beispiel #11
0
def process_windeta_dir(dir, worksheet_names):
    project.lock_undo()
    files = [
        dir + '/' + fil for fil in os.listdir(dir)
        if os.path.splitext(fil)[1] in ('.txt', '.TXT')
    ]
    wsheets = []

    project.mainwin.statusBar().message("Reading ASCII files")
    project.mainwin.progressbar.show()
    project.main_dict['app'].processEvents()
    project.mainwin.progressbar.setTotalSteps(len(files))

    for prog, f in enumerate(files):
        w = project.new_worksheet()
        w.import_ascii(f)
        name = windeta_wstemp(w, 1)
        if name is None:
            name = windeta_wstemp(w, 2)
            if name is None:
                p = Page(None,
                         ('Could not determine temperature\n for ascii file ' +
                          f, ['Temperature']))
                p.run()
                try:
                    name = float(p['Temperature'])
                except ValueError:
                    continue
        name = temp_to_wsname(name)
        while name in [s.name for s in wsheets]:
            name += 'a'
        w.name = name
        wsheets.append(w)
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog + 1)
    e1_f = project.new_worksheet('_e1_f')
    e2_f = project.new_worksheet('_e2_f')
    e1_f.freq = e2_f.freq = None

    new_wsheets = [(windeta_wstemp(w), w) for w in wsheets]
    new_wsheets.sort()
    wsheets = [w[1] for w in new_wsheets]

    project.mainwin.statusBar().message("Creating e1_f and e2_f")
    project.mainwin.progressbar.setTotalSteps(len(files))

    for prog, w in enumerate(wsheets):
        if len(w[0]) > len(e1_f.freq):
            e1_f.freq = w[0]
            e2_f.freq = w[0]
        e1_f[w.name] = w[1]
        e2_f[w.name] = w[2]
        project.remove(w)
        if prog % 5 == 0:
            project.mainwin.progressbar.setProgress(prog + 1)

    if 'e1(T)' in worksheet_names or 'e2(T)' in worksheet_names:
        make_isochronal(e1_f, e2_f)
        if 'e1(T)' in worksheet_names: project.w._e1_T.name = 'e1_T'
        else: project.remove(project.w._e1_T)
        if 'e2(T)' in worksheet_names: project.w._e2_T.name = 'e2_T'
        else: project.remove(project.w._e2_T)
    if 'e2deriv(f)' in worksheet_names:
        make_e2deriv(e1_f)

    if 'e1(f)' in worksheet_names: project.w._e1_f.name = 'e1_f'
    else: project.remove(project.w._e1_f)
    if 'e2(f)' in worksheet_names: project.w._e2_f.name = 'e2_f'
    else: project.remove(project.w._e2_f)

    project.unlock_undo()
    project.mainwin.progressbar.hide()
Beispiel #12
0
 def add_fit_curve_to_graph(self, function):
     try:
         project['fitcurves']
     except IndexError, KeyError:
         project.new_worksheet('fitcurves')