@@ -643,59 +643,62 @@ def OnIntegrateAll(event):
643643 Names = G2gd .GetGPXtreeDataNames (G2frame ,['IMG ' ,])
644644 dlg = G2G .G2MultiChoiceDialog (G2frame ,'Image integration controls' ,'Select images to integrate:' ,Names )
645645 try :
646- if dlg .ShowModal () == wx .ID_OK :
647- items = dlg .GetSelections ()
648- G2frame .EnablePlot = False
649- dlgp = wx .ProgressDialog ("Elapsed time" ,"2D image integrations" ,len (items )+ 1 ,
650- style = wx .PD_ELAPSED_TIME | wx .PD_CAN_ABORT ,parent = G2frame )
651- try :
652- pId = 0
653- oldData = {'tilt' :0. ,'distance' :0. ,'rotation' :0. ,'center' :[0. ,0. ],'DetDepth' :0. ,'azmthOff' :0. ,'det2theta' :0. }
654- oldMhash = 0
655- for icnt ,item in enumerate (items ):
656- dlgp .Raise ()
657- GoOn = dlgp .Update (icnt )
658- if not GoOn [0 ]:
659- break
660- name = Names [item ]
661- G2frame .Image = G2gd .GetGPXtreeItemId (G2frame ,G2frame .root ,name )
662- CId = G2gd .GetGPXtreeItemId (G2frame ,G2frame .Image ,'Image Controls' )
663- Data = G2frame .GPXtree .GetItemPyData (CId )
664- same = True
665- for item in ['tilt' ,'distance' ,'rotation' ,'DetDepth' ,'azmthOff' ,'det2theta' ]:
666- if Data [item ] != oldData [item ]:
667- same = False
668- if (Data ['center' ][0 ] != oldData ['center' ][0 ] or
669- Data ['center' ][1 ] != oldData ['center' ][1 ]):
670- same = False
671- if not same :
672- t0 = time .time ()
673- useTA = G2img .MakeUseTA (Data ,blkSize )
674- print (' Use new image controls; new xy -> th,azm time %.3f' % (time .time ()- t0 ))
675- Masks = G2frame .GPXtree .GetItemPyData (
676- G2gd .GetGPXtreeItemId (G2frame ,G2frame .Image ,'Masks' ))
677- Mhash = copy .deepcopy (Masks )
678- Mhash .pop ('Thresholds' )
679- Mhash = hash (str (Mhash ))
680- if Mhash != oldMhash :
681- t0 = time .time ()
682- useMask = G2img .MakeUseMask (Data ,Masks ,blkSize )
683- print (' Use new mask; make mask time: %.3f' % (time .time ()- t0 ))
684- oldMhash = Mhash
685- image = GetImageZ (G2frame ,Data )
686- if not Masks ['SpotMask' ]['spotMask' ] is None :
687- image = ma .array (image ,mask = Masks ['SpotMask' ]['spotMask' ])
688- G2frame .Integrate = G2img .ImageIntegrate (image ,Data ,Masks ,blkSize ,useTA = useTA ,useMask = useMask )
689- del image #force cleanup
690- pId = G2IO .SaveIntegration (G2frame ,CId ,Data )
691- oldData = Data
692- finally :
693- dlgp .Destroy ()
694- G2frame .EnablePlot = True
695- if pId :
696- G2frame .GPXtree .SelectItem (pId )
697- G2frame .GPXtree .Expand (pId )
698- G2frame .PatternId = pId
646+ if dlg .ShowModal () != wx .ID_OK : return
647+ items = dlg .GetSelections ()
648+ G2frame .EnablePlot = False
649+ dlgp = wx .ProgressDialog ("Elapsed time" ,"2D image integrations" ,len (items )+ 1 ,
650+ style = wx .PD_ELAPSED_TIME | wx .PD_CAN_ABORT ,parent = G2frame )
651+ try :
652+ pId = 0
653+ oldData = {'tilt' :0. ,'distance' :0. ,'rotation' :0. ,'center' :[0. ,0. ],'DetDepth' :0. ,'azmthOff' :0. ,'det2theta' :0. }
654+ oldMhash = 0
655+ for icnt ,item in enumerate (items ):
656+ dlgp .Raise ()
657+ GoOn = dlgp .Update (icnt )
658+ if not GoOn [0 ]:
659+ break
660+ name = Names [item ]
661+ G2frame .Image = G2gd .GetGPXtreeItemId (G2frame ,G2frame .root ,name )
662+ CId = G2gd .GetGPXtreeItemId (G2frame ,G2frame .Image ,'Image Controls' )
663+ Data = G2frame .GPXtree .GetItemPyData (CId )
664+ same = True
665+ for item in ['tilt' ,'distance' ,'rotation' ,'DetDepth' ,'azmthOff' ,'det2theta' ]:
666+ if Data [item ] != oldData [item ]:
667+ same = False
668+ if (Data ['center' ][0 ] != oldData ['center' ][0 ] or
669+ Data ['center' ][1 ] != oldData ['center' ][1 ]):
670+ same = False
671+ if not same :
672+ t0 = time .time ()
673+ useTA = G2img .MakeUseTA (Data ,blkSize )
674+ print (' Use new image controls; new xy -> th,azm time %.3f' % (time .time ()- t0 ))
675+ Masks = G2frame .GPXtree .GetItemPyData (
676+ G2gd .GetGPXtreeItemId (G2frame ,G2frame .Image ,'Masks' ))
677+ Mhash = copy .deepcopy (Masks )
678+ Mhash .pop ('Thresholds' )
679+ Mhash = hash (str (Mhash ))
680+ if Mhash != oldMhash :
681+ t0 = time .time ()
682+ useMask = G2img .MakeUseMask (Data ,Masks ,blkSize )
683+ savedMask = copy .deepcopy (useMask )
684+ print (' Use new mask; make mask time: %.3f' % (time .time ()- t0 ))
685+ oldMhash = Mhash
686+ else :
687+ useMask = copy .deepcopy (savedMask )
688+ image = GetImageZ (G2frame ,Data )
689+ if not Masks ['SpotMask' ]['spotMask' ] is None :
690+ image = ma .array (image ,mask = Masks ['SpotMask' ]['spotMask' ])
691+ G2frame .Integrate = G2img .ImageIntegrate (image ,Data ,Masks ,blkSize ,useTA = useTA ,useMask = useMask )
692+ del image #force cleanup
693+ pId = G2IO .SaveIntegration (G2frame ,CId ,Data )
694+ oldData = Data
695+ finally :
696+ dlgp .Destroy ()
697+ G2frame .EnablePlot = True
698+ if pId :
699+ G2frame .GPXtree .SelectItem (pId )
700+ G2frame .GPXtree .Expand (pId )
701+ G2frame .PatternId = pId
699702 finally :
700703 dlg .Destroy ()
701704
0 commit comments