From 68caacd6980f3c66e4a474dc584beaa39ae87bac Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 26 Mar 2012 12:54:42 -0400 Subject: [PATCH] Add calibcant-calibrate.py, now that we have a configurable default AFM to calibrate. --- bin/calibcant-calibrate.py | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 bin/calibcant-calibrate.py diff --git a/bin/calibcant-calibrate.py b/bin/calibcant-calibrate.py new file mode 100755 index 0000000..f12112f --- /dev/null +++ b/bin/calibcant-calibrate.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# calibcant - tools for thermally calibrating AFM cantilevers +# +# Copyright + +"""Run a cantilever calibration using the default AFM +(``pyafm.storage.load_afm()``). +""" + +import os +import time as _time + +from calibcant.calibrate import Calibrator as _Calibrator +from pyafm.storage import load_afm as _load_afm +import calibcant.config as _config + + +def main(args): + timestamp = '{0}-{1:02d}-{2:02d}T{3:02d}-{4:02d}-{5:02d}'.format( + *_time.localtime()) + filename = '{}-calibcant-data.h5'.format(timestamp) + config = _config.CalibrateConfig() + config['bump'] = _config.BumpConfig() + config['bump'].update( + {'model':_config.Linear, 'initial-position':-150e-9}) + config['temperature'] = _config.TemperatureConfig() + config['vibration'] = _config.VibrationConfig() + devices = [] + try: + afm = _load_afm() + afm.load_from_config(devices=devices) + calibrator = _Calibrator(config=config, afm=afm) + calibrator.setup_config() + deflection = afm.piezo.read_deflection() + afm.stepper_approach(target_deflection=deflection + 1e3) + k,k_s,data = calibrator.calibrate(filename=filename) + finally: + for device in devices: + device.close() + print 'k: {:g} +/- {:g}'.format(k, k_s) + return 0 + +if __name__ == '__main__': + import sys + + sys.exit(main(sys.argv[1:])) -- 2.26.2