Changeset 1493


Ignore:
Timestamp:
Sep 11, 2014 4:35:59 PM (9 years ago)
Author:
vondreele
Message:

set move=True for GenAtom? call for FillUnitCell?
show bin width in calibration plot - also label items
add check if nothing refined in calibrate
fix crash at end of refinement for reflections with bad widths
fix testDeriv to show constrained variables
fix SCExtinction for constrained extinction coef

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r1489 r1493  
    24432443                    if atom[cuia] == 'A':
    24442444                        Uij = atom[cuij:cuij+6]
    2445                         result = G2spc.GenAtom(XYZ,SGData,False,Uij,False)
     2445                        result = G2spc.GenAtom(XYZ,SGData,False,Uij,True)
    24462446                        for item in result:
    24472447                            atom = copy.copy(atomData[ind])
     
    24602460                                    atomData.append(atom[:])
    24612461                    else:
    2462                         result = G2spc.GenAtom(XYZ,SGData,False,Move=False)
     2462                        result = G2spc.GenAtom(XYZ,SGData,False,Move=True)
    24632463                        for item in result:
    24642464                            atom = copy.copy(atomData[ind])
  • trunk/GSASIIplot.py

    r1480 r1493  
    18421842            Page.canvas.SetCursor(wx.CROSS_CURSOR)
    18431843            try:
    1844                 G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3f'%(xpos,Title,ypos),1)                   
     1844                G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3g'%(xpos,Title,ypos),1)                   
    18451845            except TypeError:
    18461846                G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1)
     
    18861886    else:
    18871887        Plot.set_ylabel(r'$\mathsf{\Delta}T/T$',fontsize=14)
    1888     for ixy,xy in enumerate(XY):
    1889         X,Y = xy
     1888    for ixy,xyw in enumerate(XY):
     1889        if len(xyw) > 2:
     1890            X,Y,W = xyw
     1891        else:
     1892            X,Y = xyw
     1893            W = 0.
    18901894        Yc = G2lat.Dsp2pos(Inst,X)
    18911895        if 'C' in Inst['Type'][0]:
    18921896            Y = Y-Yc
    18931897            E = Sigs[ixy]
     1898            bin = W/2.
    18941899        else:
    18951900            Y = (Y-Yc)/Yc
    18961901            E = Sigs[ixy]/Yc
     1902            bin = W/(2.*Yc)
    18971903        if E:
    18981904            Plot.errorbar(X,Y,ecolor='k',yerr=E)
    1899         Plot.plot(X,Y,'kx',picker=3)
     1905        if ixy:
     1906            Plot.plot(X,Y,'kx',picker=3)
     1907        else:
     1908            Plot.plot(X,Y,'kx',label='peak')
     1909        if W:
     1910            if ixy:
     1911                Plot.plot(X,bin,'b+')
     1912            else:
     1913                Plot.plot(X,bin,'b+',label='bin width')
     1914            Plot.plot(X,-bin,'b+')
    19001915        Plot.axhline(0.,color='r',linestyle='--')
     1916    Plot.legend(loc='best')
    19011917    if not newPlot:
    19021918        Page.toolbar.push_current()
  • trunk/GSASIIpwd.py

    r1484 r1493  
    12191219    parmDict.update(insDict)
    12201220    varyList = insVary
     1221    if not len(varyList):
     1222        print '**** ERROR - nothing to refine! ****'
     1223        return False
    12211224    while True:
    12221225        begin = time.time()
     
    12391242        except ValueError:          #result[1] is None on singular matrix
    12401243            print '**** Refinement failed - singular matrix ****'
    1241         return
     1244    return True
    12421245       
    12431246    sigDict = dict(zip(varyList,sig))
  • trunk/GSASIIpwdGUI.py

    r1475 r1493  
    956956           
    957957    def OnCalibrate(event):
     958        Pattern = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     959        xye = ma.array(ma.getdata(Pattern[1]))
     960        cw = np.diff(xye[0])
    958961        IndexPeaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Index Peak List'))
    959962        if not len(IndexPeaks[0]):
     
    967970            G2frame.ErrorDialog('Can not calibrate','Index Peak List not indexed')
    968971            return           
    969         G2pwd.DoCalibInst(IndexPeaks,data)
    970         UpdateInstrumentGrid(G2frame,data)
    971         XY = []
    972         Sigs = []
    973         for ip,peak in enumerate(IndexPeaks[0]):
    974             if peak[2] and peak[3]:
    975                 XY.append([peak[8],peak[0]])
    976                 Sigs.append(IndexPeaks[1][ip])
    977         if len(XY):
    978             XY = np.array(XY)
    979             G2plt.PlotCalib(G2frame,data,XY,Sigs,newPlot=True)
     972        if G2pwd.DoCalibInst(IndexPeaks,data):
     973            UpdateInstrumentGrid(G2frame,data)
     974            XY = []
     975            Sigs = []
     976            for ip,peak in enumerate(IndexPeaks[0]):
     977                if peak[2] and peak[3]:
     978                    binwid = cw[np.searchsorted(xye[0],peak[0])]
     979                    XY.append([peak[8],peak[0],binwid])
     980                    Sigs.append(IndexPeaks[1][ip])
     981            if len(XY):
     982                XY = np.array(XY)
     983                G2plt.PlotCalib(G2frame,data,XY,Sigs,newPlot=True)
     984        else:
     985            G2frame.ErrorDialog('Can not calibrate','Nothing selected for refinement')
     986           
    980987
    981988    def OnLoad(event):
  • trunk/GSASIIstrMain.py

    r1491 r1493  
    4242   
    4343ateln2 = 8.0*math.log(2.0)
    44 DEBUG = False
     44DEBUG = True
    4545
    4646def RefineCore(Controls,Histograms,Phases,restraintDict,rigidbodyDict,parmDict,varyList,
     
    207207        cPickle.dump(result[0],fl,1)
    208208        cPickle.dump([Histograms,Phases,restraintDict,rigidbodyDict],fl,1)
     209        cPickle.dump([G2mv.dependentParmList,G2mv.arrayList,G2mv.invarrayList,
     210            G2mv.indParmList,G2mv.invarrayList],fl,1)
    209211        cPickle.dump(parmDict,fl,1)
    210212        cPickle.dump(varyList,fl,1)
  • trunk/GSASIIstrMath.py

    r1491 r1493  
    15481548                        iBeg = max(xB,np.searchsorted(x,refl[5]-fmin))
    15491549                        iFin = max(xB,min(np.searchsorted(x,refl[5]+fmax),xF))
    1550                         yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getEpsVoigt(refl[5],refl[12],refl[13],refl[6],refl[7],ma.getdata(x[iBeg:iFin]))  #>90% of time spent here
    1551                         refl[8] = np.sum(np.where(ratio[iBeg:iFin]>0.,yp[iBeg:iFin]*ratio[iBeg:iFin]/refl[11],0.0))
     1550                        if iBeg < iFin:
     1551                            yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getEpsVoigt(refl[5],refl[12],refl[13],refl[6],refl[7],ma.getdata(x[iBeg:iFin]))  #>90% of time spent here
     1552                            refl[8] = np.sum(np.where(ratio[iBeg:iFin]>0.,yp[iBeg:iFin]*ratio[iBeg:iFin]/refl[11],0.0))
    15521553                    Fo = np.sqrt(np.abs(refl[8]))
    15531554                    Fc = np.sqrt(np.abs(refl[9]))
     
    20012002        for iref,ref in enumerate(refDict['RefList']):
    20022003            if ref[6] > 0:
    2003                 dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[1]
     2004                dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1]
    20042005                w = 1.0/ref[6]
    20052006                if w*ref[5] >= calcControls['minF/sig']:
     
    20162017                        depDerivDict[phfx+'Scale'][iref] = w*ref[9]*ref[11]
    20172018                    for item in ['Ep','Es','Eg']:
    2018                         if phfx+item in varylist and dervDict:
     2019                        if phfx+item in varylist and phfx+item in dervDict:
    20192020                            dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11]  #OK
    2020                         elif phfx+item in dependentVars and dervDict:
     2021                        elif phfx+item in dependentVars and phfx+item in dervDict:
    20212022                            depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11]  #OK
    20222023                    for item in ['BabA','BabU']:
     
    20282029        for iref,ref in enumerate(refDict['RefList']):
    20292030            if ref[5] > 0.:
    2030                 dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[1]
     2031                dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1]
    20312032                Fo = np.sqrt(ref[5])
    20322033                Fc = np.sqrt(ref[7])
     
    20452046                        depDerivDict[phfx+'Scale'][iref] = w*ref[9]*ref[11]                           
    20462047                    for item in ['Ep','Es','Eg']:
    2047                         if phfx+item in varylist and dervDict:
     2048                        if phfx+item in varylist and phfx+item in dervDict:
    20482049                            dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11]  #correct
    2049                         elif phfx+item in dependentVars and dervDict:
     2050                        elif phfx+item in dependentVars and phfx+item in dervDict:
    20502051                            depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11]
    20512052                    for item in ['BabA','BabU']:
  • trunk/testDeriv.py

    r1483 r1493  
    3131import GSASIIstrMath as G2stMth
    3232import GSASIItestplot as plot
     33import GSASIImapvars as G2mv
    3334import pytexture as ptx
    3435ptx.pyqlmninit()            #initialize fortran arrays for spherical harmonics
     
    9495                self.values = cPickle.load(file)
    9596                self.HistoPhases = cPickle.load(file)
     97                (G2mv.dependentParmList,G2mv.arrayList,G2mv.invarrayList,G2mv.indParmList,
     98                    G2mv.invarrayList) = cPickle.load(file)
    9699                self.parmDict = cPickle.load(file)
    97100                self.varylist = cPickle.load(file)
     
    102105                file.close()
    103106                self.UpdateControls(event)
     107                print G2mv.VarRemapShow(self.varylist)
    104108        finally:
    105109            dlg.Destroy()
Note: See TracChangeset for help on using the changeset viewer.