6 Library for interpreting Hemingway force spectroscopy files.
8 Copyright (C) 2008 Massimo Sandal, Marco Brucale (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 class DataChunk(list):
22 '''Dummy class to provide ext and ret methods to the data list.
23 In this case ext and self can be equal.
32 class hemingclampDriver(lhc.Driver):
34 def __init__(self, filename):
36 self.filedata = open(filename,'r')
37 self.data = self.filedata.readlines()[6:]
40 self.filetype = 'hemingclamp'
41 self.experiment = 'clamp'
43 self.filename=filename
50 we define our magic heuristic for HemingClamp files
52 myfile=file(self.filename)
53 headerlines=myfile.readlines()[0:3]
55 if headerlines[0][0:10]=='#Hemingway' and headerlines[1][0:19]=='#Experiment: FClamp':
60 def _getdata_all(self):
70 temp = string.split(i)
71 #time.append(float(temp[0])*(1.0e-3)) # This is managed differently now, since each data point = 1ms: see below
72 phase.append(float(temp[1])*(1.0e-7)) # The nonsensical (e-7) multiplier is just there to make phase data nicely plottable along other data
73 zpiezo.append(float(temp[2])*(1.0e-9))
74 defl.append(float(temp[3])*(1.0e-9))
75 imposed.append(float(temp[4])*(1.0e-9))
77 for x in range (0,len(phase)):
78 if phase[x] != trim_counter:
79 trim_indexes.append(x)
80 trim_counter = phase[x]
82 #we rebuild the time counter assuming 1 point = 1 millisecond
88 return time,phase,zpiezo,defl,imposed,trim_indexes
91 return DataChunk(self._getdata_all()[0])
94 return DataChunk(self._getdata_all()[1])
97 return DataChunk(self._getdata_all()[2])
100 return DataChunk(self._getdata_all()[3])
103 return DataChunk(self._getdata_all()[4])
105 def trimindexes(self):
106 return DataChunk(self._getdata_all()[5])
110 Explicitly closes all files
112 self.filedata.close()
114 def default_plots(self):
115 main_plot=lhc.PlotObject()
116 defl_plot=lhc.PlotObject()
121 deflection=self.deflection()
122 imposed=self.imposed()
124 main_plot.vectors=[[time,zpiezo],[time,phase]]
125 main_plot.units=['seconds','meters']
126 main_plot.destination=0
127 main_plot.title=self.filename
129 defl_plot.vectors=[[time,deflection],[time,imposed]]
130 defl_plot.units=['seconds','Newtons']
131 defl_plot.destination=1
133 return [main_plot, defl_plot]