4 Alberto Gomez-Casado (c) 2010 University of Twente
7 from ..libhooke import WX_GOOD
9 wxversion.select(WX_GOOD)
10 from wx import PostEvent
17 warnings.simplefilter('ignore',np.RankWarning)
19 from .. import libinput as linp
24 def do_review(self,args):
28 Presents curves (in current playlist) in groups of ten. User can indicate which curves will be selected to be saved in a separate directory for further analysis.
29 By default curves are presented separated -30 nm in x and -100 pN in y.
30 Curve number one of each set is the one showing the approach.
33 review [x spacing (nm)] [y spacing (pN]
41 xgap=int(args[0])*1e-9 #scale to SI units
42 ygap=int(args[1])*1e-12
44 print 'Spacings must be numeric! Using defaults'
51 print 'Processing playlist...'
56 print 'You can stop the review at any moment by entering \'q\' you can go back ten curves entering \'b\''
57 print 'What curve no. you would like to start? (Enter for starting from the first)'
60 if skip.isdigit()==False:
64 print 'Skipping '+str(skip)+ ' curves'
67 while c < len(self.current_list):
70 #take a group of ten curves and plot them with some spacing
72 curveset=self.current_list[c:c+10]
77 multiplot=copy.deepcopy(self._get_displayed_plot(0))
78 self.current.curve.close_all()
81 if i >= len(curveset):
82 print 'End of the list'
83 print 'WARNING: maybe you want to finish!'
86 if not nextitem.identify(self.drivers):
88 nextplot=self.plotmanip_correct(nextitem.curve.default_plots()[0],nextitem)
89 nextvect=nextplot.vectors
90 nextitem.curve.close_all()
95 ymedian=np.median(nexty)
97 for j in range(0,len(nextx)):
98 nextx[j]=nextx[j]+i*xgap
99 nexty[j]=nexty[j]+i*ygap-ymedian
100 multiplot.add_set(nextx,nexty)
101 multiplot.styles.append('lines')
102 multiplot.colors.append(None)
104 self._send_plot([multiplot])
107 print 'Which ones you want to keep?'
111 print 'Going back ten curves'
114 print 'We are already at the start'
120 for i in keep.split():
121 if i.isdigit() and int(i)>0 and int(i)<11: #if it is not digit the int() call is never made, so no exception should be happening
122 keep_item=curveset[int(i)-1].path
123 if keep_item in keep_list:
124 print 'This curve ('+keep_item+') was already selected, skipping'
126 keep_list.append(keep_item)
128 print 'You entered an invalid value: '+i
132 #FIXME I don't know why the print below gives errors sometimes
134 print 'Kept '+str(len(keep_list))+' curves from '+str(min(c+i+1,len(self.current_list)))
136 print 'Display error, never mind, we continue. Below the amount of kept and total curves:'
137 print str(len(keep_list))
138 print str(len(self.current_list))
140 allok=0 #flag to keep from losing all the work in a slight mistake
142 if len(keep_list) == 0:
144 save=linp.safeinput('Do you want to save the selected curves?',['y','n'])
146 savedir=linp.safeinput('Destination directory?')
147 savedir=os.path.abspath(savedir)
148 if not os.path.isdir(savedir):
149 print 'Destination is not a directory. Try again'
155 for item in keep_list:
157 shutil.copy(item, savedir)
159 except (OSError, IOError):
160 print 'Cannot copy file. '+item+' Perhaps you gave me a wrong directory?'