Added modular directory structure.
[hooke.git] / hooke / libhookecurve.py
old mode 100755 (executable)
new mode 100644 (file)
index 37cd1b1..44dc9d6
@@ -1,13 +1,10 @@
-#!/usr/bin/env python
-
-
 class HookeCurve(object):
-    
+
     def __init__(self,path):
         self.path=path
         self.curve=Driver()
         self.notes=''
-    
+
     def identify(self, drivers):
         '''
         identifies a curve and returns the corresponding object
@@ -18,59 +15,57 @@ class HookeCurve(object):
                 #bring on all the driver, with his load of methods etc.
                 #so we can access the whole of it.
                 self.curve=tempcurve
-                del tempcurve
                 return True
-        
-        print 'Not a recognizable curve format.'
+        print 'Not a recognizable curve format: ', self.path
         return False
-        
-        
-class Driver:
+
+
+class Driver(object):
     '''
     Base class for file format drivers.
-    
+
     To be overridden
     '''
     def __init__(self):
         self.experiment=''
         self.filetype=''
-    
+
     def is_me(self):
         '''
         This method must read the file and return True if the filetype can be managed by the driver, False if not.
         '''
         return False
-    
+
     def close_all(self):
         '''
         This method must close all the open files of the driver, explicitly.
         '''
         return None
-    
+
     def default_plots(self):
         dummy_default=PlotObject()
         dummy_default.vectors.append([[[0]],[[0]]])
         return [dummy_default]
-   
 
-class PlotObject:
-    
+
+class PlotObject(object):
+
     def __init__(self):
-        
+
         '''
         the plot destination
         0=top
         1=bottom
         '''
-        self.destination=0 
-        
+        self.destination=0
+
         '''
         self.vectors is a multidimensional array:
         self.vectors[0]=plot1
         self.vectors[1]=plot2
         self.vectors[2]=plot3
         etc.
-        
+
         2 curves in a x,y plot are:
         [[[x1],[y1]],[[x2],[y2]]]
         for example:
@@ -87,31 +82,31 @@ class PlotObject:
         self.units is simpler. for each plot with N axes (x,y,z...) only N labels
         can be made, regardless of the number of superimposed plots
         so units for the double plot above is: [unitx, unity]
-        
+
         units are strings
         '''
         self.units=['','']
-        
+
         '''
         xaxes and yaxes directions. 0,0 means the common +X=right, +Y=top directions
         '''
         self.xaxes=0
         self.yaxes=0
-        
-        self.title='' #title 
-        
+
+        self.title='' #title
+
         '''
         styles: defines what is the style of the current plots. If undefined or None, it is line plot.
         If an element of the list is 'scatter', the corresponding dataset
         is drawn with scattered points and not a continuous line.
         '''
         self.styles=[]
-        
+
         '''
         colors: define what is the colour of the current plots
         '''
         self.colors=[]
-        
+
     def add_set(self,x,y):
         '''
         Adds an x,y data set to the vectors.
@@ -120,19 +115,19 @@ class PlotObject:
         self.vectors[-1].append(x)
         self.vectors[-1].append(y)
         return
-    
+
     def remove_set(self,whichset):
         '''
         Removes a set
         '''
         waste=self.vectors.pop(whichset)
         return
-    
+
     def normalize_vectors(self):
         '''
         Trims the vector lengths as to be equal in a plot.
         '''
-        
+
         for index in range(0,len(self.vectors)):
             vectors_to_plot=self.vectors[index]
             lengths=[len(vector) for vector in vectors_to_plot]