Changeset 2695


Ignore:
Timestamp:
Feb 8, 2017 12:31:24 PM (5 years ago)
Author:
vondreele
Message:

use min(intensity) as default for PDF Flat Bkg - gives better start for optimize PDF
refactor sequential refinements so that old results are updated (not erased)

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2694 r2695  
    35763576                if 'PWDR' in name:
    35773577                    TextList.append(name)
     3578                    Data = self.PatternTree.GetItemPyData(id)[1]
     3579                    pwdrMin = np.min(Data[1])
    35783580                    Comments = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id,'Comments'))
    35793581                    Parms = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id,'Instrument Parameters'))[0]
     
    36063608                    for i in dlg.GetSelections():
    36073609                        PDFnames = G2gd.GetPatternTreeDataNames(self,['PDF ',])
    3608                         G2obj.CreatePDFitems(self,TextList[i],ElLists[i],Qlimits[i],PDFnames)
     3610                        G2obj.CreatePDFitems(self,TextList[i],ElLists[i],Qlimits[i],pwdrMin,PDFnames)
    36093611                for item in self.ExportPDF: item.Enable(True)
    36103612            finally:
  • trunk/GSASIIgrid.py

    r2694 r2695  
    37843784    prevVaryList = []
    37853785    foundNames = []
     3786    missing = 0
    37863787    for i,name in enumerate(histNames):
    37873788        if name not in data:
    3788             print("Error: "+name+" not found!")
     3789            if missing < 5:
     3790                print(" Warning: "+name+" not found")
     3791            elif missing == 5:
     3792                print ' Warning: more are missing'
     3793            missing += 1
    37893794            continue
    37903795        foundNames.append(name)
     
    38033808                posdict[name][combinedVaryList.index(svar)] = svar
    38043809            VaryListChanges.append(name)
     3810    if missing:
     3811        print ' Warning: Total of %d data sets missing from sequential results'%(missing)
    38053812    if len(VaryListChanges) > 1:
    38063813        G2frame.dataFrame.SequentialFile.Enable(wxID_ORGSEQSEL,True)
  • trunk/GSASIIimgGUI.py

    r2694 r2695  
    188188        try:
    189189            if dlg.ShowModal() == wx.ID_OK:
    190                 SeqResult = {}
     190                Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential image calibration results')
     191                if Id:
     192                    SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     193                else:
     194                    SeqResult = {}
     195                    Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential image calibration results')
     196                    G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    191197                items = dlg.GetSelections()
    192198                G2frame.EnablePlot = False
    193                 names = []
    194199                for item in items:
    195200                    name = Names[item]
    196                     names.append(name)
    197201                    print 'calibrating',name
    198202                    G2frame.Image = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
     
    213217                    SeqResult[name] = {'variables':vals,'varyList':varyList,'sig':sigList,'Rvals':[],
    214218                        'covMatrix':np.eye(len(varyList)),'title':name,'parmDict':parmDict}
    215                 SeqResult['histNames'] = names
    216                 Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential image calibration results')
    217                 if Id:
    218                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    219                     G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    220                 else:
    221                     Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential image calibration results')
    222                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     219                SeqResult['histNames'] = Names
    223220        finally:
    224221            dlg.Destroy()
    225222        print 'All selected images recalibrated - results in Sequential image calibration results'
     223        G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    226224        G2plt.PlotExposedImage(G2frame,event=None)
    227         wx.CallLater(100,UpdateImageControls,G2frame,data,masks)
     225        G2frame.PatternTree.SelectItem(Id)
    228226       
    229227    def OnClearCalib(event):
     
    19151913    def OnFitAllStrSta(event):
    19161914        choices = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
    1917         sel = []
    19181915        dlg = G2G.G2MultiChoiceDialog(G2frame,'Stress/Strain fitting','Select images to fit:',choices)
    1919         dlg.SetSelections(sel)
    19201916        names = []
    19211917        if dlg.ShowModal() == wx.ID_OK:
    19221918            for sel in dlg.GetSelections():
    19231919                names.append(choices[sel])
     1920            Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential strain fit results')
     1921            if Id:
     1922                SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     1923            else:
     1924                SeqResult = {}
     1925                Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential strain fit results')
     1926                G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    19241927        else:
     1928            dlg.Destroy()
    19251929            return
     1930        dlg.Destroy()
    19261931        if not names:
    19271932            return
    1928         dlg.Destroy()
    1929         SeqResult = {}
    19301933        Reverse = False
    19311934        CopyForward = False
     
    19901993        finally:
    19911994            wx.EndBusyCursor()   
    1992         if Reverse:
    1993             names.reverse()
    1994         SeqResult['histNames'] = names
    1995         Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential strain fit results')
    1996         if Id:
    1997             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    1998             G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    1999         else:
    2000             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential strain fit results')
    2001             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     1995        SeqResult['histNames'] = choices
    20021996        G2frame.PatternTree.SelectItem(Id)
    20031997        print 'All images fitted'
     
    28912885                    continue
    28922886                # Setup PDF
     2887                Data = G2frame.PatternTree.GetItemPyData(PWid)[1]
     2888                pwdrMin = np.min(Data[1])
    28932889                Parms = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
    28942890                    G2frame,PWid,'Instrument Parameters'))[0]
     
    29162912                            ElList[elem] = ElData
    29172913                PDFnames = G2gd.GetPatternTreeDataNames(G2frame,['PDF ',])
    2918                 PDFid = G2obj.CreatePDFitems(G2frame,pwdr,ElList.copy(),Qlimits,PDFnames)
     2914                PDFid = G2obj.CreatePDFitems(G2frame,pwdr,ElList.copy(),Qlimits,pwdrMin,PDFnames)
    29192915                if not PDFid: continue
    29202916                PDFdata = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
  • trunk/GSASIIobj.py

    r2692 r2695  
    20882088        return repr(self.msg)
    20892089
    2090 def CreatePDFitems(G2frame,PWDRtree,ElList,Qlimits,PDFnames=[]):
     2090def CreatePDFitems(G2frame,PWDRtree,ElList,Qlimits,FltBkg=0,PDFnames=[]):
    20912091    '''Create and initialize a new set of PDF tree entries
    20922092
     
    21082108        'Container':{'Name':'','Mult':-1.0},
    21092109        'Container Bkg.':{'Name':'','Mult':-1.0,'Add':0.0},'ElList':ElList,
    2110         'Geometry':'Cylinder','Diam':1.0,'Pack':0.50,'Form Vol':10.0,
     2110        'Geometry':'Cylinder','Diam':1.0,'Pack':0.50,'Form Vol':10.0,'Flat Bkg':FltBkg,
    21112111        'DetType':'Image plate','ObliqCoeff':0.2,'Ruland':0.025,'QScaleLim':Qlimits,
    21122112        'Lorch':False,'BackRatio':0.0,'Rmax':100.,'noRing':False,'IofQmin':1.0,
  • trunk/GSASIIpwdGUI.py

    r2694 r2695  
    521521       
    522522    def OnSeqPeakFit(event):
    523         hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    524         histList = GetHistsLikeSelected(G2frame)
    525         if not histList:
    526             G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
    527             return
    528         sel = []
     523        histList = G2gd.GetPatternTreeDataNames(G2frame,['PWDR',])
    529524        dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential peak fits',
    530525             'Select dataset to include',histList)
    531         dlg.SetSelections(sel)
    532526        names = []
    533527        if dlg.ShowModal() == wx.ID_OK:
     
    537531        if not names:
    538532            return
    539         SeqResult = {}
     533        Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential peak fit results')
     534        if Id:
     535            SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     536        else:
     537            SeqResult = {}
     538            Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential peak fit results')
     539            G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    540540        Reverse = False
    541541        CopyForward = False
     
    558558        FitPgm = 'LSQ'
    559559        prevVaryList = []
    560         Names = []
    561560        peaks = None
    562561        varyList = None
     
    579578                inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    580579                data = G2frame.PatternTree.GetItemPyData(PatternId)[1]
    581                 dlg2 = wx.ProgressDialog('Residual','Peak fit Rwp = ',101.0,
    582                     style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
    583                 screenSize = wx.ClientDisplayRect()
    584                 Size = dlg.GetSize()
    585                 if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0
    586                     dlg2.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x
    587                     dlg2.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    588                 try:
    589                     peaks['sigDict'],result,sig,Rvals,varyList,parmDict,fullvaryList,badVary = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],
    590                         background,limits,inst,inst2,data,prevVaryList,oneCycle,controls,dlg2)
    591                 finally:
    592                     dlg2.Destroy()
     580                peaks['sigDict'],result,sig,Rvals,varyList,parmDict,fullvaryList,badVary = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],
     581                    background,limits,inst,inst2,data,prevVaryList,oneCycle,controls)
    593582                if len(result[0]) != len(fullvaryList):
    594583                    dlg.Destroy()
     
    596585                    break
    597586                else:
    598                     Names.append(name)   
    599587                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.deepcopy(peaks))
    600588                    SeqResult[name] = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
     
    604592        finally:
    605593            dlg.Destroy()
    606         if Reverse:
    607             Names.reverse()
    608         SeqResult['histNames'] = Names
    609         Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential peak fit results')
    610         if Id:
    611             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    612             G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    613         else:
    614             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential peak fit results')
    615             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     594        SeqResult['histNames'] = histList
     595        G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    616596        G2frame.PatternTree.SelectItem(Id)
    617597       
     
    40424022    def OnFitModelAll(event):
    40434023        choices = G2gd.GetPatternTreeDataNames(G2frame,['SASD',])
    4044         sel = []
    40454024        dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential SASD refinement',
    40464025             'Select dataset to include',choices)
    4047         dlg.SetSelections(sel)
    40484026        names = []
    40494027        if dlg.ShowModal() == wx.ID_OK:
    40504028            for sel in dlg.GetSelections():
    40514029                names.append(choices[sel])
     4030            Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential SASD results')
     4031            if Id:
     4032                SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     4033            else:
     4034                SeqResult = {}
     4035                Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential SASD results')
     4036                G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     4037            SeqResult['histNames'] = choices
     4038        else:
     4039            dlg.Destroy()
     4040            return
    40524041        dlg.Destroy()
    4053         SeqResult = {}
    40544042        Reverse = False
    40554043        CopyForward = False
     
    41024090        finally:
    41034091            wx.EndBusyCursor()   
    4104         if Reverse:
    4105             names.reverse()
    4106         SeqResult['histNames'] = names
    4107         Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential SASD results')
    4108         if Id:
    4109             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    4110             G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    4111         else:
    4112             Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential SASD results')
    4113             G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    41144092        G2frame.PatternTree.SelectItem(Id)
    41154093       
     
    53425320       
    53435321        atms = ','.join(data['ElList'].keys())
    5344         colLabels = ['position','magnitude','sig','refine','Atom A','Atom B','Cooord. No.']
     5322        colLabels = ['position','magnitude','sig','refine','Atom A','Atom B','Bond No.']
    53455323        Types = 3*[wg.GRID_VALUE_FLOAT+':10,3',]+[wg.GRID_VALUE_CHOICE+': ,P,M,S,PM,PS,MS,PMS',]+     \
    53465324            2*[wg.GRID_VALUE_CHOICE+':'+atms,]+[wg.GRID_VALUE_FLOAT+':10,3',]
     
    53985376        try:
    53995377            if dlg.ShowModal() == wx.ID_OK:
    5400                 SeqResult = {}
     5378                Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential PDF peak fit results')
     5379                if Id:
     5380                    SeqResult = G2frame.PatternTree.GetItemPyData(Id)
     5381                else:
     5382                    SeqResult = {}
     5383                    Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential PDF peak fit results')
     5384                    G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    54015385                items = dlg.GetSelections()
    54025386                G2frame.EnablePlot = False
    5403                 names = []
    54045387                for item in items:
    54055388                    name = Names[item]
    5406                     names.append(name)
    54075389                    pId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
    54085390                    data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,pId, 'PDF Controls'))
     
    54125394                        'covMatrix':np.eye(len(varyList)),'title':name,'parmDict':parmDict}
    54135395                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,pId, 'PDF Peaks'),newpeaks)
    5414                 SeqResult['histNames'] = names
    5415                 Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential PDF peak fit results')
    5416                 if Id:
    5417                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
    5418                     G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    5419                 else:
    5420                     Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text='Sequential PDF peak fit results')
    5421                     G2frame.PatternTree.SetItemPyData(Id,SeqResult)
     5396                SeqResult['histNames'] = Names
     5397                G2frame.G2plotNB.Delete('Sequential refinement')    #clear away probably invalid plot
    54225398        finally:
    54235399            dlg.Destroy()
    54245400        G2plt.PlotISFG(G2frame,data,peaks=newpeaks,newPlot=False)
    5425         wx.CallAfter(UpdatePDFPeaks,G2frame,newpeaks,data)
     5401        G2frame.PatternTree.SelectItem(Id)
    54265402        print 'All PDFs peak fitted - results in Sequential PDF peak fit results'
    54275403       
  • trunk/GSASIIstrMath.py

    r2616 r2695  
    10261026        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
    10271027        MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
    1028         TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops)     #Nref,Natm                                  #Nref,Natm
     1028        TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops)     #Nref,Natm
    10291029        if SGData['SGInv']:
    10301030            mphase = np.hstack((phase,-phase))
Note: See TracChangeset for help on using the changeset viewer.