better headers in csv result files

This commit is contained in:
Markus Rosenstihl 2014-09-18 22:49:59 +02:00
parent 40ef9527ef
commit 1fe6057cd6

16
QDS.py
View File

@ -15,6 +15,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
import numpy as np
import time
import pyqtgraph as pg
from Container import Conductivity, PowerComplex, Static, Peak, YAFF
@ -241,20 +242,21 @@ class AppWindow(QMainWindow):
# prepare header
header="# T "
header = "{n1:13}{n2:13}".format(n1="# 0T", n2="1invT")
header = "# Date: {date}\n".format(date=time.ctime())
header += "{n1:13}{n2:13}".format(n1="# 0:T", n2="1:invT")
pars = []
bname = os.path.splitext(self.filepath)[0]
base_filename = os.path.splitext(self.filepath)[0]
# print "Registered Functions (saveFitResult): ",self.function_registry.get_registered_functions()
varnum = 2 # T, invT are the first two columns
for i_fcn, fcn in enumerate(self.function_registry.get_registered_functions()):
fit_function_name = fcn.id_string
for i, name in enumerate(fcn.widget.names): # get variable names
header += "{n:13}{n_sd:13}".format(n="%i%s"%(varnum, name), n_sd="%i%s_sd"%(varnum+1, name))
header += "{n:13}{n_sd:13}".format(n="%i:%s"%(varnum, name), n_sd="%i:%s_sd"%(varnum+1, name))
varnum += 2
# write for each function extra file
name_fcn = "%s_%i.fit"%(bname, i_fcn)
f_fcn = open(name_fcn, 'w')
f_fcn.write("# %s\n"%(fcn.id_string))
fit_filename = "%s_%i.fit"%(base_filename, i_fcn)
f_fcn = open(fit_filename, 'w')
f_fcn.write("# %s\n"%fit_function_name)
f_fcn.flush()
np.savetxt(f_fcn, fcn.resampleData(self.data.frequency))
f_fcn.close()