6 Library for interpreting Hemingway force spectroscopy files.
8 Copyright (C) 2006 Massimo Sandal (University of Bologna, Italy)
10 This program is released under the GNU General Public License version 2.
12 __version__='2007_02_15_devel'
15 2007_02_15: fixed time counter with my counter
16 2007_02_07: Initial implementation
19 import libhookecurve as lhc
21 def hemingclamp_magic(filepath):
23 we define our magic heuristic for HemingClamp files
26 headerlines=myfile.readlines()[0:3]
27 if headerlines[0][0:10]=='#Hemingway' and headerlines[1][0:19]=='#Experiment: FClamp':
32 class DataChunk(list):
33 '''Dummy class to provide ext and ret methods to the data list.
34 In this case ext and self can be equal.
43 class hemingclampDriver(lhc.Driver):
45 def __init__(self, filename):
47 self.filedata = open(filename,'r')
48 self.data = self.filedata.readlines()[6:]
51 self.filetype = 'hemingclamp'
52 self.experiment = 'clamp'
54 self.filename=filename
61 we define our magic heuristic for HemingClamp files
63 myfile=file(self.filename)
64 headerlines=myfile.readlines()[0:3]
66 if headerlines[0][0:10]=='#Hemingway' and headerlines[1][0:19]=='#Experiment: FClamp':
71 def _getdata_all(self):
77 temp = string.split(i)
78 #time.append(float(temp[0])*(1.0e-3))
79 zpiezo.append(float(temp[2])*(1.0e-9))
80 defl.append(float(temp[3])*(1.0e-9))
82 #we rebuild the time counter assuming 1 point = 1 millisecond
88 return time,zpiezo,defl
91 return DataChunk(self._getdata_all()[0])
94 return DataChunk(self._getdata_all()[1])
97 return DataChunk(self._getdata_all()[2])
101 Explicitly closes all files
103 self.filedata.close()
105 def default_plots(self):
106 main_plot=lhc.PlotObject()
107 defl_plot=lhc.PlotObject()
111 deflection=self.deflection()
113 main_plot.vectors=[[time,zpiezo]]
114 main_plot.units=['seconds','meters']
115 main_plot.destination=0
116 main_plot.title=self.filename
118 defl_plot.vectors=[[time,deflection]]
119 defl_plot.units=['seconds','Newtons']
120 defl_plot.destination=1
122 return [main_plot, defl_plot]