Merged Rolf Schmidt's illysam branch
[hooke.git] / hooke / driver / mcs.py
index a00117ff4e59dbc3633e91fb9b591da0c2f211cc..f8208c04aea545dbfe482eeec35ff48e68feada7 100644 (file)
@@ -1,31 +1,16 @@
-# Copyright (C) 2009-2010 Allen Chen
-#                         Massimo Sandal <devicerandom@gmail.com>
-#                         W. Trevor King <wking@drexel.edu>
-#
-# This file is part of Hooke.
-#
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
-#
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke.  If not, see
-# <http://www.gnu.org/licenses/>.
-
-"""Driver for mcs fluorescence files
+# Copyright
+
+"""Driver for mcs fluorescence files.
 """
 
-from .. import curve as lhc
-from .. import libhooke as lh
+import os.path
+
+import lib.curve
+import lib.driver
+import lib.plot
 import struct
 
-class mcsDriver(lhc.Driver):
+class mcsDriver(lib.driver.Driver):
 
     def __init__(self, filename):
         '''
@@ -53,32 +38,53 @@ class mcsDriver(lhc.Driver):
         self.filetype = 'mcs'
         self.experiment = 'smfluo'
 
-    def is_me(self):
-        if self.filename[-3:].lower()=='mcs':
-            return True
-        else:
-            return False
-
     def close_all(self):
         self.filedata.close()
         self.filebluedata.close()
 
-
     def default_plots(self):
+        #TODO: rename blue and red data to something more appropriate if possible
         red_data=self.read_file(self.reddata)
         blue_data=self.read_file(self.bluedata)
         blue_data=[-1*float(item) for item in blue_data] #visualize blue as "mirror" of red
 
-        main_plot=lhc.PlotObject()
-        main_plot.add_set(range(len(red_data)),red_data)
-        main_plot.add_set(range(len(blue_data)),blue_data)
-        main_plot.normalize_vectors()
-        main_plot.units=['time','count']  #FIXME: if there's an header saying something about the time count, should be used
-        main_plot.destination=0
-        main_plot.title=self.filename
-        main_plot.colors=['red','blue']
+        extension = lib.curve.Curve()
+        retraction = lib.curve.Curve()
+
+        extension.color = 'red'
+        extension.label = 'extension'
+        extension.style = 'plot'
+        extension.title = 'Force curve'
+        #FIXME: if there's an header saying something about the time count, should be used
+        #TODO: time is not really a unit
+        extension.units.x = 'time'
+        extension.units.y = 'count'
+        extension.x = range(len(red_data))
+        extension.y = red_data
+        retraction.color = 'blue'
+        retraction.label = 'retraction'
+        retraction.style = 'plot'
+        retraction.title = 'Force curve'
+        #FIXME: if there's an header saying something about the time count, should be used
+        #TODO: time is not really a unit
+        retraction.units.x = 'time'
+        retraction.units.y = 'count'
+        retraction.x = range(len(blue_data))
+        retraction.y = blue_data
+
+        plot = lib.plot.Plot()
+        plot.title = os.path.basename(self.filename)
+        plot.curves.append(extension)
+        plot.curves.append(retraction)
+
+        plot.normalize()
+        return plot
 
-        return [main_plot]
+    def is_me(self):
+        if self.filename[-3:].lower()=='mcs':
+            return True
+        else:
+            return False
 
     def read_file(self, raw_data):
         real_data=[]