Library for interpreting Hemingway force spectroscopy files.
-Copyright (C) 2006 Massimo Sandal (University of Bologna, Italy)
+Copyright (C) 2008 Massimo Sandal, Marco Brucale (University of Bologna, Italy)
This program is released under the GNU General Public License version 2.
'''
import string
import libhookecurve as lhc
-def hemingclamp_magic(filepath):
- '''
- we define our magic heuristic for HemingClamp files
- '''
- myfile=file(filepath)
- headerlines=myfile.readlines()[0:3]
- if headerlines[0][0:10]=='#Hemingway' and headerlines[1][0:19]=='#Experiment: FClamp':
- return True
- else:
- return False
-
class DataChunk(list):
'''Dummy class to provide ext and ret methods to the data list.
In this case ext and self can be equal.
return False
def _getdata_all(self):
- time = []\r
+ time = []
phase = []
zpiezo = []
- defl = []\r
- imposed = []\r
- trim_indexes = []\r
- trim_counter = 0.0\r
+ defl = []
+ imposed = []
+ trim_indexes = []
+ trim_counter = 0.0
for i in self.data:
temp = string.split(i)
#time.append(float(temp[0])*(1.0e-3)) # This is managed differently now, since each data point = 1ms: see below
- 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\r
+ 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
zpiezo.append(float(temp[2])*(1.0e-9))
- defl.append(float(temp[3])*(1.0e-9))\r
- imposed.append(float(temp[4])*(1.0e-9))\r
-\r
+ defl.append(float(temp[3])*(1.0e-9))
+ imposed.append(float(temp[4])*(1.0e-9))
+
for x in range (0,len(phase)):
if phase[x] != trim_counter:
trim_indexes.append(x)
- trim_counter = phase[x]\r
+ trim_counter = phase[x]
#we rebuild the time counter assuming 1 point = 1 millisecond
c=0.0
def time(self):
return DataChunk(self._getdata_all()[0])
-\r
+
def phase(self):
- return DataChunk(self._getdata_all()[1])\r
+ return DataChunk(self._getdata_all()[1])
def zpiezo(self):
return DataChunk(self._getdata_all()[2])
def deflection(self):
return DataChunk(self._getdata_all()[3])
-\r
+
def imposed(self):
- return DataChunk(self._getdata_all()[4])\r
-\r
- def trimindexes(self):\r
- return DataChunk(self._getdata_all()[5])\r
+ return DataChunk(self._getdata_all()[4])
+
+ def trimindexes(self):
+ return DataChunk(self._getdata_all()[5])
def close_all(self):
'''
main_plot=lhc.PlotObject()
defl_plot=lhc.PlotObject()
- time=self.time()\r
+ time=self.time()
phase=self.phase()
zpiezo=self.zpiezo()
- deflection=self.deflection()\r
- imposed=self.imposed()\r
+ deflection=self.deflection()
+ imposed=self.imposed()
main_plot.vectors=[[time,zpiezo],[time,phase]]
main_plot.units=['seconds','meters']
defl_plot.vectors=[[time,deflection],[time,imposed]]
defl_plot.units=['seconds','Newtons']
- defl_plot.destination=1\r
+ defl_plot.destination=1
return [main_plot, defl_plot]
\ No newline at end of file