Changeset 3173 for trunk/GSASIIimgGUI.py


Ignore:
Timestamp:
Dec 5, 2017 3:23:50 PM (5 years ago)
Author:
vondreele
Message:

ensure limits on multiple powder patterns from integration are independent
Integrate All & Auto integrate now reuse x,y --> 2th,azm maps if image controls unchanged - much faster multiple integrations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r3172 r3173  
    143143##### Image Controls
    144144################################################################################                   
    145 def UpdateImageControls(G2frame,data,masks,IntegrateOnly=False):
     145blkSize = 1024   #this seems to be optimal; will break in polymask if >1024
     146def UpdateImageControls(G2frame,data,masks,useTA=None,IntegrateOnly=False):
    146147    '''Shows and handles the controls on the "Image Controls"
    147148    data tree entry
     
    237238        MaxSizer.GetChildren()[5].Window.SetValue(Imin)   #tricky
    238239         
    239     def OnIntegrate(event):
     240    def OnIntegrate(event,useTA=None):
    240241        '''Integrate image in response to a menu event or from the AutoIntegrate
    241242        dialog. In the latter case, event=None.
     
    243244        '''
    244245        CleanupMasks(masks)
    245         blkSize = 1024   #this seems to be optimal; will break in polymask if >1024
    246 #        blkSize = 128   #this seems to be optimal; will break in polymask if >1024
    247246        sumImg = GetImageZ(G2frame,data)
    248247        wx.BeginBusyCursor()
    249248        try:
    250             G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize)           
     249            G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,useTA=useTA)           
    251250        finally:
    252251            wx.EndBusyCursor()   
     
    269268                    style = wx.PD_ELAPSED_TIME|wx.PD_CAN_ABORT)
    270269                try:
     270                    pId = 0
     271                    oldData = {'tilt':0.,'distance':0.,'rotation':0.,'center':[0.,0.],'DetDepth':0.,'azmthOff':0.}
    271272                    for icnt,item in enumerate(items):
    272273                        GoOn = dlgp.Update(icnt)
     
    277278                        CId = G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls')
    278279                        Data = G2frame.GPXtree.GetItemPyData(CId)
     280                        same = True
     281                        for item in ['tilt','distance','rotation','center','DetDepth','azmthOff']:
     282                            if Data[item] != oldData[item]:
     283                                same = False
     284                        if not same:
     285                            print('Use new image controls')
     286                            useTA = G2img.MakeUseTA(Data,blkSize)
    279287                        Masks = G2frame.GPXtree.GetItemPyData(
    280288                            G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Masks'))
    281289                        image = GetImageZ(G2frame,Data)
    282                         blkSize = 128   #this seems to be optimal; will break in polymask if >1024
    283                         G2frame.Integrate = G2img.ImageIntegrate(image,Data,Masks,blkSize)
     290                        G2frame.Integrate = G2img.ImageIntegrate(image,Data,Masks,blkSize,useTA=useTA)
    284291                        del image   #force cleanup
    285292                        pId = G2IO.SaveIntegration(G2frame,CId,Data)
     293                        oldData = Data
    286294                finally:   
    287295                    dlgp.Destroy()
    288296                    G2frame.EnablePlot = True
    289                     G2frame.GPXtree.SelectItem(pId)
    290                     G2frame.GPXtree.Expand(pId)
    291                     G2frame.PatternId = pId
     297                    if pId:
     298                        G2frame.GPXtree.SelectItem(pId)
     299                        G2frame.GPXtree.Expand(pId)
     300                        G2frame.PatternId = pId
    292301        finally:
    293302            dlg.Destroy()
     
    11841193   
    11851194    if IntegrateOnly:
    1186         OnIntegrate(None)
     1195        OnIntegrate(None,useTA=useTA)
    11871196        return
    11881197   
     
    27152724        self.Pause = True
    27162725           
    2717     def IntegrateImage(self,img):
     2726    def IntegrateImage(self,img,useTA=None):
    27182727        '''Integrates a single image. Ids for created PWDR entries (more than one is possible)
    27192728        are placed in G2frame.IntgOutList
     
    27412750        # simulate a Image Controls press, since that is where the
    27422751        # integration is hidden
    2743         UpdateImageControls(G2frame,data,masks,IntegrateOnly=True)
     2752        UpdateImageControls(G2frame,data,masks,useTA=useTA,IntegrateOnly=True)
    27442753        G2frame.IntegratedList.append(img) # note this as integrated
    27452754        # split name and control number
     
    29192928        This is called only after the "Start" button is pressed (then its label reads "Pause").
    29202929        '''
    2921         def AutoIntegrateImage(imgId):
     2930        def AutoIntegrateImage(imgId,useTA=None):
    29222931            '''Integrates an image that has been read into the data tree and updates the
    29232932            AutoInt window.
     
    29362945            self.EnableButtons(False)
    29372946            try:
    2938                 self.IntegrateImage(img)
     2947                self.IntegrateImage(img,useTA=useTA)
    29392948            finally:
    29402949                self.EnableButtons(True)
     
    30223031        # integrate the images that have already been read in, but
    30233032        # have not yet been processed           
     3033        oldData = {'tilt':0.,'distance':0.,'rotation':0.,'center':[0.,0.],'DetDepth':0.,'azmthOff':0.}
    30243034        for img in G2gd.GetGPXtreeDataNames(G2frame,['IMG ']):
    30253035            imgId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,img)
     
    30293039            # skip if already integrated
    30303040            if img in G2frame.IntegratedList: continue
    3031             AutoIntegrateImage(imgId)
    3032             #self.Pause |= G2frame.PauseIntegration
    3033             #if self.Pause:
    3034             #    self.OnPause()
    3035             #    self.PreventReEntryTimer = False
    3036             #    return
     3041            Data = G2frame.GPXtree.GetItemPyData(
     3042                G2gd.GetGPXtreeItemId(G2frame,imgId, 'Image Controls'))
     3043            same = True
     3044            for item in ['tilt','distance','rotation','center','DetDepth','azmthOff']:
     3045                if Data[item] != oldData[item]:
     3046                    same = False
     3047            if not same:
     3048                print('Use new image controls')
     3049                self.useTA = G2img.MakeUseTA(Data,blkSize)
     3050            AutoIntegrateImage(imgId,self.useTA)
     3051            oldData = Data
    30373052            if self.pdfControls: AutoComputePDF(imgId)
    30383053            self.Pause |= G2frame.PauseIntegration
     
    30463061            if newImage in imageFileList or self.Pause: continue # already read?
    30473062            for imgId in G2IO.ReadImages(G2frame,newImage):
    3048                 AutoIntegrateImage(imgId)           
    3049                 #self.Pause |= G2frame.PauseIntegration
    3050                 #if self.Pause:
    3051                 #    self.OnPause()
    3052                 #    self.PreventReEntryTimer = False
    3053                 #    return
     3063                AutoIntegrateImage(imgId,self.useTA)
    30543064                if self.pdfControls: AutoComputePDF(imgId)
    30553065                self.Pause |= G2frame.PauseIntegration
Note: See TracChangeset for help on using the changeset viewer.