1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
19 """Library for interpreting Hemingway force spectroscopy files.
25 from .. import curve as curve
26 from ..util.util import Closing as Closing
27 from . import Driver as Driver
30 class HemingwayDriver (Driver):
31 """Handle Hemingway force spectroscopy files.
34 super(HemingwayDriver, self).__init__(name='hemingway')
36 def is_me(self, path):
37 if os.path.isdir(path):
40 with Closing(file(path, 'r')) as f:
42 headlines.append(f.readline())
43 return (headlines[0].startswith('#Hemingway')
44 and headlines[1].startswith('#Experiment: FClamp'))
46 def read(self, path, info=None):
48 with Closing(file(path, 'r')) as f:
50 line = f.readline().strip()
53 fields = line.split(':', 1)
55 file_info[fields[0]] = fields[1]
56 data = numpy.loadtxt(f, dtype=numpy.float)
63 ret.info['columns'] = [
64 'time (s)', # first data column in file just increasing index
70 ret.info['name'] = 'force clamp'
71 # assume 1 ms timestep
72 ret[:,0] = numpy.arange(0, 1e-3*data.shape[0], 1e-3, dtype=ret.dtype)
74 return ([ret,], file_info)