Run update-copyright.py
[calibcant.git] / bin / calibcant-calibrate.py
index 5cf5a92f78570f7234e102866b9a64fd22a1c20d..afcbba46642d1dc454ad77f570d7a9dd7b8fb9fb 100755 (executable)
@@ -1,7 +1,21 @@
 #!/usr/bin/env python
 # calibcant - tools for thermally calibrating AFM cantilevers
 #
-# Copyright
+# Copyright (C) 2012-2013 W. Trevor King <wking@tremily.us>
+#
+# This file is part of calibcant.
+#
+# calibcant is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# calibcant 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# calibcant.  If not, see <http://www.gnu.org/licenses/>.
 
 """Run a cantilever calibration using the default AFM
 (``pyafm.storage.load_afm()``).
 import argparse as _argparse
 import time as _time
 
-from calibcant.calibrate import Calibrator as _Calibrator
+import h5py as _h5py
 from pyafm.storage import load_afm as _load_afm
+
+from calibcant.calibrate import Calibrator as _Calibrator
 import calibcant.config as _config
 
 
@@ -62,7 +78,11 @@ def main(args):
         calibrator.setup_config()
         deflection = afm.piezo.read_deflection()
         try:
-            afm.stepper_approach(target_deflection=deflection + 1e3)
+            position,deflection = afm.stepper_approach(
+                target_deflection=deflection + 1e3, record_data=True)
+            with _h5py.File(filename) as f:
+                f['/approach/position'] = position
+                f['/approach/deflection'] = deflection
             if insufficient_calibration_data:
                 data = calibrator.acquire(filename=filename)
             else: