Get calibcant working with the new load_from_config-based pyafm.
[calibcant.git] / calibcant / config.py
index 2cb32da01338ab9a390619b379167bdfca334b5e..87ec91717e7baf6484edf11fada4b66966cc71bb 100644 (file)
@@ -1,31 +1,30 @@
 # calibcant - tools for thermally calibrating AFM cantilevers
 #
-# Copyright (C) 2008-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2008-2012 W. Trevor King <wking@drexel.edu>
 #
 # This file is part of calibcant.
 #
-# calibcant 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.
+# 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 Lesser General Public License for more details.
+# 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 Lesser General Public
-# License along with calibcant.  If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License along with
+# calibcant.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Define some variables to configure the package for a particular lab
-and workflow."""
+"""h5config support, so we can easily save what we did and load it later.
+"""
 
 import sys as _sys
 
 from FFT_tools import window_hann as _window_hann
 import h5config.config as _config
 import h5config.tools as _h5config_tools
+from pyafm.config import AFMConfig as _AFMConfig
 
 
 class PackageConfig (_h5config_tools.PackageConfig):
@@ -35,37 +34,8 @@ class PackageConfig (_h5config_tools.PackageConfig):
             name='matplotlib',
             help='Plot piezo motion using `matplotlib`.',
             default=False),
-        _config.FloatSetting(
-            name='temperature',
-            help=('Default temperature for thermal calibration in degrees '
-                  'Celsius.'),
-            default=22),
         ]
 
-class _TemperatureUnit (object):
-    pass
-class Celsius (_TemperatureUnit):
-    pass
-class Kelvin (_TemperatureUnit):
-    pass
-
-class TemperatureConfig (_config.Config):
-    "Configure `calibcant` temperature operation"
-    settings = [
-        _config.ChoiceSetting(
-            name='units',
-            help='Units of raw temperature measurements.',
-            default=Celsius,
-            choices=[
-                ('Celsius', Celsius),
-                ('Kelvin', Kelvin),
-                ]),
-        _config.BooleanSetting(
-            name='default',
-            help=('The temperature values are defaults (vs. real '
-                  'measurements).'),
-            default=True),
-        ]
 
 class _BumpModel (object):
     pass
@@ -124,6 +94,17 @@ class BumpConfig (_config.Config):
         ]
 
 
+class TemperatureConfig (_config.Config):
+    "Configure `calibcant` temperature operation"
+    settings = [
+        _config.FloatSetting(
+            name='sleep',
+            help=('Time between temperature measurements (in seconds) to get '
+                  'independent measurements when reading from slow sensors.'),
+            default=1),
+        ]
+
+
 class _VibrationModel (object):
     pass
 class Variance (_VibrationModel):
@@ -179,9 +160,13 @@ class VibrationConfig (_config.Config):
         ]
 
 
-class CalibrationConfig (_config.Config):
+class CalibrateConfig (_config.Config):
     "Configure a full `calibcant` calibration run"
     settings = [
+        _config.ConfigSetting(
+            name='afm',
+            help='Configure the AFM used to carry out the calibration',
+            config_class=_AFMConfig),
         _config.ConfigSetting(
             name='bump',
             help='Configure the surface bumps',
@@ -206,11 +191,6 @@ class CalibrationConfig (_config.Config):
             name='num-vibrations',
             help='Number of thermal vibration measurements.',
             default=20),
-        _config.FloatSetting(
-            name='temperature-sleep',
-            help=('Time between temperature measurements (in seconds) to get '
-                  'independent measurements when reading from slow sensors.'),
-            default=1),
         _config.FloatSetting(
             name='vibration-spacing',
             help=('Approximate distance from the surface in meters for the '