3 from ..libhooke import WX_GOOD
5 wxversion.select(WX_GOOD)
6 from wx import PostEvent
13 warnings.simplefilter('ignore',np.RankWarning)
15 from .. import libinput as linp
20 def do_review(self,args):
24 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.
25 By default curves are presented separated -30 nm in x and -100 pN in y.
26 Curve number one of each set is the one showing the approach.
29 review [x spacing (nm)] [y spacing (pN]
37 xgap=int(args[0])*1e-9 #scale to SI units
38 ygap=int(args[1])*1e-12
40 print 'Spacings must be numeric! Using defaults'
47 print 'Processing playlist...'
52 print 'You can stop the review at any moment by entering \'q\' you can go back ten curves entering \'b\''
53 print 'What curve no. you would like to start? (Enter for starting from the first)'
56 if skip.isdigit()==False:
60 print 'Skipping '+str(skip)+ ' curves'
63 while c < len(self.current_list):
66 #take a group of ten curves and plot them with some spacing
68 curveset=self.current_list[c:c+10]
73 multiplot=copy.deepcopy(self._get_displayed_plot(0))
74 self.current.curve.close_all()
77 if i >= len(curveset):
78 print 'End of the list'
79 print 'WARNING: maybe you want to finish!'
82 if not nextitem.identify(self.drivers):
84 nextplot=self.plotmanip_correct(nextitem.curve.default_plots()[0],nextitem)
85 nextvect=nextplot.vectors
86 nextitem.curve.close_all()
91 ymedian=np.median(nexty)
93 for j in range(0,len(nextx)):
94 nextx[j]=nextx[j]+i*xgap
95 nexty[j]=nexty[j]+i*ygap-ymedian
96 multiplot.add_set(nextx,nexty)
97 multiplot.styles.append('lines')
98 multiplot.colors.append(None)
100 self._send_plot([multiplot])
103 print 'Which ones you want to keep?'
107 print 'Going back ten curves'
110 print 'We are already at the start'
116 for i in keep.split():
117 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
118 keep_item=curveset[int(i)-1].path
119 if keep_item in keep_list:
120 print 'This curve ('+keep_item+') was already selected, skipping'
122 keep_list.append(keep_item)
124 print 'You entered an invalid value: '+i
128 #FIXME I don't know why the print below gives errors sometimes
130 print 'Kept '+str(len(keep_list))+' curves from '+str(min(c+i+1,len(self.current_list)))
132 print 'Display error, never mind, we continue. Below the amount of kept and total curves:'
133 print str(len(keep_list))
134 print str(len(self.current_list))
136 allok=0 #flag to keep from losing all the work in a slight mistake
138 if len(keep_list) == 0:
140 save=linp.safeinput('Do you want to save the selected curves?',['y','n'])
142 savedir=linp.safeinput('Destination directory?')
143 savedir=os.path.abspath(savedir)
144 if not os.path.isdir(savedir):
145 print 'Destination is not a directory. Try again'
151 for item in keep_list:
153 shutil.copy(item, savedir)
155 except (OSError, IOError):
156 print 'Cannot copy file. '+item+' Perhaps you gave me a wrong directory?'