First attempt at temperature extraction for MFP3D (+ convert spring constant to float).
authorW. Trevor King <wking@drexel.edu>
Fri, 20 Aug 2010 13:14:11 +0000 (09:14 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 20 Aug 2010 13:14:11 +0000 (09:14 -0400)
hooke/driver/mfp3d.py

index ccffd5e8de798f1e7afb1d9fa9db6e5f00ae394b..39ea3d36d8e1b80b05398e9ee19a7a027f092fde 100644 (file)
@@ -103,7 +103,8 @@ class MFP3DDriver (Driver):
             'raw info':{'bin':bin_info,
                         'wave':wave_info},
             'time':wave_info['creationDate'],
-            'spring constant (N/m)':note['SpringConstant'],
+            'spring constant (N/m)':float(note['SpringConstant']),
+            'temperature (K)':self._temperature(note),
             }
         # MFP3D's native data dimensions match Hooke's (<point>, <column>) layout.
         approach = self._scale_block(data[:wave_info['npnts']/2,:], info, 'approach')
@@ -159,3 +160,41 @@ class MFP3DDriver (Driver):
             ret[:,t_scol] = data[:,t_rcol]
 
         return ret
+
+    def _temperature(self, note):
+        # I'm not sure which field we should be using here.  Options are:
+        #   StartHeadTemp
+        #   StartScannerTemp
+        #   StartBioHeaterTemp
+        #   EndScannerTemp
+        #   EndHeadTemp
+        # I imagine the 'Start*Temp' fields were measured at
+        # 'StartTempSeconds' at the beginning of a series of curves,
+        # while our particular curve was initiated at 'Seconds'.
+        #   python -c "from hooke.hooke import Hooke;
+        #              h=Hooke();
+        #              h.run_command('load playlist',
+        #                  {'input':'test/data/vclamp_mfp3d/playlist'});
+        #              x = [(int(c.info['raw info']['bin']['note']['Seconds'])
+        #                    - int(c.info['raw info']['bin']['note']['StartTempSeconds']))
+        #                   for c in h.playlists.current().items()];
+        #              print 'average', float(sum(x))/len(x);
+        #              print 'range', min(x), max(x);
+        #              print x"
+        # For the Line*Point*.ibw series, the difference increases slowly
+        #   46, 46, 47, 47, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54,...
+        # However, for the Image*.ibw series, the difference increase
+        # is much faster:
+        #   21, 38, 145, 150, 171, 181
+        # This makes the 'Start*Temp' fields less and less relevant as
+        # the experiment continues.  Still, I suppose it's better than
+        # nothing.
+        #
+        # The 'Thermal' fields seem to be related to cantilever calibration.
+        celsius = unicode(note['StartHeadTemp'], 'latin-1')
+        if celsius.endswith(u' \u00b0C'):
+            number = celsius.split(None, 1)[0]
+            return float(number) + 273.15  # Convert to Kelvin.
+        else:
+            raise NotImplementedError(
+                'unkown temperature format: %s' % repr(celsius))