From: W. Trevor King Date: Fri, 20 Aug 2010 13:14:11 +0000 (-0400) Subject: First attempt at temperature extraction for MFP3D (+ convert spring constant to float). X-Git-Url: http://git.tremily.us/?p=hooke.git;a=commitdiff_plain;h=98a9809cab15c41b807e52adf99ca8769203faad First attempt at temperature extraction for MFP3D (+ convert spring constant to float). --- diff --git a/hooke/driver/mfp3d.py b/hooke/driver/mfp3d.py index ccffd5e..39ea3d3 100644 --- a/hooke/driver/mfp3d.py +++ b/hooke/driver/mfp3d.py @@ -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 (, ) 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))