3 """Driver for text-exported HDF5 files from Igor pro
6 from .. import curve as lhc
7 from .. import libhooke as lh
9 class hdf5Driver(lhc.Driver):
11 def __init__(self, filename):
13 self.filename=filename
14 self.filedata=open(filename,'rU')
15 self.lines=list(self.filedata.readlines())
19 self.experiment='smfs'
25 self.raw_header=self.lines[0]
27 if 'IGP-HDF5-Hooke' in self.raw_header:
32 def _read_columns(self):
34 self.raw_columns=self.lines[4:]
37 for line in self.lines:
38 if line[:7]=='SpringC':
42 kline=kline.split(':')
44 self.k=float(kline[1])
51 for line in self.raw_columns:
53 xext.append(float(spline[0]))
54 yext.append(float(spline[1]))
55 xret.append(float(spline[2]))
56 yret.append(float(spline[3]))
58 return [[xext,yext],[xret,yret]]
61 self.data=self._read_columns()
62 return self.data[0][1],self.data[1][1]
65 def default_plots(self):
66 main_plot=lhc.PlotObject()
67 defl_ext,defl_ret=self.deflection()
68 yextforce=[i*self.k for i in defl_ext]
69 yretforce=[i*self.k for i in defl_ret]
70 main_plot.add_set(self.data[0][0],yextforce)
71 main_plot.add_set(self.data[1][0],yretforce)
72 main_plot.normalize_vectors()
73 main_plot.units=['Z','force'] #FIXME: if there's an header saying something about the time count, should be used
74 main_plot.destination=0
75 main_plot.title=self.filename
76 #main_plot.colors=['red','blue']