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.
40 This method must read the file and return True if the filetype can be managed by the driver, False if not.
46 This method must close all the open files of the driver, explicitly.
50 def default_plots(self):
51 dummy_default=PlotObject()
52 dummy_default.vectors.append([[[0]],[[0]]])
53 return [dummy_default]
68 self.vectors is a multidimensional array:
74 2 curves in a x,y plot are:
75 [[[x1],[y1]],[[x2],[y2]]]
78 [[[1,2,3,4],[10,20,30,40]],[[3,6,9,12],[30,60,90,120]]]
79 x1 = self.vectors[0][0]
80 y1 = self.vectors[0][1]
81 x2 = self.vectors[1][0]
82 y2 = self.vectors[1][1]
87 self.units is simpler. for each plot with N axes (x,y,z...) only N labels
88 can be made, regardless of the number of superimposed plots
89 so units for the double plot above is: [unitx, unity]
96 xaxes and yaxes directions. 0,0 means the common +X=right, +Y=top directions
104 styles: defines what is the style of the current plots. If undefined or None, it is line plot.
105 If an element of the list is 'scatter', the corresponding dataset
106 is drawn with scattered points and not a continuous line.
111 colors: define what is the colour of the current plots
115 def add_set(self,x,y):
117 Adds an x,y data set to the vectors.
119 self.vectors.append([])
120 self.vectors[-1].append(x)
121 self.vectors[-1].append(y)
124 def remove_set(self,whichset):
128 waste=self.vectors.pop(whichset)
131 def normalize_vectors(self):
133 Trims the vector lengths as to be equal in a plot.
136 for index in range(0,len(self.vectors)):
137 vectors_to_plot=self.vectors[index]
138 lengths=[len(vector) for vector in vectors_to_plot]
139 if min(lengths) != max(lengths):
140 for indexplot in range(0,len(vectors_to_plot)):
141 self.vectors[index][indexplot] = self.vectors[index][indexplot][0:min(lengths)]