Added README and reorganized directory structure (breaks code)
[hooke.git] / hooke / plugin / cut.py
1 # -*- coding: utf-8 -*-
2 class cutCommands:
3
4     def _plug_init(self):
5         self.cut_basecurrent=None
6         self.cut_basepoints=None
7
8
9
10
11     def do_cut(self,args):
12         '''
13 CUT
14         (cut.py)
15         Cut the selected signal between two points.
16         With the first parameter you have to select the signal (for FS for example
17         you can select with "0" the approacing curve and 1 for the retracting
18         curve. This depend also on how many set of data you have on the graph).
19         With the second parameter you select the output name file for the selection.
20         The data is arranged in two simple column without a header, the first column
21         is the "x" data and the second the "y".
22         -----------------
23         Syntax: distance "whatset" "namefile"
24         '''
25         if len(args)==0:
26                 print "This command need the number of the graph that you want save and a name for the output file."
27                 return
28         
29         a=args.split()
30         
31         
32         whatset=int(a[0])
33         outfile=a[1]
34         plot=self._get_displayed_plot()
35
36         print 'Select two points'
37         points=self._measure_N_points(N=2, whatset=whatset)
38         minbound=min(points[0].index, points[1].index)
39         maxbound=max(points[0].index, points[1].index)
40         boundpoints=[minbound, maxbound]
41         yarr=plot.vectors[whatset][1][boundpoints[0]:boundpoints[1]]
42         xarr=plot.vectors[whatset][0][boundpoints[0]:boundpoints[1]]
43
44         f=open(outfile,'w+')
45         for i in range(len(yarr)):
46                 f.write(str(xarr[i])+";"+str(yarr[i])+"\n")
47         f.close()
48
49
50