Get calibcant working with the new load_from_config-based pyafm.
[calibcant.git] / calibcant / config.py
index f8f06ec416dbee1f72898b8496adc4e158d6d476..87ec91717e7baf6484edf11fada4b66966cc71bb 100644 (file)
 # 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):
@@ -33,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
@@ -122,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):
@@ -177,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',
@@ -204,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 '