-#!/usr/bin/env python
+# Copyright (C) 2008-2010 Massimo Sandal <devicerandom@gmail.com>
+# W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation, either
+# version 3 of the License, or (at your option) any later version.
+#
+# Hooke is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke. If not, see
+# <http://www.gnu.org/licenses/>.
-'''
-libhemingclamp.py
-
-Library for interpreting Hemingway force spectroscopy files.
-
-Copyright (C) 2008 Massimo Sandal, Marco Brucale (University of Bologna, Italy)
-
-This program is released under the GNU General Public License version 2.
-'''
+"""Library for interpreting Hemingway force spectroscopy files.
+"""
__version__='2007_02_15_devel'
__changelog__='''
2007_02_07: Initial implementation
'''
import string
-import libhookecurve as lhc
+from .. import curve as lhc
class DataChunk(list):
'''Dummy class to provide ext and ret methods to the data list.
In this case ext and self can be equal.
'''
-
+
def ext(self):
return self
-
+
def ret(self):
return self
class hemingclampDriver(lhc.Driver):
-
+
def __init__(self, filename):
-
+
self.filedata = open(filename,'r')
self.data = self.filedata.readlines()[6:]
self.filedata.close()
-
+
self.filetype = 'hemingclamp'
self.experiment = 'clamp'
-
+
self.filename=filename
-
+
def __del__(self):
- self.filedata.close()
-
+ self.filedata.close()
+
def is_me(self):
'''
we define our magic heuristic for HemingClamp files
return True
else:
return False
-
+
def _getdata_all(self):
time = []
phase = []
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
if phase[x] != trim_counter:
trim_indexes.append(x)
trim_counter = phase[x]
-
+
#we rebuild the time counter assuming 1 point = 1 millisecond
c=0.0
for z in zpiezo:
time.append(c)
- c+=(1.0e-3)
-
+ c+=(1.0e-3)
+
return time,phase,zpiezo,defl,imposed,trim_indexes
-
+
def time(self):
return DataChunk(self._getdata_all()[0])
def phase(self):
return DataChunk(self._getdata_all()[1])
-
+
def zpiezo(self):
return DataChunk(self._getdata_all()[2])
-
+
def deflection(self):
return DataChunk(self._getdata_all()[3])
def trimindexes(self):
return DataChunk(self._getdata_all()[5])
-
+
def close_all(self):
'''
Explicitly closes all files
'''
self.filedata.close()
-
+
def default_plots(self):
main_plot=lhc.PlotObject()
defl_plot=lhc.PlotObject()
-
+
time=self.time()
phase=self.phase()
zpiezo=self.zpiezo()
deflection=self.deflection()
imposed=self.imposed()
-
+
main_plot.vectors=[[time,zpiezo],[time,phase]]
main_plot.units=['seconds','meters']
main_plot.destination=0
main_plot.title=self.filename
-
+
defl_plot.vectors=[[time,deflection],[time,imposed]]
defl_plot.units=['seconds','Newtons']
defl_plot.destination=1
-
+
return [main_plot, defl_plot]
-
\ No newline at end of file
+