1 # Copyright (C) 2008-2010 Massimo Sandal <devicerandom@gmail.com>
2 # W. Trevor King <wking@drexel.edu>
4 # This file is part of Hooke.
6 # Hooke is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with Hooke. If not, see
18 # <http://www.gnu.org/licenses/>.
20 """Library for interpreting Hemingway force spectroscopy files.
26 from .. import curve as curve
27 from .. import experiment as experiment
28 from ..util.util import Closing as Closing
29 from . import Driver as Driver
32 class HemingwayDriver (Driver):
33 """Handle Hemingway force spectroscopy files.
36 super(HemingwayDriver, self).__init__(name='hemingway')
38 def is_me(self, path):
39 if os.path.isdir(path):
42 with Closing(file(path, 'r')) as f:
44 headlines.append(f.readline())
45 return (headlines[0].startswith('#Hemingway')
46 and headlines[1].startswith('#Experiment: FClamp'))
48 def read(self, path, info=None):
50 with Closing(file(path, 'r')) as f:
52 line = f.readline().strip()
55 fields = line.split(':', 1)
57 file_info[fields[0]] = fields[1]
58 data = numpy.loadtxt(f, dtype=numpy.float)
65 ret.info['columns'] = [
66 'time (s)', # first data column in file just increasing index
72 ret.info['name'] = 'force clamp'
73 # assume 1 ms timestep
74 ret[:,0] = numpy.arange(0, 1e-3*data.shape[0], 1e-3, dtype=ret.dtype)
76 file_info['filetype'] = self.name
77 file_info['experiment'] = experiment.ForceClamp
78 return ([ret,], file_info)