middle_deflection = (self.info['min deflection']
+ self.info['deflection range']/2.)
kink_position = 2*(self._data > middle_deflection).argmax()
- left_slope = ((self._data[-1] - self.info['min deflection'])
- /kink_position)
+ if kink_position == 0:
+ # jump vibration at the start of the retraction?
+ start = int(min(max(20, 0.01 * len(self._data)), 0.5*len(self._data)))
+ std = self._data[:start].std()
+ left_offset = self._data[start].mean()
+ stop = start
+ while abs(self._data[stop] - left_offset) < 3*std:
+ stop += 1
+ left_slope = (self._data[stop-start:stop].mean()
+ - left_offset) / (stop-start)
+ left_offset -= left_slope * start/2
+ kink_position = (self._data[-1] - left_offset)/left_slope
+ else:
+ left_slope = (self._data[-1] - self.info['min deflection']
+ )/kink_position
right_slope = 0
self.info['guessed contact slope'] = left_slope
params = [left_offset, left_slope, kink_position, right_slope]
--- /dev/null
+# Copyright (C) 2010 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/>.
+
+"""
+Point data_logger to our test data.
+
+>>> import os
+>>> import os.path
+>>> import data_logger
+>>> data_logger.DEFAULT_PATH = os.path.join(
+... os.getcwd(), 'test', 'data', 'vclamp_wtk')
+
+Adjust Hooke in case we don't have calibcant installed.
+
+>>> from hooke.hooke import Hooke, HookeRunner
+>>> h = Hooke()
+>>> h.config.set('wtk driver', 'cantilever calibration directory',
+... '${DEFAULT}/calibrate_cantilever')
+>>> h.load_drivers()
+
+Proceed with the test itself.
+
+>>> r = HookeRunner()
+>>> playlist = os.path.join('test', 'data', 'vclamp_wtk', 'playlist')
+>>> h = r.run_lines(h, ['load_playlist ' + playlist])
+<FilePlaylist WTK>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['previous_curve'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_info --enable-path'])
+... # doctest: +ELLIPSIS, +REPORT_UDIFF
+path: .../test/data/vclamp_wtk/unfold/20100504/20100504151536_unfold
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['zero_surface_contact_point --block retract'])
+... # doctest: +ELLIPSIS, +REPORT_UDIFF
+{'active fitted parameters': array([ 1.04..., 1.12..., 0.91...]),
+ 'active parameters': array([ 1.04..., 1.12..., 0.91...]),
+ 'convergence flag': ...,
+ 'covariance matrix': array(...),
+ 'data scale factor': Data(3.95...e-08),
+ 'fitted parameters': [-8.3...e-08,
+ 4.6...e-11,
+ 2875.7...],
+ 'info': {...},
+ 'initial parameters': [-8.0...e-08,
+ 4.1...e-11,
+ 3149.2...],
+ 'message': '...',
+ 'rescaled': True,
+ 'scale': None}
+Success
+<BLANKLINE>
+"""