Changeset 5021


Ignore:
Timestamp:
Sep 3, 2021 3:19:48 PM (3 months ago)
Author:
vondreele
Message:

use copy.deepcopy on element info in PDF stuff to avoid cross talk between PDFs
A currently commented out smoothing of I(Q) tried - seems not to matter
Allow PDF optimizer to handle negative fixed background & allow its input in the GUI

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5003 r5021  
    48144814                                sumnum = 0.
    48154815                                for [elem,num] in Formula:
    4816                                     ElData = G2elem.GetElInfo(elem,Parms)
     4816                                    ElData = copy.deepcopy(G2elem.GetElInfo(elem,Parms))
    48174817                                    ElData['FormulaNo'] = float(num)
    48184818                                    sumnum += float(num)
     
    48214821                            except ValueError:
    48224822                                G2G.G2MessageBox(self,'Carbon-based (and wrong) PDF will be generated','Missing chemical formula')
    4823                                 ElData = G2elem.GetElInfo('C',Parms)
     4823                                ElData = copy.deepcopy(G2elem.GetElInfo('C',Parms))
    48244824                                sumnum = 1.0
    48254825                                ElData['FormulaNo'] = 1.0
  • trunk/GSASIIobj.py

    r5010 r5021  
    33143314        {'Limits':[1.,5.],'Background':[2,[0.,-0.2*np.pi],False],'Peaks':[]})
    33153315    return Id
    3316 #%%
     3316
    33173317class ShowTiming(object):
    33183318    '''An object to use for timing repeated sections of code.
     
    33633363        for i,(lbl,val) in enumerate(zip(self.label,self.timeSum)):
    33643364            print('{} {:20} {:8.2f} ms {:5.2f}%'.format(i,lbl,1000.*val,100*val/sumT))
    3365 #%%
    33663365
    33673366def validateAtomDrawType(typ,generalData={}):
  • trunk/GSASIIpwd.py

    r5018 r5021  
    347347            Abs += SA
    348348        MuR = Abs*data['Diam']/2.
    349         IofQ[1][1] /= Absorb(data['Geometry'],MuR,inst['2-theta'][1]*np.ones(len(wave)))       
     349        IofQ[1][1] /= Absorb(data['Geometry'],MuR,inst['2-theta'][1]*np.ones(len(wave)))
     350    # improves look of F(Q) but no impact on G(R)
     351    # bBut,aBut = signal.butter(8,.5,"lowpass")
     352    # IofQ[1][1] = signal.filtfilt(bBut,aBut,IofQ[1][1])
    350353    XY = IofQ[1]   
    351354    #convert to Q
    352 #    nQpoints = len(XY[0])     #points for Q interpolation
    353355    nQpoints = 5000
    354356    if 'C' in inst['Type'][0]:
     
    539541#    auxPlot.append([Qpoints,Qsmooth,'interpolate:'+RDFcontrols['Smooth']])
    540542    DofR = dq*np.imag(fft.fft(Qsmooth,16*nR)[:nR])
    541 #    DofR = dq*np.imag(ft.fft(Qsmooth,16*nR)[:nR])
    542543    auxPlot.append([R[:iFin],DofR[:iFin],'D(R) for '+RDFcontrols['UseObsCalc']])   
    543544    return auxPlot
    544545
    545546# PDF optimization =============================================================
    546 def OptimizePDF(data,xydata,limits,inst,showFit=True,maxCycles=5):
     547def OptimizePDF(data,xydata,limits,inst,showFit=True,maxCycles=25):
    547548    import scipy.optimize as opt
    548549    numbDen = GetNumDensity(data['ElList'],data['Form Vol'])
     
    564565                    method='L-BFGS-B',options={'maxiter':maxCycles},tol=0.001)
    565566    else:
    566         res = opt.minimize(Min,xstart,bounds=([0,None],[0,1],[0.01,1.]),
     567        res = opt.minimize(Min,xstart,bounds=([0.,None],[0,1],[0.01,1.]),
    567568                    method='L-BFGS-B',options={'maxiter':maxCycles},tol=0.001)
    568569    Done(res['x'])
     
    594595        else:
    595596            F,B,R = arg
    596             Data['Flat Bkg'] = F*BkgMax
     597            Data['Flat Bkg'] = BkgMax*(2.*F-1.)
    597598            Data['BackRatio'] = B
    598599        Data['Ruland'] = R
     
    610611                return [max(data['Ruland'],.05),data['Sample']['Mult']]
    611612        try:
    612             F = data['Flat Bkg']/BkgMax
     613            F = 0.5+0.5*data['Flat Bkg']/BkgMax
    613614        except:
    614615            F = 0
     
    623624        else:
    624625            F,B,R = arg
    625             data['Flat Bkg'] = F*BkgMax
     626            data['Flat Bkg'] = BkgMax*(2.*F-1.)
    626627            data['BackRatio'] = B
    627628        data['Ruland'] = R
  • trunk/GSASIIpwdGUI.py

    r5016 r5021  
    28882888        wx.CallLater(100,UpdateSampleGrid,G2frame,data)
    28892889       
    2890        
    2891     ######## DEBUG #######################################################
    2892     #import GSASIIpwdGUI
    2893     #reload(GSASIIpwdGUI)
    2894     #reload(G2gd)
    2895     ######################################################################
    28962890    Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(
    28972891            G2frame,G2frame.PatternId, 'Instrument Parameters'))[0]
     
    71047098        def FillElemSizer(elemSizer,ElData):
    71057099           
    7106             def AfterChange(invalid,value,tc):
     7100            def OnElemNum(invalid,value,tc):
    71077101                if invalid: return
    71087102                data['Form Vol'] = max(10.0,SumElementVolumes())
     
    71137107                label=' Element: '+'%2s'%(ElData['Symbol'])+' * '),0,WACV)
    71147108            num = G2G.ValidatedTxtCtrl(G2frame.dataWindow,ElData,'FormulaNo',nDig=(10,3),xmin=0.0,
    7115                 typeHint=float,OnLeave=AfterChange)
     7109                typeHint=float,OnLeave=OnElemNum)
    71167110            elemSizer.Add(num,0,WACV)
    71177111            elemSizer.Add(wx.StaticText(parent=G2frame.dataWindow,
     
    72787272            sqBox.Add(obliqCoeff,0)
    72797273        sqBox.Add(wx.StaticText(G2frame.dataWindow,label=' Flat Bkg.: '),0,WACV)
    7280         G2frame.flatBkg = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'Flat Bkg',nDig=(10,0),xmin=0,
     7274        G2frame.flatBkg = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'Flat Bkg',nDig=(10,0),
    72817275                typeHint=float,OnLeave=AfterChangeNoRefresh)
    72827276        sqBox.Add(G2frame.flatBkg,0)
     
    74127406       
    74137407    def OnCopyPDFControls(event):
    7414         import copy
    74157408        TextList = GetFileList(G2frame,'PDF')
    74167409        Source = G2frame.GPXtree.GetItemText(G2frame.PatternId)
     
    74947487                if El not in ElList:
    74957488                    try:
    7496                         data['ElList'][El] = G2elem.GetElInfo(El,inst)
     7489                        data['ElList'][El] = copy.deepcopy(G2elem.GetElInfo(El,inst))
    74977490                        data['ElList'][El]['FormulaNo'] = 1.0
    74987491                    except IndexError: # happens with element Q
     
    77677760       
    77687761    def OnCopyPDFPeaks(event):
    7769         import copy
    77707762        TextList = GetFileList(G2frame,'PDF')
    77717763        Source = G2frame.GPXtree.GetItemText(G2frame.PatternId)
Note: See TracChangeset for help on using the changeset viewer.