6 Driver for text-exported MFP 1D files
8 Massimo Sandal (c) 2009
11 import libhookecurve as lhc
14 class mfp1dexportDriver(lhc.Driver):
16 def __init__(self, filename):
18 self.filename=filename
19 self.filedata=open(filename,'rU')
21 lines=list(self.filedata.readlines())
22 self.raw_header=lines[0:38]
23 self.raw_columns=lines[39:]
26 self.data=self._read_columns()
28 self.k=float(self.raw_header[22][16:])
31 self.filetype='mfp1dexport'
32 self.experiment='smfs'
38 if self.raw_header[0][0:4]=='Wave':
43 def _read_columns(self):
48 for line in self.raw_columns:
50 xext.append(float(spline[0]))
51 yext.append(float(spline[1]))
52 xret.append(float(spline[2]))
53 yret.append(float(spline[3]))
55 return [[xext,yext],[xret,yret]]
58 return self.data[0][1],self.data[1][1]
61 def default_plots(self):
62 main_plot=lhc.PlotObject()
64 yextforce=[i*self.k for i in self.data[0][1]]
65 yretforce=[i*self.k for i in self.data[1][1]]
66 main_plot.add_set(self.data[0][0],yextforce)
67 main_plot.add_set(self.data[1][0],yretforce)
68 main_plot.normalize_vectors()
69 main_plot.units=['Z','force'] #FIXME: if there's an header saying something about the time count, should be used
70 main_plot.destination=0
71 main_plot.title=self.filename
72 #main_plot.colors=['red','blue']