Add `default-temperature` option to AFMConfig.
authorW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 21:21:01 +0000 (17:21 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 21:21:01 +0000 (17:21 -0400)
pyafm/afm.py
pyafm/config.py

index a68b77219334a72345209796b1211139353f50fd..cac626941e0de556353a5bfbc8b33657bf3905ff 100644 (file)
@@ -147,11 +147,14 @@ class AFM (object):
       device: /dev/ttyS0
       baudrate: 9600
       max-current: 0.0
+    fallback-temperature: 295.15
     far: 3e-05
 
     >>> pyafm.storage.save_afm(afm=afm, filename=filename)
     >>> pprint_HDF5(filename=filename)  # doctest: +REPORT_UDIFF
     /
+      <HDF5 dataset "fallback-temperature": shape (), type "<f8">
+        295.15
       <HDF5 dataset "far": shape (), type "<f8">
         3e-05
       <HDF5 dataset "main-axis": shape (), type "|S1">
@@ -314,6 +317,7 @@ class AFM (object):
         """
         if hasattr(self.temperature, 'get_temperature'):
             return self.temperature.get_temperature()
+        return self.config['default-temperature']
 
     def move_just_onto_surface(self, depth=-50e-9, setpoint=2,
                                min_slope_ratio=10, far=200, steps=20,
index c3af39a543c29f3f8fdab6be93cae6ecce06ea55..dca08a026fc6646c05bd7063ea89d606171fa312 100644 (file)
@@ -169,6 +169,11 @@ class AFMConfig (_config.Config):
             help='Configure the underlying temperature sensor.',
             config_class=TemperatureConfig,
             default=None),
+        _config.FloatSetting(
+            name='fallback-temperature',
+            help=('Temperature in Kelvin to use if no temperature sensor is '
+                  'configured.'),
+            default=295.15),
         _config.FloatSetting(
             name='far',
             help=('Approximate distance in meters to move away to get "far" '