4 Library for interpreting Hemingway force spectroscopy files.
6 Copyright (C) 2008 Massimo Sandal, Marco Brucale (University of Bologna, Italy)
8 This program is released under the GNU General Public License version 2.
10 __version__='2007_02_15_devel'
13 2007_02_15: fixed time counter with my counter
14 2007_02_07: Initial implementation
17 from .. import curve as lhc
19 class DataChunk(list):
20 '''Dummy class to provide ext and ret methods to the data list.
21 In this case ext and self can be equal.
30 class hemingclampDriver(lhc.Driver):
32 def __init__(self, filename):
34 self.filedata = open(filename,'r')
35 self.data = self.filedata.readlines()[6:]
38 self.filetype = 'hemingclamp'
39 self.experiment = 'clamp'
41 self.filename=filename
48 we define our magic heuristic for HemingClamp files
50 myfile=file(self.filename)
51 headerlines=myfile.readlines()[0:3]
53 if headerlines[0][0:10]=='#Hemingway' and headerlines[1][0:19]=='#Experiment: FClamp':
58 def _getdata_all(self):
68 temp = string.split(i)
69 #time.append(float(temp[0])*(1.0e-3)) # This is managed differently now, since each data point = 1ms: see below
70 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
71 zpiezo.append(float(temp[2])*(1.0e-9))
72 defl.append(float(temp[3])*(1.0e-9))
73 imposed.append(float(temp[4])*(1.0e-9))
75 for x in range (0,len(phase)):
76 if phase[x] != trim_counter:
77 trim_indexes.append(x)
78 trim_counter = phase[x]
80 #we rebuild the time counter assuming 1 point = 1 millisecond
86 return time,phase,zpiezo,defl,imposed,trim_indexes
89 return DataChunk(self._getdata_all()[0])
92 return DataChunk(self._getdata_all()[1])
95 return DataChunk(self._getdata_all()[2])
98 return DataChunk(self._getdata_all()[3])
101 return DataChunk(self._getdata_all()[4])
103 def trimindexes(self):
104 return DataChunk(self._getdata_all()[5])
108 Explicitly closes all files
110 self.filedata.close()
112 def default_plots(self):
113 main_plot=lhc.PlotObject()
114 defl_plot=lhc.PlotObject()
119 deflection=self.deflection()
120 imposed=self.imposed()
122 main_plot.vectors=[[time,zpiezo],[time,phase]]
123 main_plot.units=['seconds','meters']
124 main_plot.destination=0
125 main_plot.title=self.filename
127 defl_plot.vectors=[[time,deflection],[time,imposed]]
128 defl_plot.units=['seconds','Newtons']
129 defl_plot.destination=1
131 return [main_plot, defl_plot]