Changeset 2310


Ignore:
Timestamp:
Jun 7, 2016 9:52:48 AM (5 years ago)
Author:
vondreele
Message:

Add two new image control menu items:
1) Recalibrate all - does a global recalibration of all/selected images
2) Copy Selected - copies selected Image Controls to all/selected images

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2301 r2310  
    9393] = [wx.NewId() for item in range(3)]
    9494
    95 [ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB, 
     95[ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB,wxID_IMRECALIBALL, 
    9696    wxID_IMCOPYCONTROLS, wxID_INTEGRATEALL, wxID_IMSAVECONTROLS, wxID_IMLOADCONTROLS, wxID_IMAUTOINTEG,
    97 ] = [wx.NewId() for item in range(9)]
     97    wxID_IMCOPYSELECTED,
     98] = [wx.NewId() for item in range(11)]
    9899
    99100[ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD, wxID_NEWMASKSPOT,wxID_NEWMASKARC,wxID_NEWMASKRING,
     
    17491750        self.ImageEdit.Append(help='Recalibrate detector by fitting to calibrant lines',
    17501751            id=wxID_IMRECALIBRATE, kind=wx.ITEM_NORMAL,text='Recalibrate')
     1752        self.ImageEdit.Append(help='Recalibrate all images by fitting to calibrant lines',
     1753            id=wxID_IMRECALIBALL, kind=wx.ITEM_NORMAL,text='Recalibrate all')           
    17511754        self.ImageEdit.Append(help='Clear calibration data points and rings',id=wxID_IMCLEARCALIB,
    17521755            kind=wx.ITEM_NORMAL,text='Clear calibration')
     
    17571760        self.ImageEdit.Append(help='Copy image controls to other images',
    17581761            id=wxID_IMCOPYCONTROLS, kind=wx.ITEM_NORMAL,text='Copy Controls')
     1762        self.ImageEdit.Append(help='Copy selected image controls to other images',
     1763            id=wxID_IMCOPYSELECTED, kind=wx.ITEM_NORMAL,text='Copy Selected')
    17591764        self.ImageEdit.Append(help='Save image controls to file',
    17601765            id=wxID_IMSAVECONTROLS, kind=wx.ITEM_NORMAL,text='Save Controls')
  • trunk/GSASIIimgGUI.py

    r2304 r2310  
    180180        wx.CallLater(100,UpdateImageControls,G2frame,data,masks)
    181181       
     182    def OnRecalibAll(event):
     183        Names = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
     184        dlg = G2G.G2MultiChoiceDialog(G2frame,'Image calibration controls','Select images to recalibrate:',Names)
     185        try:
     186            if dlg.ShowModal() == wx.ID_OK:
     187                items = dlg.GetSelections()
     188                G2frame.EnablePlot = False
     189                for item in items:
     190                    name = Names[item]
     191                    print 'calibrating',name
     192                    G2frame.Image = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
     193                    CId = G2gd.GetPatternTreeItemId(G2frame,G2frame.Image,'Image Controls')
     194                    Data = G2frame.PatternTree.GetItemPyData(CId)
     195                    G2frame.ImageZ = GetImageZ(G2frame,Data)
     196                    Data['setRings'] = True
     197                    Mid = G2gd.GetPatternTreeItemId(G2frame,G2frame.Image,'Masks')
     198                    Masks = G2frame.PatternTree.GetItemPyData(Mid)
     199                    G2img.ImageRecalibrate(G2frame,Data,Masks)
     200        finally:
     201            dlg.Destroy()
     202        G2plt.PlotExposedImage(G2frame,event=None)
     203        wx.CallLater(100,UpdateImageControls,G2frame,data,masks)
     204       
    182205    def OnClearCalib(event):
    183206        data['ring'] = []
     
    295318            dlg.Destroy()
    296319            G2frame.PatternTree.SelectItem(G2frame.PickId)
     320           
     321    def OnCopySelected(event):
     322        Names = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
     323        if len(Names) == 1:
     324            G2frame.ErrorDialog('Nothing to copy controls to','There must be more than one "IMG" pattern')
     325            return
     326        Source = G2frame.PatternTree.GetItemText(G2frame.Image)
     327        # Assemble a list of item labels
     328        keyList = ['type','wavelength','calibrant','distance','center',
     329                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
     330                    'IOtth','outChannels','outAzimuths','invert_x','invert_y','DetDepth',
     331                    'calibskip','pixLimit','cutoff','calibdmin','chisq','Flat Bkg',
     332                    'binType','SampleShape','PolaVal','SampleAbs','dark image','background image']
     333        keyText = [i+'='+str(data[i]) for i in keyList]
     334        # sort both lists together, ordered by keyText
     335        selectedKeys = []
     336        dlg = G2G.G2MultiChoiceDialog(
     337            G2frame.dataFrame,
     338            'Select which image controls\nto copy',
     339            'Select image controls', keyText)
     340        try:
     341            if dlg.ShowModal() == wx.ID_OK:
     342                selectedKeys = [keyList[i] for i in dlg.GetSelections()]
     343        finally:
     344            dlg.Destroy()
     345        if not selectedKeys: return # nothing to copy
     346        copyDict = {}
     347        for parm in selectedKeys:
     348            copyDict[parm] = data[parm]
     349        dlg = G2G.G2MultiChoiceDialog(
     350            G2frame.dataFrame,
     351            'Copy image controls from\n'+Source+' to...',
     352            'Copy image controls', Names)
     353        try:
     354            if dlg.ShowModal() == wx.ID_OK:
     355                result = dlg.GetSelections()
     356                for i in result:
     357                    item = Names[i]
     358                    Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item)
     359                    Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Image Controls'))
     360                    Controls.update(copy.deepcopy(copyDict))
     361        finally:
     362            dlg.Destroy()           
     363                         
     364           
     365           
    297366               
    298367    def OnSaveControls(event):
     
    907976                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=True)
    908977                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCALIBRATE,enable=True)
     978                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBALL,enable=True)
    909979                data['calibskip'] = calFile.Calibrants[data['calibrant']][3]
    910980                limits = calFile.Calibrants[data['calibrant']][4]
     
    917987                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=False)
    918988                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCALIBRATE,enable=False)
    919            
     989                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBALL,enable=False)
    920990        def OnCalibSkip(event):
    921991            data['calibskip'] = int(calibSkip.GetValue())
     
    11001170    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCalibrate, id=G2gd.wxID_IMCALIBRATE)
    11011171    G2frame.dataFrame.Bind(wx.EVT_MENU, OnRecalibrate, id=G2gd.wxID_IMRECALIBRATE)
     1172    G2frame.dataFrame.Bind(wx.EVT_MENU, OnRecalibAll, id=G2gd.wxID_IMRECALIBALL)
    11021173    G2frame.dataFrame.Bind(wx.EVT_MENU, OnClearCalib, id=G2gd.wxID_IMCLEARCALIB)
    11031174    if data.get('calibrant'):
    11041175        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=True)
    11051176        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCALIBRATE,enable=True)
     1177        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBALL,enable=True)
    11061178    else:
    11071179        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=False)
    11081180        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCALIBRATE,enable=False)
     1181        G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBALL,enable=False)
    11091182    G2frame.dataFrame.Bind(wx.EVT_MENU, OnIntegrate, id=G2gd.wxID_IMINTEGRATE)
    11101183    G2frame.dataFrame.Bind(wx.EVT_MENU, OnIntegrateAll, id=G2gd.wxID_INTEGRATEALL)
    11111184    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyControls, id=G2gd.wxID_IMCOPYCONTROLS)
     1185    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopySelected, id=G2gd.wxID_IMCOPYSELECTED)
    11121186    G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveControls, id=G2gd.wxID_IMSAVECONTROLS)
    11131187    G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadControls, id=G2gd.wxID_IMLOADCONTROLS)
  • trunk/GSASIIplot.py

    r2308 r2310  
    42414241    if not event:                       #event from GUI TextCtrl - don't want focus to change to plot!!!
    42424242        G2frame.G2plotNB.RaisePageNoRefresh(Page)
     4243    G2frame.G2plotNB.skipPageChange = True
    42434244    Title = G2frame.PatternTree.GetItemText(G2frame.Image)[4:]
    42444245    G2frame.G2plotNB.status.DestroyChildren()
  • trunk/GSASIIpwdGUI.py

    r2308 r2310  
    33243324                    Fcsq = float(G2frame.refTable[phaseName].GetCellValue(r,7+im))
    33253325                    sig = float(G2frame.refTable[phaseName].GetCellValue(r,6+im))
    3326                     rat = abs(Fosq-Fcsq)/sig
     3326                    rat = 11.
     3327                    if sig:
     3328                        rat = abs(Fosq-Fcsq)/sig
    33273329                    if  rat > 10.:
    33283330                        G2frame.refTable[phaseName].SetCellBackgroundColour(r,7+im,wx.RED)
    33293331                    elif rat > 3.0:
    33303332                        G2frame.refTable[phaseName].SetCellBackgroundColour(r,7+im,wx.Colour(255,255,0))
    3331 #                    else:
    3332 #                        G2frame.refTable[phaseName].SetCellBackgroundColour(r,7+im,wx.WHITE)
    33333333                else:   #PWDR
    33343334                    if float(G2frame.refTable[phaseName].GetCellValue(r,12+im+itof)) < 0.:
Note: See TracChangeset for help on using the changeset viewer.