Changeset 2339
- Timestamp:
- Jun 22, 2016 5:51:56 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r2322 r2339 863 863 864 864 def ImageIntegrate(image,data,masks,blkSize=128,dlg=None,returnN=False): 865 ' Needs a doc string' #for q, log(q) bins need data['binType']865 'Integrate an image; called from OnIntegrateAll and OnIntegrate in G2imgGUI' #for q, log(q) bins need data['binType'] 866 866 import histogram2d as h2d 867 867 print 'Begin image integration' 868 CancelPressed = False 868 869 LUtth = np.array(data['IOtth']) 869 870 LRazm = np.array(data['LRazimuth'],dtype=np.float64) … … 905 906 if dlg: 906 907 pause = dlg.Update(Nup) 908 if not pause[0]: CancelPressed = True 907 909 Block = image[iBeg:iFin,jBeg:jFin] 908 910 t0 = time.time() … … 913 915 if dlg: 914 916 pause = dlg.Update(Nup) 917 if not pause[0]: CancelPressed = True 915 918 tax = np.where(tax > LRazm[1],tax-360.,tax) #put azm inside limits if possible 916 919 tax = np.where(tax < LRazm[0],tax+360.,tax) … … 935 938 if dlg: 936 939 pause = dlg.Update(Nup) 940 if not pause[0]: CancelPressed = True 937 941 t0 = time.time() 938 942 NST = np.array(NST,dtype=np.float) … … 959 963 if dlg: 960 964 pause = dlg.Update(Nup) 965 if not pause[0]: CancelPressed = True 961 966 times[4] += time.time()-t0 962 967 print 'Step times: \n apply masks %8.3fs xy->th,azm %8.3fs fill map %8.3fs \ … … 965 970 print 'Integration complete' 966 971 if returnN: #As requested by Steven Weigand 967 return H0,H1,H2,NST, not pause[0]972 return H0,H1,H2,NST,CancelPressed 968 973 else: 969 return H0,H1,H2, not pause[0]974 return H0,H1,H2,CancelPressed 970 975 971 976 def MakeStrStaRing(ring,Image,Controls): -
trunk/GSASIIimgGUI.py
r2338 r2339 228 228 Nup = nXBlks*nYBlks*3+1 #exact count expected so AUTO_HIDE works! 229 229 if IntegrateOnly: 230 pdlg = wx.ProgressDialog("Elapsed time","2D image integration\n Cancel to pause",230 pdlg = wx.ProgressDialog("Elapsed time","2D image integration\nPress Cancel to pause after current image", 231 231 Nup,style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT) 232 232 else: … … 236 236 sumImg = GetImageZ(G2frame,data) 237 237 G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,pdlg) 238 G2frame.PauseIntegration = G2frame.Integrate[-1] 238 239 del sumImg #force cleanup 239 240 Id = G2IO.SaveIntegration(G2frame,G2frame.PickId,data,(event is None)) … … 245 246 pdlg.Destroy() 246 247 for item in G2frame.MakePDF: item.Enable(True) 247 G2frame.PauseIntegration = G2frame.Integrate[-1]248 248 249 249 def OnIntegrateAll(event): … … 404 404 S = File.readline() 405 405 continue 406 [key,val] = S [:-1].split(':',1)406 [key,val] = S.strip().split(':',1) 407 407 if key in ['type','calibrant','binType','SampleShape',]: #strings 408 408 save[key] = val … … 1324 1324 S = File.readline() 1325 1325 continue 1326 [key,val] = S [:-1].split(':')1326 [key,val] = S.strip().split(':',1) 1327 1327 if key in ['Points','Rings','Arcs','Polygons','Frames','Thresholds']: 1328 1328 if ignoreThreshold and key == 'Thresholds': … … 1983 1983 S = File.readline() 1984 1984 continue 1985 [key,val] = S [:-1].split(':')1985 [key,val] = S.strip().split(':',1) 1986 1986 if key in ['Points','Rings','Arcs','Polygons','Frames','Thresholds']: 1987 1987 save[key] = eval(val) … … 2004 2004 S = File.readline() 2005 2005 continue 2006 [key,val] = S [:-1].split(':')2006 [key,val] = S.strip().split(':',1) 2007 2007 if key in ['type','calibrant','binType','SampleShape',]: #strings 2008 2008 save[key] = val … … 2105 2105 if self.btnstart.GetLabel() != 'Pause': 2106 2106 self.btnstart.SetLabel('Pause') 2107 self.Status.SetStatusText('Press Pause to delay integration or Reset to prepare to reintegrate all images') 2107 2108 if self.timer.IsRunning(): self.timer.Stop() 2108 2109 self.PreventReEntryTimer = False 2109 2110 self.StartLoop() 2110 self.OnTimerLoop(None) # run once immediately and again after delay 2111 self.timer.Start(int(1000*PollTime),oneShot=False) 2112 self.Status.SetStatusText('Press Pause to delay integration or Reset to prepare to reintegrate all images') 2113 else: 2114 self.btnstart.SetLabel('Resume') 2115 if self.timer.IsRunning(): self.timer.Stop() 2116 print('\nPausing autointegration\n') 2117 self.Status.SetStatusText('Press Resume to continue integration or Reset to prepare to reintegrate all images') 2118 self.Pause = True 2119 2111 self.OnTimerLoop(None) # run once immediately 2112 if not self.Pause: 2113 # no pause, so start timer to check for new files 2114 self.timer.Start(int(1000*PollTime),oneShot=False) 2115 return 2116 # we will get to this point if Paused 2117 self.OnPause() 2118 2120 2119 def OnReset(event): 2121 2120 '''Called when Reset button is pressed. This stops the … … 2302 2301 self.btnstart.Bind(wx.EVT_BUTTON, OnStart) 2303 2302 sizer.Add(self.btnstart) 2304 btnstop= wx.Button(mnpnl, wx.ID_ANY, "Reset")2305 btnstop.Bind(wx.EVT_BUTTON, OnReset)2306 sizer.Add( btnstop)2303 self.btnreset = wx.Button(mnpnl, wx.ID_ANY, "Reset") 2304 self.btnreset.Bind(wx.EVT_BUTTON, OnReset) 2305 sizer.Add(self.btnreset) 2307 2306 sizer.Add((20,-1),wx.EXPAND,1) 2308 btnquit= wx.Button(mnpnl, wx.ID_ANY, "Close")2309 btnquit.Bind(wx.EVT_BUTTON, OnQuit)2310 sizer.Add( btnquit)2307 self.btnclose = wx.Button(mnpnl, wx.ID_ANY, "Close") 2308 self.btnclose.Bind(wx.EVT_BUTTON, OnQuit) 2309 sizer.Add(self.btnclose) 2311 2310 sizer.Add((20,-1)) 2312 2311 mnsizer.Add(sizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP,5) … … 2354 2353 return 2355 2354 2355 def OnPause(self): 2356 '''Respond to Pause, changes text on button/Status line, if needed 2357 Stops timer 2358 self.Pause should already be True 2359 ''' 2360 if self.timer.IsRunning(): self.timer.Stop() 2361 if self.btnstart.GetLabel() == 'Restart': 2362 return 2363 if self.btnstart.GetLabel() != 'Resume': 2364 print('\nPausing autointegration\n') 2365 self.btnstart.SetLabel('Resume') 2366 self.Status.SetStatusText( 2367 'Press Resume to continue integration or Reset to prepare to reintegrate all images') 2368 self.Pause = True 2369 2356 2370 def IntegrateImage(self,img): 2357 2371 '''Integrates a single image''' … … 2401 2415 print('writing file '+fil+dfmt) 2402 2416 G2IO.ExportPowder(G2frame,treename,fil,dfmt) 2417 2418 def EnableButtons(self,flag): 2419 '''Turns the buttons at window bottom "off" when integration is running 2420 ''' 2421 for item in (self.btnstart,self.btnreset,self.btnclose): 2422 item.Enable(flag) 2423 if flag: 2424 self.btnstart.SetLabel('Pause') 2425 else: 2426 self.btnstart.SetLabel('(running)') 2427 wx.Yield() 2403 2428 2404 2429 def ResetFromTable(self,dist): … … 2531 2556 # update masks from master w/o Thresholds 2532 2557 ImageMasks.update(self.ImageMasks) 2533 self.IntegrateImage(img) 2534 self.Pause = G2frame.PauseIntegration 2558 self.EnableButtons(False) 2559 try: 2560 self.IntegrateImage(img) 2561 finally: 2562 self.EnableButtons(True) 2563 self.Pause |= G2frame.PauseIntegration 2535 2564 self.G2frame.oldImagefile = '' # mark image as changed; reread as needed 2536 2565 wx.Yield() … … 2538 2567 wx.Yield() 2539 2568 if self.Pause: 2540 self.btnstart.SetLabel('Resume') 2541 if self.timer.IsRunning(): self.timer.Stop() 2542 print('\nPausing autointegration\n') 2543 self.Status.SetStatusText('Press Resume to continue integration or Reset to prepare to reintegrate all images') 2569 self.OnPause() 2570 self.PreventReEntryTimer = False 2544 2571 return 2545 2572 … … 2561 2588 # now integrate the image 2562 2589 img = G2frame.PatternTree.GetItemText(imgId) 2563 self.IntegrateImage(img) 2590 self.EnableButtons(False) 2591 try: 2592 self.IntegrateImage(img) 2593 finally: 2594 self.EnableButtons(True) 2595 self.Pause |= G2frame.PauseIntegration 2564 2596 self.G2frame.oldImagefile = '' # mark image as changed; reread as needed 2565 2597 wx.Yield() 2566 2598 self.ShowMatchingFiles(self.params['filter']) 2567 2599 wx.Yield() 2568 self.Pause = G2frame.PauseIntegration2569 print 'pause',self.Pause2570 2600 if self.Pause: 2571 self.btnstart.SetLabel('Resume') 2572 if self.timer.IsRunning(): self.timer.Stop() 2573 print('\nPausing autointegration\n') 2574 self.Status.SetStatusText('Press Resume to continue integration or Reset to prepare to reintegrate all images') 2601 self.OnPause() 2575 2602 break 2576 2603
Note: See TracChangeset
for help on using the changeset viewer.