Changeset 1367


Ignore:
Timestamp:
May 29, 2014 9:52:18 AM (8 years ago)
Author:
vondreele
Message:

add Dsp2pos & Pos2dsp for conversions to G2lattice
remove wave from DoIndexPeaks? - wasn't needed
use Pos2dsp & Dsp2pos in various places in G2pwdGUI
set sort order for TOF peaks - makes indexing work!

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIindex.py

    r939 r1367  
    525525    return A
    526526
    527 def DoIndexPeaks(peaks,wave,controls,bravais):
     527def DoIndexPeaks(peaks,controls,bravais):
    528528    'needs a doc string'
    529529   
     
    543543    ncMax = Nobs*ncno
    544544    print "%s %8.3f %8.3f" % ('lattice parameter range = ',amin,amax)
    545     print "%s %8.5f %s %.4f %s %d %s %d" % ('Wavelength =',wave,'Zero =',zero,'Nc/No max =',ncno,' Max Nc =',ncno*Nobs)
     545    print "%s %.4f %s %d %s %d" % ('Zero =',zero,'Nc/No max =',ncno,' Max Nc =',ncno*Nobs)
    546546    cells = []
    547547    for ibrav in range(14):
  • trunk/GSASIIlattice.py

    r1075 r1367  
    413413#for these: H = [h,k,l]; A is as used in calc_rDsq; G - inv metric tensor, g - metric tensor;
    414414#           cell - a,b,c,alp,bet,gam in A & deg
     415   
     416def Pos2dsp(Inst,pos):
     417    ''' convert powder pattern position (2-theta or TOF, musec) to d-spacing
     418    ignores secondary effects (e.g. difA in TOF)
     419    '''
     420    if 'C' in Inst['Type'][0]:
     421        wave = G2mth.getWave(Inst)
     422        dsp = wave/(2.0*sind((pos-Inst['Zero'][1])/2.0))
     423    else:   #'T'OF - ignore difA
     424        dsp = (pos-Inst['Zero'][1])/difC
     425    return dsp
     426   
     427def Dsp2pos(Inst,dsp):
     428    ''' convert d-spacing to powder pattern position (2-theta or TOF, musec)
     429    ignores secondary effects (e.g. difA in TOF) - maybe later?
     430    '''
     431    if 'C' in Inst['Type'][0]:
     432        wave = G2mth.getWave(Inst)
     433        pos = 2.0*asind(wave/(2.*dsp))+Inst['Zero'][1]             
     434    else:   #'T'OF - ignore difA
     435        pos = Inst['difC'][1]*dsp+Inst['Zero'][1]
     436    return pos             
    415437   
    416438def calc_rDsq(H,A):
  • trunk/GSASIIpwdGUI.py

    r1349 r1367  
    311311        poss = x[indx]
    312312        refs = zip(poss,mags)
    313         refs = G2mth.sortArray(refs,0,reverse=True)
     313        if 'C' in Inst['Type'][0]:   
     314            refs = G2mth.sortArray(refs,0,reverse=True)     #small 2-Thetas first
     315        else:   #'T'OF
     316            refs = G2mth.sortArray(refs,0,reverse=False)    #big TOFs first
    314317        for i,ref1 in enumerate(refs):
    315318            for ref2 in refs[i+1:]:
    316319                if abs(ref2[0]-ref1[0]) < 0.1*G2pwd.getFWHM(ref1[0],inst):
    317                     del(refs[i])   
    318         refs = G2mth.sortArray(refs,1,reverse=True)
     320                    del(refs[i])
     321        if 'C' in Inst['Type'][0]:   
     322            refs = G2mth.sortArray(refs,1,reverse=True)
     323        else:   #'T'OF
     324            refs = G2mth.sortArray(refs,1,reverse=False)
    319325        for pos,mag in refs:
    320326            data.append(G2mth.setPeakparms(inst,inst2,pos,mag))
     
    527533    D = dict(zip(T,data))
    528534    T.sort()
     535    if 'T' in Inst['Type'][0]:  #want big TOF's first
     536        T.reverse()
    529537    X = []
    530538    for key in T: X.append(D[key])
     
    17061714    IndexId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Index Peak List')
    17071715    Inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))[0]
    1708     wave = G2mth.getWave(Inst)
    1709    
    17101716    def RefreshIndexPeaksGrid(event):
    17111717        r,c =  event.GetRow(),event.GetCol()
     
    17241730        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Peak List'))
    17251731        for peak in peaks:
    1726             dsp = wave/(2.0*sind((peak[0]-Inst['Zero'][1])/2.0))
     1732            dsp = G2lat.Pos2dsp(Inst,peak[0])
    17271733            data.append([peak[0],peak[2],True,False,0,0,0,dsp,0.0])
    17281734        G2frame.PatternTree.SetItemPyData(IndexId,data)
     
    17721778                    G2indx.IndexPeaks(data,G2frame.HKL)
    17731779                    for hkl in G2frame.HKL:
    1774                         hkl.append(2.0*asind(wave/(2.*hkl[3]))+Inst['Zero'][1])             
     1780                        hkl.append(G2mth.Dsp2pos(Inst,hkl[3]))
    17751781    rowLabels = []
    17761782    for i in range(len(data)): rowLabels.append(str(i+1))
     
    18101816        'P 4/m m m','F m m m','I m m m','C m m m','P m m m','C 2/m','P 2/m','P -1']
    18111817    Inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))[0]
    1812     wave = G2mth.getWave(Inst)
     1818    if 'C' in Inst['Type'][0]:
     1819        wave = G2mth.getWave(Inst)
     1820    else:
     1821        difC = Inst['difC'][1]
    18131822   
    18141823    def SetLattice(controls):
     
    19231932        spc = controls[13]
    19241933        SGData = G2spc.SpcGroup(spc)[1]
    1925         dmin = wave/(2.0*sind(limits[1]/2.0))
     1934        if 'C' in Inst['Type'][0]:
     1935            dmin = G2lat.Pos2dsp(Inst,limits[1])
     1936        else:
     1937            dmin = G2lat.Pos2dsp(Inst,limits[0])
    19261938        G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A)
    19271939        for hkl in G2frame.HKL:
    1928             hkl.append(2.0*asind(wave/(2.*hkl[3]))+controls[1]+Inst['Zero'][1])             
     1940            hkl.append(G2lat.Dsp2pos(Inst,hkl[3])++controls[1])
    19291941        if 'PKS' in G2frame.PatternTree.GetItemText(G2frame.PatternId):
    19301942            G2plt.PlotPowderLines(G2frame)
     
    19912003        G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A)
    19922004        G2indx.IndexPeaks(peaks,G2frame.HKL)
    1993         Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksZ(peaks,wave,ibrav,A,controls[1],controls[0])           
     2005        Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksZ(peaks,wave,ibrav,A,controls[1],controls[0])  #TOF?         
    19942006        controls[1] = Zero
    19952007        controls[6:12] = G2lat.A2cell(Aref)
     
    20072019        cellPrint(ibrav,Aref)
    20082020        for hkl in G2frame.HKL:
    2009             hkl.append(2.0*asind(wave/(2.*hkl[3]))+controls[1]+Inst['Zero'][1])             
     2021            hkl.append(G2lat.Dsp2pos(Inst,hkl[3])+controls[1])
    20102022        if 'PKS' in G2frame.PatternTree.GetItemText(G2frame.PatternId):
    20112023            G2plt.PlotPowderLines(G2frame)
     
    20332045        G2frame.dataFrame.CopyCell.Enable(False)
    20342046        G2frame.dataFrame.RefineCell.Enable(False)
    2035         OK,dmin,newcells = G2indx.DoIndexPeaks(peaks,wave,controls,bravais)
     2047        OK,dmin,newcells = G2indx.DoIndexPeaks(peaks,controls,bravais)
    20362048        cells = keepcells+newcells
    20372049        cells = G2indx.sortM20(cells)
     
    20442056                G2frame.HKL = G2lat.GenHBravais(dmin,bestCell[2],G2lat.cell2A(bestCell[3:9]))
    20452057                for hkl in G2frame.HKL:
    2046                     hkl.append(2.0*asind(wave/(2.*hkl[3]))+controls[1]+Inst['Zero'][1])             
     2058                    hkl.append(G2lat.Dsp2pos(Inst,hkl[3])+controls[1])
    20472059                if 'PKS' in G2frame.PatternTree.GetItemText(G2frame.PatternId):
    20482060                    G2plt.PlotPowderLines(G2frame)
     
    20702082                G2frame.HKL = G2lat.GenHBravais(dmin,ibrav,A)
    20712083                for hkl in G2frame.HKL:
    2072                     hkl.append(2.0*asind(wave/(2.*hkl[3]))+controls[1]+Inst['Zero'][1])             
     2084                    hkl.append(G2lat.Dsp2pos(Inst,hkl[3])+controls[1])
    20732085                if 'PKS' in G2frame.PatternTree.GetItemText(G2frame.PatternId):
    20742086                    G2plt.PlotPowderLines(G2frame)
     
    22682280                G2frame.HKL = G2lat.GenHBravais(dmin,cell[2],A)
    22692281                for hkl in G2frame.HKL:
    2270                     hkl.append(2.0*asind(wave/(2.*hkl[3]))+controls[1]+Inst['Zero'][1])             
     2282                    hkl.append(G2lat.Dsp2pos(Inst,hkl[3])+controls[1])
    22712283            table.append(row)
    22722284        UnitCellsTable = G2gd.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
Note: See TracChangeset for help on using the changeset viewer.