6 Driver for text-exported HDF5 files from Igor pro
8 Alberto Gomez-Casado (c) 2010
9 Massimo Sandal (c) 2009
12 from .. import libhookecurve as lhc
13 from .. import libhooke as lh
15 class hdf5Driver(lhc.Driver):
17 def __init__(self, filename):
19 self.filename=filename
20 self.filedata=open(filename,'rU')
21 self.lines=list(self.filedata.readlines())
25 self.experiment='smfs'
31 self.raw_header=self.lines[0]
33 if 'IGP-HDF5-Hooke' in self.raw_header:
38 def _read_columns(self):
40 self.raw_columns=self.lines[4:]
43 for line in self.lines:
44 if line[:7]=='SpringC':
48 kline=kline.split(':')
50 self.k=float(kline[1])
57 for line in self.raw_columns:
59 xext.append(float(spline[0]))
60 yext.append(float(spline[1]))
61 xret.append(float(spline[2]))
62 yret.append(float(spline[3]))
64 return [[xext,yext],[xret,yret]]
67 self.data=self._read_columns()
68 return self.data[0][1],self.data[1][1]
71 def default_plots(self):
72 main_plot=lhc.PlotObject()
73 defl_ext,defl_ret=self.deflection()
74 yextforce=[i*self.k for i in defl_ext]
75 yretforce=[i*self.k for i in defl_ret]
76 main_plot.add_set(self.data[0][0],yextforce)
77 main_plot.add_set(self.data[1][0],yretforce)
78 main_plot.normalize_vectors()
79 main_plot.units=['Z','force'] #FIXME: if there's an header saying something about the time count, should be used
80 main_plot.destination=0
81 main_plot.title=self.filename
82 #main_plot.colors=['red','blue']