Use 'simple' conversion handler to process 'file'-type JPK conversions.
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 02:17:26 +0000 (22:17 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Aug 2010 02:17:26 +0000 (22:17 -0400)
Michael Haggerty at JPK pointed out that the information from the
external file was already stored in the curve file.  He also confirmed
that my interpretation of the external calibration file format was
correct, although that no longer matters now that I've just removed
the 'file'-specific conversion code.

hooke/driver/jpk.py

index bc13761b8c5d2da637b95d9d4a53311ebdb1b5d7..30fabdf0c0817a162687fcc32e3489b5110f249b 100644 (file)
@@ -208,40 +208,17 @@ class JPKDriver (Driver):
             # the previous conversion first.
             segment = self._zip_scale_channel(
                 segment, channel, conversion_info['base-calibration-slot'],
-                info, path)
+                path=path, info=info)
         if conversion_info['type'] == 'file':
-            key = ('%s_%s_to_%s_calibration_file'
-                   % (channel_name,
-                      conversion_info['base-calibration-slot'],
-                      conversion))
-            calib_path = conversion_info['file']
-            if key in info:
-                calib_path = os.path.join(os.path.dirname(path), info[key])
-                self.logger().debug(
-                    'Overriding %s -> %s calibration for %s channel: %s'
-                    % (conversion_info['base-calibration-slot'],
-                       conversion, channel_name, calib_path))
-            if os.path.exists(calib_path):
-                with file(calib_path, 'r') as f:
-                    lines = [x.strip() for x in f.readlines()]
-                    f.close()
-                calib = {  # I've emailed JPK to confirm this file format.
-                    'title':lines[0],
-                    'multiplier':float(lines[1]),
-                    'offset':float(lines[2]),
-                    'unit':lines[3],
-                    'note':'\n'.join(lines[4:]),
-                    }
-                segment[:,channel] = (segment[:,channel] * calib['multiplier']
-                                      + calib['offset'])
-                segment.info['columns'][channel] = (
-                    '%s (%s)' % (channel_name, calib['unit']))
-                return segment
-            else:
-                self.logger().warn(
-                    'Skipping %s -> %s calibration for %s channel.  Calibration file %s not found'
-                    % (conversion_info['base-calibration-slot'],
-                       conversion, channel_name, calib_path))
+            # Michael Haggerty at JPK points out that the conversion
+            # information stored in the external file is reproduced in
+            # the force curve file.  So there is no need to actually
+            # read `conversion_info['file']`.  In fact, the data there
+            # may have changed with future calibrations, while the
+            # information stored directly in conversion_info retains
+            # the calibration information as it was when the experiment
+            # was performed.
+            pass  # Fall through to 'simple' conversion processing.
         else:
             assert conversion_info['type'] == 'simple', conversion_info['type']
         assert conversion_info['scaling']['type'] == 'linear', \