4 class HookeCurve(object):
6 def __init__(self,path):
11 def identify(self, drivers):
13 identifies a curve and returns the corresponding object
15 for driver in drivers:
16 tempcurve=driver(self.path)
18 #bring on all the driver, with his load of methods etc.
19 #so we can access the whole of it.
24 print 'Not a recognizable curve format.'
30 Base class for file format drivers.
39 This method must read the file and return True if the filetype can be managed by the driver, False if not.
45 This method must close all the open files of the driver, explicitly.
49 def default_plots(self):
50 dummy_default=PlotObject()
51 dummy_default.vectors.append([[[0]],[[0]]])
52 return [dummy_default]
67 self.vectors is a multidimensional array:
73 2 curves in a x,y plot are:
74 [[[x1],[y1]],[[x2],[y2]]]
77 [[[1,2,3,4],[10,20,30,40]],[[3,6,9,12],[30,60,90,120]]]
78 x1 = self.vectors[0][0]
79 y1 = self.vectors[0][1]
80 x2 = self.vectors[1][0]
81 y2 = self.vectors[1][1]
86 self.units is simpler. for each plot with N axes (x,y,z...) only N labels
87 can be made, regardless of the number of superimposed plots
88 so units for the double plot above is: [unitx, unity]
95 xaxes and yaxes directions. 0,0 means the common +X=right, +Y=top directions
103 styles: defines what is the style of the current plots. If undefined or None, it is line plot.
104 If an element of the list is 'scatter', the corresponding dataset
105 is drawn with scattered points and not a continuous line.
109 def add_set(self,x,y):
111 Adds an x,y data set to the vectors.
113 self.vectors.append([])
114 self.vectors[-1].append(x)
115 self.vectors[-1].append(y)
118 def remove_set(self,whichset):
122 waste=self.vectors.pop(whichset)
125 def normalize_vectors(self):
127 Trims the vector lengths as to be equal in a plot.
130 for index in range(0,len(self.vectors)):
131 vectors_to_plot=self.vectors[index]
132 lengths=[len(vector) for vector in vectors_to_plot]
133 if min(lengths) != max(lengths):
134 for indexplot in range(0,len(vectors_to_plot)):
135 self.vectors[index][indexplot] = self.vectors[index][indexplot][0:min(lengths)]