1 # calibcant - tools for thermally calibrating AFM cantilevers
3 # Copyright (C) 2008-2012 W. Trevor King <wking@drexel.edu>
5 # This file is part of calibcant.
7 # calibcant is free software: you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free Software
9 # Foundation, either version 3 of the License, or (at your option) any later
12 # calibcant is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # calibcant. If not, see <http://www.gnu.org/licenses/>.
19 """h5config support, so we can easily save what we did and load it later.
24 from FFT_tools import window_hann as _window_hann
25 import h5config.config as _config
26 import h5config.tools as _h5config_tools
27 from pyafm.config import AFMConfig as _AFMConfig
30 class PackageConfig (_h5config_tools.PackageConfig):
31 "Configure `calibcant` module operation"
32 settings = _h5config_tools.PackageConfig.settings + [
33 _config.BooleanSetting(
35 help='Plot piezo motion using `matplotlib`.',
40 class _BumpModel (object):
42 class Linear (_BumpModel):
44 class Quadratic (_BumpModel):
47 class BumpConfig (_config.Config):
48 "Configure `calibcant` bump operation"
51 name='initial-position',
52 help=('Position relative to surface for start of bump in meters. '
53 'Should be less than zero to ensure non-contact region '
54 'before you hit the surface.'),
58 help=('Maximum deflection in volts in case of stepper positioning '
59 'to achieve the initial position.'),
62 name='min-slope-ratio',
63 help=('Set the minimum ratio between the deflection/displacement '
64 'of the contact and the non-contact regions for bumps '
65 'seeking the surface. Bumps without sufficient difference '
66 'assume they need to move closer to find the surface.'),
68 _config.IntegerSetting(
70 help=('Number of stepper steps to move "far" away from the '
71 'surface. For possible stepper adjustments while initially '
72 'locating the surface.'),
76 help='Distance to approach in meters.',
80 help='Approach/retract speed in meters/second.',
84 help='Number of samples during approach and during retreat.',
86 _config.ChoiceSetting(
88 help='Bump deflection model.',
92 ('quadratic', Quadratic),
97 class TemperatureConfig (_config.Config):
98 "Configure `calibcant` temperature operation"
100 _config.FloatSetting(
102 help=('Time between temperature measurements (in seconds) to get '
103 'independent measurements when reading from slow sensors.'),
108 class _VibrationModel (object):
110 class Variance (_VibrationModel):
112 class BreitWigner (_VibrationModel):
114 class OffsetBreitWigner (_VibrationModel):
117 class VibrationConfig (_config.Config):
118 "Configure `calibcant` vibration operation"
120 _config.FloatSetting(
122 help='Sampling frequency in Hz.',
124 _config.FloatSetting(
126 help=('Aquisition time in seconds. This is rounded up as required '
127 'so the number of samples will be an integer power of two.'),
129 _config.ChoiceSetting(
131 help='Vibration model.',
134 ('variance', Variance),
135 ('Breit-Wigner', BreitWigner),
136 ('offset Breit-Wigner', OffsetBreitWigner),
138 _config.IntegerSetting(
140 help='FFT chunk size (for PSD fits).',
142 _config.BooleanSetting(
144 help='Overlap FFT chunks (for PSD fits).'),
145 _config.ChoiceSetting(
147 help='FFT chunk window (for PSD fits).',
148 default=_window_hann,
150 ('Hann', _window_hann),
152 _config.FloatSetting(
153 name='minimum-fit-frequency',
154 help='Lower bound of Lorentzian fitting region.',
156 _config.FloatSetting(
157 name='maximum-fit-frequency',
158 help='Upper bound of Lorentzian fitting region.',
163 class CalibrateConfig (_config.Config):
164 "Configure a full `calibcant` calibration run"
166 _config.ConfigSetting(
168 help='Configure the AFM used to carry out the calibration',
169 config_class=_AFMConfig),
170 _config.ConfigSetting(
172 help='Configure the surface bumps',
173 config_class=BumpConfig),
174 _config.IntegerSetting(
176 help='Number of surface bumps.',
178 _config.ConfigSetting(
180 help='Configure the temperature measurements',
181 config_class=TemperatureConfig),
182 _config.IntegerSetting(
183 name='num-temperatures',
184 help='Number of temperature measurements.',
186 _config.ConfigSetting(
188 help='Configure the temperature measurements',
189 config_class=VibrationConfig),
190 _config.IntegerSetting(
191 name='num-vibrations',
192 help='Number of thermal vibration measurements.',
194 _config.FloatSetting(
195 name='vibration-spacing',
196 help=('Approximate distance from the surface in meters for the '
197 'vibration measurements. This should be large enough that '
198 'surface effects are negligable.'),