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)
+ try:
+ afm.stepper_approach(target_deflection=deflection + 1e3)
+ k,k_s,data = calibrator.calibrate(filename=filename)
+ except:
+ afm.move_away_from_surface()
+ afm.piezo.zero()
+ raise
finally:
for device in devices:
device.close()