Changeset 5112


Ignore:
Timestamp:
Dec 15, 2021 4:56:41 PM (22 months ago)
Author:
vondreele
Message:

implement energy dispersive x-ray data as a new type 'PXE'; assume Gaussian peak shape only; no sample broadening considered. Peak resolution is only ~0.5% not good enough to see sample broadening
import, plotting, peak fitting, indexing & cell refinement from peak positions "complete"
data is old (from ~20 yrs ago) so no idea about modern ED data.
Start on use in Pawley/LeBail? refinement - Rietveld excluded; currently not working
Some work on ISODISTORT implementation

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r5043 r5112  
    8080            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
    8181       
     82        ifkeV = 'E' in UseList[G2frame.hist].get('Type','')           
    8283        plotSizer = wx.BoxSizer(wx.VERTICAL)
    83         choice = ['None','Mustrain','Size','Preferred orientation','St. proj. Inv. pole figure','Eq. area Inv. pole figure']
     84        if ifkeV:
     85            choice = ['None','Mustrain','Size']
     86        else:
     87            choice = ['None','Mustrain','Size','Preferred orientation','St. proj. Inv. pole figure','Eq. area Inv. pole figure']
    8488        plotSel = wx.RadioBox(DData,wx.ID_ANY,'Select plot type:',choices=choice,
    8589            majorDimension=1,style=wx.RA_SPECIFY_COLS)
     
    842846
    843847        def OnLeBail(event):
    844             Obj = event.GetEventObject()
    845848            if not UseList[G2frame.hist]['LeBail']:
    846849                Controls['newLeBail'] = True
     
    905908            UseList[G2frame.hist]['Layer Disp'] = [0.0,False]
    906909#end patch
     910        ifkeV = 'E' in UseList[G2frame.hist].get('Type','')           
    907911        offMsg = ''
    908912        bottomSizer = wx.BoxSizer(wx.VERTICAL)
     
    920924            lebail.Bind(wx.EVT_BUTTON, OnLeBail)
    921925            useBox.Add(lebail,0,WACV)
    922         bottomSizer.Add(useBox,0,wx.TOP|wx.BOTTOM|wx.LEFT,5)
     926        bottomSizer.Add(useBox)             #,0,wx.TOP|wx.BOTTOM|wx.LEFT,5)
     927        if ifkeV:
     928            G2G.HorizontalLine(bottomSizer,DData)
     929            bottomSizer.Add(wx.StaticText(DData,label=' NB: No structure or sample broadening refinement possible from energy dispersive data'))
     930        G2G.HorizontalLine(bottomSizer,DData)
    923931        if G2frame.testSeqRefineMode() and not UseList[G2frame.hist]['LeBail']:
    924932            bottomSizer.Add(wx.StaticText(DData,label='     Sequential Refinement Options'))
     
    950958           
    951959        if G2frame.hist[:4] == 'PWDR':
    952             if UseList[G2frame.hist]['Size'][0] == 'isotropic':
    953                 isoSizer = wx.BoxSizer(wx.HORIZONTAL)
    954                 isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
    955                     'Size',OnSizeType),0,WACV)
    956                 isoSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
    957                 isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV)
    958                 bottomSizer.Add(isoSizer)
    959                 bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size',(10,4),[0.,10.],OnSizeRef),0,wx.BOTTOM,5)
    960             elif UseList[G2frame.hist]['Size'][0] == 'uniaxial':
    961                 uniSizer = wx.BoxSizer(wx.HORIZONTAL)
    962                 uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
    963                     'Size',OnSizeType),0,WACV)
    964                 uniSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
    965                 uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV)
    966                 bottomSizer.Add(UniSizer('Size',OnSizeAxis),0)
    967                 bottomSizer.Add(uniSizer)
    968                 bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size',(10,3),[0.,10.],OnSizeRef),0,wx.BOTTOM,5)
    969             elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
    970                 ellSizer = wx.BoxSizer(wx.HORIZONTAL)
    971                 ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
    972                     'Size',OnSizeType),0,WACV)
    973                 ellSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
    974                 ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV)
    975                 bottomSizer.Add(ellSizer)
    976                 bottomSizer.Add(EllSizeDataSizer(),0,wx.BOTTOM,5)
    977            
    978             if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic':
    979                 isoSizer = wx.BoxSizer(wx.HORIZONTAL)
    980                 isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
    981                     'Mustrain',OnStrainType),0,WACV)
    982                 isoSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
    983                 isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV)
    984                 bottomSizer.Add(isoSizer)
    985                 bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5)
    986             elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial':
    987                 uniSizer = wx.BoxSizer(wx.HORIZONTAL)
    988                 uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
    989                     'Mustrain',OnStrainType),0,WACV)
    990                 uniSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
    991                 uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV)
    992                 bottomSizer.Add(uniSizer)
    993                 bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0)
    994                 bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5)
    995             elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
    996                 genSizer = wx.BoxSizer(wx.HORIZONTAL)
    997                 genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
    998                     'Mustrain',OnStrainType),0,WACV)
    999                 genSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
    1000                 genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV)
    1001                 bottomSizer.Add(genSizer)
    1002                 bottomSizer.Add(GenStrainDataSizer(),0,wx.BOTTOM,5)
    1003            
     960            if not ifkeV:
     961                if UseList[G2frame.hist]['Size'][0] == 'isotropic':
     962                    isoSizer = wx.BoxSizer(wx.HORIZONTAL)
     963                    isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
     964                        'Size',OnSizeType),0,WACV)
     965                    isoSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
     966                    isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV)
     967                    bottomSizer.Add(isoSizer)
     968                    bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size',(10,4),[0.,10.],OnSizeRef),0,wx.BOTTOM,5)
     969                elif UseList[G2frame.hist]['Size'][0] == 'uniaxial':
     970                    uniSizer = wx.BoxSizer(wx.HORIZONTAL)
     971                    uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
     972                        'Size',OnSizeType),0,WACV)
     973                    uniSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
     974                    uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV)
     975                    bottomSizer.Add(UniSizer('Size',OnSizeAxis),0)
     976                    bottomSizer.Add(uniSizer)
     977                    bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size',(10,3),[0.,10.],OnSizeRef),0,wx.BOTTOM,5)
     978                elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
     979                    ellSizer = wx.BoxSizer(wx.HORIZONTAL)
     980                    ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
     981                        'Size',OnSizeType),0,WACV)
     982                    ellSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef))
     983                    ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV)
     984                    bottomSizer.Add(ellSizer)
     985                    bottomSizer.Add(EllSizeDataSizer(),0,wx.BOTTOM,5)
     986               
     987                if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic':
     988                    isoSizer = wx.BoxSizer(wx.HORIZONTAL)
     989                    isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
     990                        'Mustrain',OnStrainType),0,WACV)
     991                    isoSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
     992                    isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV)
     993                    bottomSizer.Add(isoSizer)
     994                    bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5)
     995                elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial':
     996                    uniSizer = wx.BoxSizer(wx.HORIZONTAL)
     997                    uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
     998                        'Mustrain',OnStrainType),0,WACV)
     999                    uniSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
     1000                    uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV)
     1001                    bottomSizer.Add(uniSizer)
     1002                    bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0)
     1003                    bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5)
     1004                elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
     1005                    genSizer = wx.BoxSizer(wx.HORIZONTAL)
     1006                    genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
     1007                        'Mustrain',OnStrainType),0,WACV)
     1008                    genSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef))
     1009                    genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV)
     1010                    bottomSizer.Add(genSizer)
     1011                    bottomSizer.Add(GenStrainDataSizer(),0,wx.BOTTOM,5)
     1012               
    10041013            bottomSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Hydrostatic/elastic strain:'))
    10051014            bottomSizer.Add(HstrainSizer())
    10061015            bottomSizer.Add(DispSizer())
    10071016               
    1008             if not UseList[G2frame.hist]['LeBail']:
     1017            if not UseList[G2frame.hist]['LeBail'] and not ifkeV:
    10091018                poSizer = wx.BoxSizer(wx.VERTICAL)
    10101019                POData = UseList[G2frame.hist]['Pref.Ori.']
     
    10241033                        poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Spherical harmonic coefficients: '+'Texture index: %.3f'%(textJ))
    10251034                            ,0,wx.TOP|wx.BOTTOM,5)
    1026                         poSizer.Add(SHDataSizer(POData),0,wx.TOP|wx.BOTTOM,5)
    1027                         poSizer.Add(SHPenalty(POData),0,wx.TOP|wx.BOTTOM,5)
     1035                        poSizer.Add(SHDataSizer(POData))  #,0,wx.TOP|wx.BOTTOM,5)
     1036                        poSizer.Add(SHPenalty(POData))  #,0,wx.TOP|wx.BOTTOM,5)
    10281037                       
    1029                 bottomSizer.Add(poSizer,0,wx.TOP|wx.BOTTOM,5)
     1038                bottomSizer.Add(poSizer)    #,0,wx.TOP|wx.BOTTOM,5)
    10301039                bottomSizer.Add(ExtSizer('PWDR'),0,wx.TOP|wx.BOTTOM,5)
    10311040                if generalData['Type'] != 'magnetic':
    10321041                    bottomSizer.Add(BabSizer(),0,wx.BOTTOM,5)
    1033             # else:   #turn off PWDR intensity related paramters for LeBail refinement
    1034             #     if UseList[G2frame.hist]['Scale'][1]:
    1035             #         offMsg = "Phase fraction"
    1036             #         UseList[G2frame.hist]['Scale'][1] = False
    1037             #     if UseList[G2frame.hist]['Pref.Ori.'][2]:
    1038             #         UseList[G2frame.hist]['Pref.Ori.'][2] = False
    1039             #         if offMsg: offMsg += ', '
    1040             #         offMsg += 'Preferred orientation'
    1041             #     if UseList[G2frame.hist]['Extinction'][1]:
    1042             #         UseList[G2frame.hist]['Extinction'][1] = False
    1043             #         if offMsg: offMsg += ', '
    1044             #         offMsg += 'Extinction'
    1045             #     flag = False
    1046             #     for item in UseList[G2frame.hist]['Babinet']:
    1047             #         if UseList[G2frame.hist]['Babinet'][item][1]:
    1048             #             UseList[G2frame.hist]['Babinet'][item][1] = False
    1049             #             flag = True
    1050             #     if flag:
    1051             #         if offMsg: offMsg += ', '
    1052             #         offMsg += 'Babinet'
    1053             #     # make sure that the at least one phase uses the histogram...
    1054             #     allLeBail = True
    1055             #     hists,phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
    1056             #     for key in phases:
    1057             #         d = phases[key]
    1058             #         if G2frame.hist not in d['Histograms']: continue
    1059             #         if not d['Histograms'][G2frame.hist]['Use']: continue
    1060             #         if not d['Histograms'][G2frame.hist]['LeBail']:
    1061             #             #print('Phase',key,'is used as non-LeBail')
    1062             #             allLeBail = False
    1063             #             break
    1064             #     # ...or turn off scale
    1065             #     if allLeBail:
    1066             #         if hists[G2frame.hist]['Sample Parameters']['Scale'][1]:
    1067             #             hists[G2frame.hist]['Sample Parameters']['Scale'][1] = False
    1068             #             if offMsg: offMsg += ', '
    1069             #             offMsg += 'Histogram scale factor'
    1070             #     if offMsg:
    1071             #         offMsg = "Refinement flags turned for: " + offMsg
    10721042        elif G2frame.hist[:4] == 'HKLF':
    1073             bottomSizer.Add(ExtSizer('HKLF'),0,wx.BOTTOM,5)
    1074             bottomSizer.Add(BabSizer(),0,wx.BOTTOM,5)
     1043            bottomSizer.Add(ExtSizer('HKLF'))  #,0,wx.BOTTOM,5)
     1044            bottomSizer.Add(BabSizer())  #,0,wx.BOTTOM,5)
    10751045            if not SGData['SGInv'] and len(UseList[G2frame.hist]['Twins']) < 2:
    1076                 bottomSizer.Add(FlackSizer(),0,wx.BOTTOM,5)
    1077             bottomSizer.Add(twinSizer(),0,wx.BOTTOM,5)
     1046                bottomSizer.Add(FlackSizer())  #,0,wx.BOTTOM,5)
     1047            bottomSizer.Add(twinSizer())  #,0,wx.BOTTOM,5)
    10781048        return bottomSizer,offMsg
    10791049
     
    11311101    LeBailMsg = None
    11321102    if G2frame.hist:
     1103        ifkeV = 'E' in UseList[G2frame.hist].get('Type','')           
    11331104        topSizer = wx.FlexGridSizer(1,2,5,5)
    11341105        DData.select = wx.ListBox(DData,choices=G2frame.dataWindow.HistsInPhase,
     
    11381109        DData.select.Bind(wx.EVT_LISTBOX,OnSelect)
    11391110        topSizer.Add(DData.select,0,WACV|wx.LEFT,5)
    1140         if any(['PWDR' in item for item in keyList]):
     1111        if any(['PWDR' in item for item in keyList]) and not ifkeV:
    11411112            topSizer.Add(PlotSizer())
    11421113        mainSizer.Add(topSizer)       
     
    11541125    G2phG.SetPhaseWindow(DData,mainSizer,Scroll=Scroll)
    11551126    if LeBailMsg:
    1156         G2G.G2MessageBox(G2frame,LeBailMsg,
    1157                                  title='LeBail refinement changes')
     1127        G2G.G2MessageBox(G2frame,LeBailMsg,title='LeBail refinement changes')
    11581128
    11591129def MakeHistPhaseWin(G2frame):
  • trunk/GSASIIfiles.py

    r5096 r5112  
    277277                Inst2['Icovar'] = Icovar
    278278        return [Inst1,Inst2]
     279    elif 'E' in DataType:
     280        tth = float(Iparm['INS  1 ICONS'])
     281        s = Iparm['INS  1PRCF11'].split()
     282        names = ['Type','2-theta','XE','YE','ZE','A','B', 'C']
     283        codes = [0,0,0,0,0,0,0,0]
     284        data.extend([tth,0.0,0.0,0.0,sfloat(s[0]),sfloat(s[1]),sfloat(s[2])])    #A,B,C
     285        Iparm1 = makeInstDict(names,data,codes)
     286        Iparm1['Bank'] = [Bank,Bank,0]
     287        return [Iparm1,{}]
    279288
    280289def ReadPowderInstprm(instLines, bank, databanks, rd):
  • trunk/GSASIIindex.py

    r5098 r5112  
    636636    return True,chisq,A,Z,result
    637637   
     638def FitHKLE(tth,ibrav,peaks,A):
     639    'needs a doc string'
     640   
     641    def errFitE(values,ibrav,d,H,keV,tth):
     642        A = Values2A(ibrav,values)
     643        Qo = 1./d**2
     644        Qc = G2lat.calc_rDsq(H,A)
     645        return (Qo-Qc)
     646       
     647    def dervFitE(values,ibrav,d,H,keV,tth):
     648        if ibrav in [0,1,2]:
     649            derv = [H[0]*H[0]+H[1]*H[1]+H[2]*H[2],]
     650        elif ibrav in [3,4,]:
     651            derv = [H[0]*H[0]+H[1]*H[1]+H[0]*H[1],H[2]*H[2]]
     652        elif ibrav in [5,6]:
     653            derv = [H[0]*H[0]+H[1]*H[1],H[2]*H[2]]
     654        elif ibrav in [7,8,9,10,11,12]:
     655            derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2]]
     656        elif ibrav in [13,14,15,16]:
     657            derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[2]]
     658        else:
     659            derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[1],H[0]*H[2],H[1]*H[2]]
     660        derv = np.array(derv)
     661        return derv.T
     662     
     663    Peaks = np.array(peaks).T   
     664    values = A2values(ibrav,A)
     665    result = so.leastsq(errFitE,values,Dfun=dervFitE,full_output=True,ftol=0.0001,
     666        args=(ibrav,Peaks[7],Peaks[4:7],Peaks[0],tth))
     667    A = Values2A(ibrav,result[0])
     668    chisq = np.sum(errFitE(result[0],ibrav,Peaks[7],Peaks[4:7],Peaks[0],tth)**2)
     669    return True,chisq,A,result
     670   
    638671def errFitTSS(values,ibrav,d,H,tof,difC,vec,Vref,Z,Zref):
    639672    Zero = Z
     
    761794    M20,X20 = calc_M20(peaks,HKL)
    762795    return len(HKL),M20,X20,Aref,Z
     796   
     797def refinePeaksE(peaks,tth,ibrav,A):
     798    'needs a doc string'
     799    dmin = getDmin(peaks)
     800    OK,smin,Aref,result = FitHKLE(tth,ibrav,peaks,A)
     801    Peaks = np.array(peaks).T
     802    H = Peaks[4:7]
     803    Peaks[8] = 1./np.sqrt(G2lat.calc_rDsq(H,Aref))
     804    peaks = Peaks.T   
     805    HKL = G2lat.GenHBravais(dmin,ibrav,A)
     806    M20,X20 = calc_M20(peaks,HKL)
     807    return len(HKL),M20,X20,Aref
    763808   
    764809def refinePeaksZSS(peaks,wave,Inst,SGData,SSGData,maxH,ibrav,A,vec,vecRef,Zero,ZeroRef):
  • trunk/GSASIIlattice.py

    r5105 r5112  
    11411141def Pos2dsp(Inst,pos):
    11421142    ''' convert powder pattern position (2-theta or TOF, musec) to d-spacing
     1143    is currently only approximate for EDX data; accurate for others.
    11431144    '''
    11441145    if 'T' in Inst['Type'][0]:
    11451146        return TOF2dsp(Inst,pos)
     1147    elif 'E' in Inst['Type'][0]:
     1148        return 12.398/(2.0*pos*sind(Inst['2-theta'][1]/2.0))
    11461149    else:   #'PKS', 'C' or 'B'
    11471150        wave = G2mth.getWave(Inst)
     
    11701173    if 'T' in Inst['Type'][0]:
    11711174        pos = Inst['difC'][1]*dsp+Inst['Zero'][1]+Inst['difA'][1]*dsp**2+Inst.get('difB',[0,0,False])[1]/dsp
     1175    elif 'E' in Inst['Type'][0]:
     1176        return 12.398/(2.0*dsp*sind(Inst['2-theta'][1]/2.0)+Inst['ZE'][1]+Inst['YE'][1]*dsp+Inst['XE'][1]*dsp**2)
    11721177    else:   #'C' or 'B'
    11731178        wave = G2mth.getWave(Inst)
     
    11771182   
    11781183def getPeakPos(dataType,parmdict,dsp):
    1179     ''' convert d-spacing to powder pattern position (2-theta or TOF, musec)
     1184    ''' convert d-spacing to powder pattern position (2-theta, E or TOF, musec)
    11801185    '''
    11811186    if 'T' in dataType:
    11821187        pos = parmdict['difC']*dsp+parmdict['difA']*dsp**2+parmdict['difB']/dsp+parmdict['Zero']
     1188    elif 'E'in dataType:
     1189        pos = 12.398/(2.0*dsp*sind(parmdict['2-theta']/2.0)+parmdict['ZE']+parmdict['YE']*dsp+parmdict['XE']*dsp**2)
    11831190    else:   #'C' or 'B'
    11841191        pos = 2.0*asind(parmdict['Lam']/(2.*dsp))+parmdict['Zero']
  • trunk/GSASIImath.py

    r5104 r5112  
    45134513    '''
    45144514    return 1./cosd(pos/2.0),tand(pos/2.0),1.0
     4515
     4516def getEDsig(ins,pos):
     4517    '''get ED peak profile sig
     4518   
     4519    :param dict ins: instrument parameters with at least 'A', 'B' & 'C'
     4520      as values only
     4521    :param float pos: energy of peak as keV
     4522    :returns: float getEDsig: peak sigma^2 im keV**2
     4523   
     4524    '''
     4525    return ins['A']*pos**2+ins['B']*pos+ins['C']
     4526
     4527def getEDsigDeriv(ins,pos):
     4528    '''get derivatives of ED peak profile sig wrt A, B & C
     4529   
     4530    :param float pos: energy of peak in keV
     4531   
     4532    :returns: list getEDsigDeriv: d(sig)/dA, d(sig)/dB & d(sig)/dC,
     4533   
     4534    '''
     4535    return pos**2,pos,1.0
    45154536   
    45164537def getTOFsig(ins,dsp):
     
    47054726        gam = getCWgam(ins,pos)           
    47064727        XY = [pos,0,mag,1,alp,0,bet,0,sig,0,gam,0]       #default refine intensity 1st
     4728    elif 'E' in Parms['Type'][0]:
     4729        for x in ['A','B','C']:
     4730            ins[x] = Parms.get(x,[0.0,0.0])[ind]
     4731        sig = getEDsig(ins,pos)
     4732        XY = [pos,0,mag,1,sig,0]       #default refine intensity 1st
     4733       
    47074734    return XY
    47084735   
  • trunk/GSASIIphsGUI.py

    r5111 r5112  
    62006200            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,False)
    62016201            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,False)
    6202             #G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,True)
    62036202        if G2frame.FRMC.GetSizer():
    62046203            G2frame.FRMC.GetSizer().Clear(True)
     
    62116210        RMCsel.Bind(wx.EVT_RADIOBOX, OnRMCselect)
    62126211        mainSizer.Add(RMCsel,0)
    6213         mainSizer.Add((5,5),0)
     6212        G2G.HorizontalLine(mainSizer,G2frame.FRMC)
     6213        mainSizer.Add(wx.StaticText(G2frame.FRMC,
     6214            label=' NB: if you change any of the entries below, you must redo the Operations/Setup RMC step \n above to apply them before doing Operations/Execute'),0,WACV)
     6215        G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    62146216        if G2frame.RMCchoice == 'fullrmc':
    62156217            RMCPdict = data['RMC']['fullrmc']
     
    1075210754                    for histoName in newList:
    1075310755                        Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,histoName)
     10756                        Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Instrument Parameters'))[0]
    1075410757                        data['Histograms'][histoName] = {'Histogram':histoName,'Show':False,'LeBail':False,'newLeBail':True,
    1075510758                            'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{},['',],0.1],
    1075610759                            'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1],
    10757                                 [1.,1.,1.,0.,0.,0.],6*[False,]],
     10760                                [1.,1.,1.,0.,0.,0.],6*[False,]],'Type':Inst['Type'][0],
    1075810761                            'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1],
    1075910762                                NShkl*[0.01,],NShkl*[False,]],
  • trunk/GSASIIplot.py

    r5109 r5112  
    23212321                if 'T' in Parms['Type'][0]: # TOF
    23222322                    dT = Parms['difC'][1] * 2 * np.pi * tolerance / q**2
     2323                elif 'E' in Parms['Type'][0]: # energy dispersive x-rays
     2324                    pass    #for now
    23232325                else: # 'C' or  'B' in Parms['Type'][0] or 'PKS' in Parms['Type'][0]:
    23242326                    wave = G2mth.getWave(Parms)
     
    23602362                    else:
    23612363                        G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d=%9.5f Q=%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1)
     2364                elif 'E' in Parms['Type'][0]:
     2365                    G2frame.G2plotNB.status.SetStatusText('Energy =%9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
    23622366                else:
    23632367                    if 'PWDR' in plottype:
     
    33263330            else:
    33273331                xLabel = r'$TOF, \mathsf{\mu}$s'
     3332        elif 'E' in ParmList[0]['Type'][0]:
     3333            xLabel = 'E, keV'
    33283334        else:
    33293335            xLabel = r'$\mathsf{2\theta}$'
     
    34083414            if ('C' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \
    34093415                ('B' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \
     3416                ('E' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \
    34103417                ('T' in ParmList[0]['Type'][0] and Page.plotStyle['qPlot']): # reversed regions relative to data order
    34113418                tcorner = 1
     
    53505357       
    53515358    for N,Pattern in enumerate(PlotList):
    5352         xye = Pattern[1]
     5359        xye = np.array(Pattern[1])
    53535360        X = xye[0]
    53545361        if not lenX:
     
    63156322        return
    63166323    elif 'T' in Parms['Type'][0]:
    6317         difC = Parms['difC'][0]
     6324        difC = Parms['difC'][1]
     6325    elif 'E' in Parms['Type'][0]:
     6326        tth = Parms['2-theta'][1]
    63186327    else:
    63196328        lam = G2mth.getWave(Parms)
     
    63696378        Plot.plot(Q,G,color='m',label='Lorentzian')
    63706379
    6371         fit = G2mth.setPeakparms(Parms,Parms2,T,Z)
     6380        fit = G2mth.setPeakparms(Parms,Parms2,T,Z,useFit=True)
    63726381        ds = T/difC
    63736382        Q = 2.*np.pi/ds
     
    64026411            Plot.plot(Qp,Gp,'+',color='m',label='Lorentzian peak')
    64036412        Plot.legend(loc='best')
     6413    elif 'E' in Parms['Type'][0]:
     6414        isig = 4
     6415        Plot.set_title('Instrument and sample peak widths')
     6416        Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=14)
     6417        Plot.set_ylabel(r'$\Delta Q/Q, \Delta d/d$',fontsize=14)
     6418        Xmin,Xmax = limits[1]
     6419        X = np.linspace(Xmin,Xmax,num=101,endpoint=True)
     6420        Q = 2.*np.pi*X*npsind(tth/2.)/12.3986
     6421        Z = np.ones_like(X)
     6422        data = G2mth.setPeakparms(Parms,Parms2,X,Z)
     6423        s = np.sqrt(data[isig])   #var -> sig(radians)
     6424        Y = sq8ln2*s/X
     6425        Plot.plot(Q,Y,color='r',label='Gaussian')
     6426       
     6427        fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True)
     6428        sf = np.sqrt(fit[isig])
     6429        Yf = sq8ln2*sf/X
     6430        Plot.plot(Q,Yf,color='r',dashes=(5,5),label='Gaussian fit')
     6431       
     6432        Xp = []
     6433        Yp = []
     6434        for peak in peaks:
     6435            Xp.append(2.*np.pi*peak[0]*npsind(tth/2.)/12.3986)
     6436            try:
     6437                s = math.sqrt(peak[isig])
     6438            except ValueError:
     6439                s = 0.01
     6440            Yp.append(sq8ln2*s/peak[0])
     6441        if len(peaks):
     6442            Plot.plot(Xp,Yp,'+',color='r',label='G peak')
     6443        legend = Plot.legend(loc='best')
     6444        SetupLegendPick(legend,new)
     6445        Page.canvas.draw()
     6446       
    64046447    else:       #'C' & 'B'
    64056448        isig = 4
  • trunk/GSASIIpwd.py

    r5107 r5112  
    807807    return widths,fmin,fmax
    808808   
     809def getWidthsED(pos,sig):
     810    '''Compute the peak widths used for computing the range of a peak
     811    for energy dispersive data. On low-energy side, 20 FWHM are used,
     812    on high-energy side 20 are used
     813   
     814    :param pos: peak position; energy in keV
     815    :param sig: Gaussian peak variance in keV^2
     816   
     817    :returns: widths; [Gaussian sigma] in keV, and
     818        low angle, high angle ends of peak; 20 FWHM & 50 FWHM from position
     819    '''
     820    widths = [np.sqrt(sig),.001]
     821    fwhm = 2.355*widths[0]
     822    fmin = 5.*fwhm
     823    fmax = 5.*fwhm
     824    return widths,fmin,fmax
     825   
    809826def getWidthsTOF(pos,alp,bet,sig,gam):
    810827    '''Compute the peak widths used for computing the range of a peak
     
    837854   
    838855    sig = lambda Th,U,V,W: np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))
     856    sigED = lambda E,A,B,C: np.sqrt(max(0.001,A*E**2+B*E+C))
    839857    sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq*dsp)
    840858    gam = lambda Th,X,Y,Z: Z+X/cosd(Th)+Y*tand(Th)
     
    855873        g = gam(pos/2.,Inst['X'][1],Inst['Y'][1],Inst['Z'][1])
    856874        return getgamFW(g,s)/100.  #returns FWHM in deg
     875    elif 'E' in Inst['Type'][0]:
     876        s = sigED(pos,Inst['A'][1],Inst['B'][1],Inst['C'][1])
     877        return 2.35482*s
    857878    else:   #'B'
    858879        alp = alpPink(pos,Inst['alpha-0'][1],Inst['alpha-1'][1])
     
    943964            yb = bakInt(ma.getdata(xdata))
    944965        sumBk[0] = np.sum(yb)
    945 #Debye function       
    946     if pfx+'difC' in parmDict:
     966#Debye function
     967    if pfx+'difC' in parmDict or 'E' in parmDict[pfx+'Type']:
    947968        ff = 1.
    948969    else:       
     
    12101231    param gam: Lorentzian width in centideg
    12111232
    1212     returns: arrays: function and derivatives of pos, sig, gam, & shl
     1233    returns: arrays: function and derivatives of pos, sig & gam
     1234    NB: the pos derivative has the opposite sign compared to that in other profile functions
    12131235    '''
    12141236   
     
    14301452            except KeyError:        #no more peaks to process
    14311453                return yb+yc
     1454    elif 'E' in dataType:
     1455        iPeak = 0
     1456        dsp = 1.0 #for now - fix later
     1457        while True:
     1458            try:
     1459                pos = parmDict['pos'+str(iPeak)]
     1460                intens = parmDict['int'+str(iPeak)]
     1461                sigName = 'sig'+str(iPeak)
     1462                if sigName in varyList or not peakInstPrmMode:
     1463                    sig = parmDict[sigName]
     1464                else:
     1465                    sig = G2mth.getEDsig(parmDict,pos)
     1466                sig = max(sig,0.001)          #avoid neg sigma^2
     1467                Wd,fmin,fmax = getWidthsED(pos,sig)
     1468                iBeg = np.searchsorted(xdata,pos-fmin)
     1469                iFin = max(iBeg+3,np.searchsorted(xdata,pos+fmin))
     1470                if not iBeg+iFin:       #peak below low limit
     1471                    iPeak += 1
     1472                    continue
     1473                elif not iBeg-iFin:     #peak above high limit
     1474                    return yb+yc
     1475                yc[iBeg:iFin] += intens*getPsVoigt(pos,sig*10.**4,0.001,xdata[iBeg:iFin])[0]
     1476                iPeak += 1
     1477            except KeyError:        #no more peaks to process
     1478                return yb+yc       
    14321479    elif 'B' in dataType:
    14331480        iPeak = 0
     
    15891636                Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl)
    15901637                iBeg = np.searchsorted(xdata,pos-fmin)
    1591                 iFin = np.searchsorted(xdata,pos+fmin)
     1638                iFin = max(iBeg+3,np.searchsorted(xdata,pos+fmin))
    15921639                if not iBeg+iFin:       #peak below low limit
    15931640                    iPeak += 1
     
    16371684            except KeyError:        #no more peaks to process
    16381685                break
     1686    elif 'E' in dataType:
     1687        iPeak = 0
     1688        while True:
     1689            try:
     1690                pos = parmDict['pos'+str(iPeak)]
     1691                intens = parmDict['int'+str(iPeak)]
     1692                sigName = 'sig'+str(iPeak)
     1693                if sigName in varyList or not peakInstPrmMode:
     1694                    sig = parmDict[sigName]
     1695                    dsdA = dsdB = dsdC = 0
     1696                else:
     1697                    sig = G2mth.getEDsig(parmDict,pos)
     1698                    dsdA,dsdB,dsdC = G2mth.getEDsigDeriv(parmDict,pos)
     1699                sig = max(sig,0.001)          #avoid neg sigma
     1700                Wd,fmin,fmax = getWidthsED(pos,sig)
     1701                iBeg = np.searchsorted(xdata,pos-fmin)
     1702                iFin = np.searchsorted(xdata,pos+fmin)
     1703                if not iBeg+iFin:       #peak below low limit
     1704                    iPeak += 1
     1705                    continue
     1706                elif not iBeg-iFin:     #peak above high limit
     1707                    break
     1708                dMdpk = np.zeros(shape=(4,len(xdata)))
     1709                dMdipk = getdPsVoigt(pos,sig*10.**4,0.001,xdata[iBeg:iFin])
     1710                dMdpk[0][iBeg:iFin] += dMdipk[0]
     1711                for i in range(1,4):
     1712                    dMdpk[i][iBeg:iFin] += intens*dMdipk[i]
     1713                dervDict = {'int':dMdpk[0],'pos':-dMdpk[1],'sig':dMdpk[2]*10**4}
     1714                for parmName in ['pos','int','sig']:
     1715                    try:
     1716                        idx = varyList.index(parmName+str(iPeak))
     1717                        dMdv[idx] = dervDict[parmName]
     1718                    except ValueError:
     1719                        pass
     1720                if 'A' in varyList:
     1721                    dMdv[varyList.index('A')] += dsdA*dervDict['sig']
     1722                if 'B' in varyList:
     1723                    dMdv[varyList.index('B')] += dsdB*dervDict['sig']
     1724                if 'C' in varyList:
     1725                    dMdv[varyList.index('C')] += dsdC*dervDict['sig']
     1726                iPeak += 1
     1727            except KeyError:        #no more peaks to process
     1728                break       
     1729       
    16391730    elif 'B' in dataType:
    16401731        iPeak = 0
     
    18881979            insNames.append(parm)
    18891980            insVals.append(Inst[parm][1])
    1890             if parm in ['Lam','difC','difA','difB','Zero',]:
     1981            if parm in ['Lam','difC','difA','difB','Zero','2-theta','XE','YE','ZE']:
    18911982                if Inst[parm][2]:
    18921983                    insVary.append(parm)
     
    19081999        sigstr = 'esds  :'
    19092000        for parm in Inst:
    1910             if parm in  ['Lam','difC','difA','difB','Zero',]:
     2001            if parm in  ['Lam','difC','difA','difB','Zero','2-theta','XE','YE','ZE']:
    19112002                ptlbls += "%s" % (parm.center(12))
    19122003                ptstr += ptfmt % (Inst[parm][1])
     
    20972188            insNames.append(parm)
    20982189            insVals.append(Inst[parm][1])
    2099             if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
     2190            if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C',
    21002191                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','alpha-0','alpha-1'] and Inst[parm][2]:
    21012192                    insVary.append(parm)
    21022193        instDict = dict(zip(insNames,insVals))
    2103 #        instDict['X'] = max(instDict['X'],0.01)
    2104 #        instDict['Y'] = max(instDict['Y'],0.01)
    21052194        if 'SH/L' in instDict:
    21062195            instDict['SH/L'] = max(instDict['SH/L'],0.002)
     
    21192208                        dsp = G2lat.Pos2dsp(Inst,pos)
    21202209                        parmDict[sigName] = G2mth.getTOFsig(parmDict,dsp)
     2210                    if 'E' in Inst['Type'][0]:
     2211                        parmDict[sigName] = G2mth.getEDsig(parmDict,pos)
    21212212                    else:
    21222213                        parmDict[sigName] = G2mth.getCWsig(parmDict,pos)
     
    21392230        sigstr = 'esds  :'
    21402231        for parm in Inst:
    2141             if parm in  ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
     2232            if parm in  ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C',
    21422233                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','alpha-0','alpha-1']:
    21432234                ptlbls += "%s" % (parm.center(12))
     
    21572248        if 'C' in dataType:
    21582249            names = ['pos','int','sig','gam']
     2250        elif 'E' in dataType:
     2251            names = ['pos','int','sig']
    21592252        else:   #'T' and 'B'
    21602253            names = ['pos','int','alp','bet','sig','gam']
     
    21712264        if 'C' in Inst['Type'][0]:
    21722265            names = ['pos','int','sig','gam']
     2266        elif 'E' in Inst['Type'][0]:
     2267            names = ['pos','int','sig']
    21732268        else:   #'T' & 'B'
    21742269            names = ['pos','int','alp','bet','sig','gam']
     
    21942289                    if 'T' in Inst['Type'][0]:
    21952290                        peak[2*j] = G2mth.getTOFsig(parmDict,dsp)
     2291                    elif 'E' in Inst['Type'][0]:
     2292                        peak[2*j] = G2mth.getEDsig(parmDict,pos)
    21962293                    else:   #'C' & 'B'
    21972294                        peak[2*j] = G2mth.getCWsig(parmDict,pos)
     
    22062303        if 'C' in dataType:
    22072304            names = ['pos','int','sig','gam']
     2305        elif 'E' in dataType:
     2306            names = ['pos','int','sig']
    22082307        else:   #'T' & 'B'
    22092308            names = ['pos','int','alp','bet','sig','gam']           
     
    22182317        if 'C' in dataType:
    22192318            ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f",'gam':"%10.3f"}
     2319        elif 'E' in dataType:
     2320            ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f"}
    22202321        elif 'T' in dataType:
    22212322            ptfmt = {'pos':"%10.2f",'int':"%10.4f",'alp':"%8.3f",'bet':"%8.5f",'sig':"%10.3f",'gam':"%10.3f"}
     
    22902391    fullvaryList = varyList[:]
    22912392    if not peakInstPrmMode:
    2292         for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1',
     2393        for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1','A','B','C',
    22932394            'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',):
    22942395            if v in varyList:
  • trunk/GSASIIpwdGUI.py

    r5084 r5112  
    675675        if 'T' in Inst['Type'][0]:   
    676676            refs = G2mth.sortArray(refs,0,reverse=True)     #big TOFs first
    677         else:   #'c' or 'B'
    678             refs = G2mth.sortArray(refs,0,reverse=False)    #small 2-Thetas first
     677        else:   #'C', 'E' or 'B'
     678            refs = G2mth.sortArray(refs,0,reverse=False)    #small 2-Thetas or energies first
    679679        for i,ref1 in enumerate(refs):      #reject picks closer than 1 FWHM
    680680            for ref2 in refs[i+1:]:
     
    683683        if 'T' in Inst['Type'][0]:   
    684684            refs = G2mth.sortArray(refs,1,reverse=False)
    685         else:   #'C' or 'B'
     685        else:   #'C', 'E' or 'B'
    686686            refs = G2mth.sortArray(refs,1,reverse=True)
    687687        for pos,mag in refs:
     
    917917            parent=G2frame,
    918918            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
    919         screenSize = wx.ClientDisplayRect()
    920         Size = dlg.GetSize()
    921         if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0
    922             dlg.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x
    923             dlg.CenterOnParent()
    924         try:
    925             results = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,bxye,[],oneCycle,controls,wtFactor,dlg)
    926             peaks['sigDict'] = results[0]
    927             text = 'Peak fit: Rwp=%.2f%% Nobs= %d Nparm= %d Npeaks= %d'%(results[3]['Rwp'],results[1][2]['fjac'].shape[1],len(results[0]),len(peaks['peaks']))
    928         finally:
    929             dlg.Destroy()
     919        # Size = dlg.GetSize()
     920        # if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0
     921        #     dlg.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x
     922        #     dlg.CenterOnParent()
     923        results = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,bxye,[],oneCycle,controls,wtFactor,dlg)
     924        peaks['sigDict'] = results[0]
     925        text = 'Peak fit: Rwp=%.2f%% Nobs= %d Nparm= %d Npeaks= %d'%(results[3]['Rwp'],results[1][2]['fjac'].shape[1],len(results[0]),len(peaks['peaks']))
     926#        dlg.Destroy()
    930927        newpeaks = copy.copy(peaks)
    931928        G2frame.GPXtree.SetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Peak List'),newpeaks)
     
    11431140            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL,
    11441141            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL]
     1142    elif 'E' in Inst['Type'][0]:
     1143        colLabels = ['position','refine','intensity','refine','sigma','refine']
     1144        Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,
     1145            wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL,
     1146            wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL]
    11451147    else:
    11461148        colLabels = ['position','refine','intensity','refine','alpha','refine',
     
    11861188#    G2frame.dataWindow.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, onCellListDClick)
    11871189    reflGrid.AutoSizeColumns(False)
    1188     reflGrid.SetScrollRate(10,10)
     1190#    reflGrid.SetScrollRate(10,10)
    11891191    G2frame.reflGrid = reflGrid
    11901192    topSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    18931895        good = []
    18941896        for key in keys:
    1895             if key in ['Type','Bank','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
     1897            if key in ['Type','Bank','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C',
    18961898                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','Polariz.','alpha-0','alpha-1',
    1897                 'Lam','Azimuth','2-theta','fltPath','difC','difA','difB','Zero','Lam1','Lam2']:
     1899                'Lam','Azimuth','2-theta','fltPath','difC','difA','difB','Zero','Lam1','Lam2','XE','YE','ZE',]:
    18981900                good.append(key)
    18991901        return good
     
    21822184        copyList = []
    21832185        copyData = copy.deepcopy(data)
    2184         del copyData['Azimuth'] #not to be copied!
     2186        if 'E' not in data['Type'][0]:
     2187            del copyData['Azimuth'] #not to be copied!
    21852188        instType = data['Type'][0]
    21862189        dlg = G2G.G2MultiChoiceDialog(G2frame,'Copy inst params from\n'+hst,
     
    23812384                    instSizer.Add(itemVal,0,WACV)
    23822385                    instSizer.Add(RefineBox(item),0,WACV)
     2386            elif 'E' in insVal['Type']:
     2387                key = '2-theta'
     2388                instSizer.Add(wx.StaticText(G2frame.dataWindow,-1,u' 2-theta): (%10.6f)'%(insDef[key])),0,WACV)
     2389                tthVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,insVal,key,nDig=(10,6),typeHint=float,OnLeave=AfterChange)
     2390                labelLst.append(u'2-theta')
     2391                elemKeysLst.append([key,1])
     2392                dspLst.append([10,3])
     2393                instSizer.Add(tthVal,0,WACV)
     2394                refFlgElem.append([key,2])                   
     2395                instSizer.Add(RefineBox(key),0,WACV)
     2396                for item in ['XE','YE','ZE','A','B','C']:
     2397                    nDig = (10,6,'g')
     2398                    labelLst.append(item)
     2399                    elemKeysLst.append([item,1])
     2400                    dspLst.append(nDig)
     2401                    refFlgElem.append([item,2])
     2402                    instSizer.Add(wx.StaticText(G2frame.dataWindow,-1,lblWdef(item,nDig[1],insDef[item])),0,WACV)
     2403                    itemVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,insVal,item,nDig=nDig,typeHint=float,OnLeave=NewProfile)
     2404                    instSizer.Add(itemVal,0,WACV)
     2405                    instSizer.Add(RefineBox(item),0,WACV)
    23832406            elif 'T' in insVal['Type']:                                   #time of flight (neutrons)
    23842407                subSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    25052528            patched += 1
    25062529    if patched: print (patched,' instrument parameters changed from tuples')
    2507     if 'Z' not in data:
     2530    if 'E' not in data['Type'][0] and 'Z' not in data:
    25082531        data['Z'] = [0.0,0.0,False]
    25092532    #end of patch
     
    25262549        insDef = dict(zip(instkeys,[data[key][0] for key in instkeys]))
    25272550        insRef = {}
    2528     elif 'R' in data['Type'][0]:                               #low angle data
     2551    elif 'R' in data['Type'][0]:                               #Reflectometry data
    25292552        insVal = dict(zip(instkeys,[data[key][1] for key in instkeys]))
    25302553        insDef = dict(zip(instkeys,[data[key][0] for key in instkeys]))
     
    30243047        nameSizer.Add(wx.StaticText(G2frame.dataWindow,wx.ID_ANY,' Diffractometer type: '),
    30253048                    0,WACV)
    3026         if 'T' in Inst['Type'][0] or 'B' in Inst['Type'][0]:
     3049        if 'T' in Inst['Type'][0] or 'B' in Inst['Type'][0] or 'E' in Inst['Type'][0]:
    30273050            choices = ['Debye-Scherrer',]
    30283051        else:
     
    37133736        A = G2lat.cell2A(cell)
    37143737        ibrav = bravaisSymb.index(controls[5])
    3715 #        if not controls[13]: controls[13] = SPGlist[controls[5]][0]    #don't know if this is needed?   
    37163738        SGData = G2spc.SpcGroup(controls[13])[1]
    37173739        if 'T' in Inst['Type'][0]:
     
    37263748                G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst)
    37273749                peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]]   #put peak fit esds back in peaks
    3728                 Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0])           
     3750                Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0])
     3751        elif 'E' in Inst['Type'][0]:        #no super lattice stuff for EDX data - resolution too low
     3752            G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst)
     3753            peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]]   #put peak fit esds back in peaks
     3754            Lhkl,M20,X20,Aref = G2indx.refinePeaksE(peaks[0],TTh,ibrav,A)
     3755            Zero = 0.0
    37293756        else:   
    37303757            if ssopt.get('Use',False):
     
    44074434    if 'T' in Inst['Type'][0]:
    44084435        difC = Inst['difC'][1]
    4409         dmin = G2lat.Pos2dsp(Inst,Limits[0])
     4436        dmin = G2lat.Pos2dsp(Inst,Limits[1])
     4437    elif 'E' in Inst['Type'][0]:
     4438        TTh = Inst['2-theta'][1]
     4439        dmin = G2lat.Pos2dsp(Inst,Limits[1])
    44104440    else:   #'C', 'B', or 'PKS'
    44114441        wave = G2mth.getWave(Inst)
     
    44964526    mainSizer.Add(littleSizer,0)
    44974527    mainSizer.Add((5,5),0)
    4498     mainSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select Bravais Lattices for indexing: '),
    4499         0)
     4528    mainSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select Bravais Lattices for indexing: '),0)
    45004529    mainSizer.Add((5,5),0)
    45014530    indentSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    45434572    spcSel.Bind(wx.EVT_CHOICE,OnSpcSel)
    45444573    littleSizer.Add(spcSel,0,WACV)
    4545     if ssopt.get('Use',False):        #zero for super lattice doesn't work!
    4546         controls[0] = False
    4547     else:
    4548         littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Zero offset "),0,WACV)
    4549         zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float,
    4550                                     xmin=-5.,xmax=5.,size=(50,-1),OnLeave=OnCellChange)
    4551         littleSizer.Add(zero,0,WACV)
    4552         zeroVar = wx.CheckBox(G2frame.dataWindow,label="Refine?")
    4553         zeroVar.SetValue(controls[0])
    4554         zeroVar.Bind(wx.EVT_CHECKBOX,OnZeroVar)
    4555         littleSizer.Add(zeroVar,0,WACV)
    4556     SSopt = wx.CheckBox(G2frame.dataWindow,label="Modulated?")
    4557     SSopt.SetValue(ssopt.get('Use',False))
    4558     SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt)
    4559     littleSizer.Add(SSopt,0,WACV)
    4560     if 'N' in Inst['Type'][0]:
    4561         MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?")
    4562         MagSel.SetValue('MagSpGrp' in SGData)
    4563         MagSel.Bind(wx.EVT_CHECKBOX,OnMagSel)
    4564         littleSizer.Add(MagSel,0,WACV)
     4574    if 'E' not in Inst['Type'][0]:
     4575        if ssopt.get('Use',False):        #zero for super lattice doesn't work!
     4576            controls[0] = False
     4577        else:
     4578            littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Zero offset "),0,WACV)
     4579            zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float,
     4580                                        xmin=-5.,xmax=5.,size=(50,-1),OnLeave=OnCellChange)
     4581            littleSizer.Add(zero,0,WACV)
     4582            zeroVar = wx.CheckBox(G2frame.dataWindow,label="Refine?")
     4583            zeroVar.SetValue(controls[0])
     4584            zeroVar.Bind(wx.EVT_CHECKBOX,OnZeroVar)
     4585            littleSizer.Add(zeroVar,0,WACV)
     4586        SSopt = wx.CheckBox(G2frame.dataWindow,label="Modulated?")
     4587        SSopt.SetValue(ssopt.get('Use',False))
     4588        SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt)
     4589        littleSizer.Add(SSopt,0,WACV)
     4590        if 'N' in Inst['Type'][0]:
     4591            MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?")
     4592            MagSel.SetValue('MagSpGrp' in SGData)
     4593            MagSel.Bind(wx.EVT_CHECKBOX,OnMagSel)
     4594            littleSizer.Add(MagSel,0,WACV)
    45654595    mainSizer.Add(littleSizer,0)
    45664596    mainSizer.Add((5,5),0)
     
    49745004            elif 'B' in Inst['Type'][0]:
    49755005                refs = np.vstack((refList.T[:17+Super],I100,MuStr,CrSize)).T
     5006            elif 'E' in Inst['Type'][0]:
     5007                refs = np.vstack((refList.T[:11+Super],I100,MuStr,CrSize)).T
    49765008        rowLabels = [str(i) for i in range(len(refs))]
    49775009        Types = (4+Super)*[wg.GRID_VALUE_LONG,]+4*[wg.GRID_VALUE_FLOAT+':10,4',]+ \
     
    49955027                colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','alp','bet','Prfo','Abs','Ext','I100','mustrain','Size']
    49965028                Types += 8*[wg.GRID_VALUE_FLOAT+':10,3',]
     5029            elif 'E' in Inst['Type'][0]:
     5030                colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','I100']
     5031                Types += [wg.GRID_VALUE_FLOAT+':10,3',]
    49975032            if Super:
    49985033                colLabels.insert(3,'M')
     
    77227757        mainSizer.Add(DiffSizer())
    77237758    else:
    7724         mainSizer.Add(wx.StaticText(G2frame.dataWindow,wx.ID_ANY,
    7725                                      powName+' not in Tree'))
     7759        mainSizer.Add(wx.StaticText(G2frame.dataWindow,label='Controls for %s:\n'%powName))
     7760        mainSizer.Add(DiffSizer())
    77267761    G2frame.dataWindow.SetSizer(mainSizer)
    77277762    G2frame.dataWindow.SetDataSize()
  • trunk/GSASIIspc.py

    r4985 r5112  
    36933693    # not found
    36943694        return ''
     3695   
     3696def fullHM2shortHM(SpcGp):
     3697    ''' Accepts a full H-M space group symbol and returns a short H-M symbol that the space group
     3698    interpreter can translate
     3699    '''
     3700    fields = SpcGp.split()
     3701    if len(fields) == 4 and fields[1] == '1' and fields[3] == '1': #b-unique monoclinics
     3702        return fields[0]+' '+fields[2]
     3703    if '/' not in SpcGp:
     3704        return SpcGp
     3705    if '-3' in fields[1]:   #trigonals
     3706        fields[2] = fields.split('/')[1]
     3707        return ' '.join(fields)
     3708    if '-3' in fields[2]:       #cubics
     3709        fields[1] = fields.split('/')[1]
     3710        if len(fields) == 4:
     3711            fields[3].split('/')[1]
     3712        return ' '.join(fields)
     3713    if '6' in fields[1] and '/' in fields[2]:    #hexagonals
     3714        fields[2] = fields[2].split('/')[1]
     3715        fields[3] = fields[3].split('/')[1]
     3716        return ' '.join(fields)
     3717    if '4' in fields[1] and '/' in fields[2] and len(fields) == 4:   #tetragonals
     3718        fields[2] = fields[2].split('/')[1]
     3719        fields[3] = fields[3].split('/')[1]
     3720        return ' '.join(fields)
     3721    if '/' in fields[1] and len(fields) == 4:    #orthorhombics
     3722        if fields[2] == '1':     #skip a-unique monoclinics
     3723            return SpcGp
     3724        fields[1] = fields[1].split('/')[1]
     3725        fields[2] = fields[2].split('/')[1]
     3726        fields[3] = fields[3].split('/')[1]
     3727        return ' '.join(fields)
     3728    return SpcGp
    36953729   
    36963730def SpaceGroupNumber(spcgroup):
  • trunk/GSASIIstrIO.py

    r5106 r5112  
    320320                var = dvar.replace('::dA','::A')
    321321                albl = Ilbl[:Ilbl.rfind('_')]
    322                 v = Ilbl[Ilbl.rfind('_')+1:]
     322                pval = 0
     323                #v = Ilbl[Ilbl.rfind('_')+1:]
    323324                #pval = ISO['ParentStructure'][albl][['dx','dy','dz'].index(v)]
    324325                if var in parmDict:
     
    25202521                    dmin = wave/(2.0*sind(limits[1]/2.0))
    25212522                elif 'T' in inst['Type'][0]:
     2523                    dmin = G2lat.Pos2dsp(inst,limits[1])
    25222524                    dmin = limits[0]/inst['difC'][1]
     2525                elif 'E' in inst['Type'][0]:
     2526                    dmin = G2lat.Pos2dsp(inst,limits[1])
    25232527                else:
    25242528                    wave = inst['Lam'][1]
     
    25542558                else:
    25552559                    hapDict[pfx+'LayerDisp'] = 0.0
    2556                 controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0]
    2557                 if hapData['Pref.Ori.'][0] == 'MD':
    2558                     hapDict[pfx+'MD'] = hapData['Pref.Ori.'][1]
    2559                     controlDict[pfx+'MDAxis'] = hapData['Pref.Ori.'][3]
    2560                     if hapData['Pref.Ori.'][2]:     # and not hapDict[pfx+'LeBail']:
    2561                         hapVary.append(pfx+'MD')
    2562                 else:                           #'SH' spherical harmonics
    2563                     controlDict[pfx+'SHord'] = hapData['Pref.Ori.'][4]
    2564                     controlDict[pfx+'SHncof'] = len(hapData['Pref.Ori.'][5])
    2565                     controlDict[pfx+'SHnames'] = G2lat.GenSHCoeff(SGData['SGLaue'],'0',controlDict[pfx+'SHord'],False)
    2566                     controlDict[pfx+'SHhkl'] = []
    2567                     try: #patch for old Pref.Ori. items
    2568                         controlDict[pfx+'SHtoler'] = 0.1
    2569                         if hapData['Pref.Ori.'][6][0] != '':
    2570                             controlDict[pfx+'SHhkl'] = [eval(a.replace(' ',',')) for a in hapData['Pref.Ori.'][6]]
    2571                         controlDict[pfx+'SHtoler'] = hapData['Pref.Ori.'][7]
    2572                     except IndexError:
    2573                         pass
    2574                     for item in hapData['Pref.Ori.'][5]:
    2575                         hapDict[pfx+item] = hapData['Pref.Ori.'][5][item]
    2576                         if hapData['Pref.Ori.'][2]:         # and not hapDict[pfx+'LeBail']:
    2577                             hapVary.append(pfx+item)
    2578                 for item in ['Mustrain','Size']:
    2579                     controlDict[pfx+item+'Type'] = hapData[item][0]
    2580                     hapDict[pfx+item+';mx'] = hapData[item][1][2]
    2581                     if hapData[item][2][2]:
    2582                         hapVary.append(pfx+item+';mx')
    2583                     if hapData[item][0] in ['isotropic','uniaxial']:
    2584                         hapDict[pfx+item+';i'] = hapData[item][1][0]
    2585                         if hapData[item][2][0]:
    2586                             hapVary.append(pfx+item+';i')
    2587                         if hapData[item][0] == 'uniaxial':
    2588                             controlDict[pfx+item+'Axis'] = hapData[item][3]
    2589                             hapDict[pfx+item+';a'] = hapData[item][1][1]
    2590                             if hapData[item][2][1]:
    2591                                 hapVary.append(pfx+item+';a')
    2592                     else:       #generalized for mustrain or ellipsoidal for size
    2593                         Nterms = len(hapData[item][4])
    2594                         if item == 'Mustrain':
    2595                             names = G2spc.MustrainNames(SGData)
    2596                             pwrs = []
    2597                             for name in names:
    2598                                 h,k,l = name[1:]
    2599                                 pwrs.append([int(h),int(k),int(l)])
    2600                             controlDict[pfx+'MuPwrs'] = pwrs
    2601                         for i in range(Nterms):
    2602                             sfx = ';'+str(i)
    2603                             hapDict[pfx+item+sfx] = hapData[item][4][i]
    2604                             if hapData[item][5][i]:
    2605                                 hapVary.append(pfx+item+sfx)
    2606                 if Phases[phase]['General']['Type'] != 'magnetic':
    2607                     for bab in ['BabA','BabU']:
    2608                         hapDict[pfx+bab] = hapData['Babinet'][bab][0]
    2609                         if hapData['Babinet'][bab][1]:      # and not hapDict[pfx+'LeBail']:
    2610                             hapVary.append(pfx+bab)
     2560                if 'E' not in inst['Type'][0]:
     2561                    controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0]
     2562                    if hapData['Pref.Ori.'][0] == 'MD':
     2563                        hapDict[pfx+'MD'] = hapData['Pref.Ori.'][1]
     2564                        controlDict[pfx+'MDAxis'] = hapData['Pref.Ori.'][3]
     2565                        if hapData['Pref.Ori.'][2]:     # and not hapDict[pfx+'LeBail']:
     2566                            hapVary.append(pfx+'MD')
     2567                    else:                           #'SH' spherical harmonics
     2568                        controlDict[pfx+'SHord'] = hapData['Pref.Ori.'][4]
     2569                        controlDict[pfx+'SHncof'] = len(hapData['Pref.Ori.'][5])
     2570                        controlDict[pfx+'SHnames'] = G2lat.GenSHCoeff(SGData['SGLaue'],'0',controlDict[pfx+'SHord'],False)
     2571                        controlDict[pfx+'SHhkl'] = []
     2572                        try: #patch for old Pref.Ori. items
     2573                            controlDict[pfx+'SHtoler'] = 0.1
     2574                            if hapData['Pref.Ori.'][6][0] != '':
     2575                                controlDict[pfx+'SHhkl'] = [eval(a.replace(' ',',')) for a in hapData['Pref.Ori.'][6]]
     2576                            controlDict[pfx+'SHtoler'] = hapData['Pref.Ori.'][7]
     2577                        except IndexError:
     2578                            pass
     2579                        for item in hapData['Pref.Ori.'][5]:
     2580                            hapDict[pfx+item] = hapData['Pref.Ori.'][5][item]
     2581                            if hapData['Pref.Ori.'][2]:         # and not hapDict[pfx+'LeBail']:
     2582                                hapVary.append(pfx+item)
     2583                    for item in ['Mustrain','Size']:
     2584                        controlDict[pfx+item+'Type'] = hapData[item][0]
     2585                        hapDict[pfx+item+';mx'] = hapData[item][1][2]
     2586                        if hapData[item][2][2]:
     2587                            hapVary.append(pfx+item+';mx')
     2588                        if hapData[item][0] in ['isotropic','uniaxial']:
     2589                            hapDict[pfx+item+';i'] = hapData[item][1][0]
     2590                            if hapData[item][2][0]:
     2591                                hapVary.append(pfx+item+';i')
     2592                            if hapData[item][0] == 'uniaxial':
     2593                                controlDict[pfx+item+'Axis'] = hapData[item][3]
     2594                                hapDict[pfx+item+';a'] = hapData[item][1][1]
     2595                                if hapData[item][2][1]:
     2596                                    hapVary.append(pfx+item+';a')
     2597                        else:       #generalized for mustrain or ellipsoidal for size
     2598                            Nterms = len(hapData[item][4])
     2599                            if item == 'Mustrain':
     2600                                names = G2spc.MustrainNames(SGData)
     2601                                pwrs = []
     2602                                for name in names:
     2603                                    h,k,l = name[1:]
     2604                                    pwrs.append([int(h),int(k),int(l)])
     2605                                controlDict[pfx+'MuPwrs'] = pwrs
     2606                            for i in range(Nterms):
     2607                                sfx = ';'+str(i)
     2608                                hapDict[pfx+item+sfx] = hapData[item][4][i]
     2609                                if hapData[item][5][i]:
     2610                                    hapVary.append(pfx+item+sfx)
     2611                    if Phases[phase]['General']['Type'] != 'magnetic':
     2612                        for bab in ['BabA','BabU']:
     2613                            hapDict[pfx+bab] = hapData['Babinet'][bab][0]
     2614                            if hapData['Babinet'][bab][1]:      # and not hapDict[pfx+'LeBail']:
     2615                                hapVary.append(pfx+bab)
    26112616                               
    26122617                if Print:
     
    26152620                    if hapDict[pfx+'LeBail']:
    26162621                        pFile.write(' Perform LeBail extraction\n')                     
    2617                     else:
     2622                    elif 'E' not in inst['Type'][0]:
    26182623                        pFile.write(' Phase fraction  : %10.4g Refine? %s\n'%(hapData['Scale'][0],hapData['Scale'][1]))
    26192624                        pFile.write(' Extinction coeff: %10.4f Refine? %s\n'%(hapData['Extinction'][0],hapData['Extinction'][1]))
     
    26252630                            PrintSHPO(hapData['Pref.Ori.'])
    26262631                            pFile.write(' Penalty hkl list: %s tolerance: %.2f\n'%(controlDict[pfx+'SHhkl'],controlDict[pfx+'SHtoler']))
    2627                     PrintSize(hapData['Size'])
    2628                     PrintMuStrain(hapData['Mustrain'],SGData)
     2632                    if 'E' not in inst['Type'][0]:
     2633                        PrintSize(hapData['Size'])
     2634                        PrintMuStrain(hapData['Mustrain'],SGData)
    26292635                    PrintHStrain(hapData['HStrain'],SGData)
    26302636                    if 'Layer Disp' in hapData:
    26312637                        pFile.write(' Layer Displacement: %10.3f Refine? %s\n'%(hapData['Layer Disp'][0],hapData['Layer Disp'][1]))
    2632                     if Phases[phase]['General']['Type'] != 'magnetic':
     2638                    if Phases[phase]['General']['Type'] != 'magnetic'and 'E' not in inst['Type'][0]:
    26332639                        if hapData['Babinet']['BabA'][0]:
    26342640                            PrintBabinet(hapData['Babinet'])
     
    26902696                                    refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,StartI, 0.0,0.0,0.0,0.0, 1.0,1.0,1.0])
    26912697                                    # ... sig,gam,fotsq,fctsq, phase,icorr,alp,bet, prfo,abs,ext
     2698                            elif 'E' in inst['Type'][0]:
     2699                                pos = G2lat.Dsp2pos(inst,d)
     2700                                if limits[0] < pos < limits[1]:
     2701                                    refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,StartI, 0.0,0.0])
     2702                                    # ... sig,gam,fotsq,fctsq, phase,icorr
    26922703                    Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList),'FF':{},'Type':inst['Type'][0],'Super':ifSuper}
    26932704            elif 'HKLF' in histogram:
     
    29872998                wtFrSum[hId] = 0.
    29882999            if 'PWDR' in histogram:
    2989                 parmDict[pfx+'Scale'] = max(1.e-12,parmDict[pfx+'Scale'])
    2990                 for item in ['Scale','Extinction']:
    2991                     hapData[item][0] = parmDict[pfx+item]
    2992                     if pfx+item in sigDict and not parmDict[pfx+'LeBail']:
    2993                         PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],})
    2994                 wtFrSum[hId] += hapData['Scale'][0]*General['Mass']
    2995                 if hapData['Pref.Ori.'][0] == 'MD':
    2996                     hapData['Pref.Ori.'][1] = parmDict[pfx+'MD']
    2997                     if pfx+'MD' in sigDict and not parmDict[pfx+'LeBail']:
    2998                         PhFrExtPOSig.update({pfx+'MD':sigDict[pfx+'MD'],})
    2999                 else:                           #'SH' spherical harmonics
    3000                     for item in hapData['Pref.Ori.'][5]:
    3001                         hapData['Pref.Ori.'][5][item] = parmDict[pfx+item]
     3000                inst = Histogram['Instrument Parameters'][0]    #TODO - grab table here if present
     3001                if 'E' not in inst['Type'][0]:
     3002                    parmDict[pfx+'Scale'] = max(1.e-12,parmDict[pfx+'Scale'])
     3003                    for item in ['Scale','Extinction']:
     3004                        hapData[item][0] = parmDict[pfx+item]
    30023005                        if pfx+item in sigDict and not parmDict[pfx+'LeBail']:
    30033006                            PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],})
    3004                 SizeMuStrSig.update({pfx+'Mustrain':[[0,0,0],[0 for i in range(len(hapData['Mustrain'][4]))]],
    3005                     pfx+'Size':[[0,0,0],[0 for i in range(len(hapData['Size'][4]))]],
    3006                     pfx+'HStrain':{}})                 
    3007                 for item in ['Mustrain','Size']:
    3008                     hapData[item][1][2] = parmDict[pfx+item+';mx']
    3009 #                    hapData[item][1][2] = min(1.,max(0.,hapData[item][1][2]))
    3010                     if pfx+item+';mx' in sigDict:
    3011                         SizeMuStrSig[pfx+item][0][2] = sigDict[pfx+item+';mx']
    3012                     if hapData[item][0] in ['isotropic','uniaxial']:                   
    3013                         hapData[item][1][0] = parmDict[pfx+item+';i']
    3014                         if item == 'Size':
    3015                             hapData[item][1][0] = min(10.,max(0.001,hapData[item][1][0]))
    3016                         if pfx+item+';i' in sigDict:
    3017                             SizeMuStrSig[pfx+item][0][0] = sigDict[pfx+item+';i']
    3018                         if hapData[item][0] == 'uniaxial':
    3019                             hapData[item][1][1] = parmDict[pfx+item+';a']
     3007                    wtFrSum[hId] += hapData['Scale'][0]*General['Mass']
     3008                    if hapData['Pref.Ori.'][0] == 'MD':
     3009                        hapData['Pref.Ori.'][1] = parmDict[pfx+'MD']
     3010                        if pfx+'MD' in sigDict and not parmDict[pfx+'LeBail']:
     3011                            PhFrExtPOSig.update({pfx+'MD':sigDict[pfx+'MD'],})
     3012                    else:                           #'SH' spherical harmonics
     3013                        for item in hapData['Pref.Ori.'][5]:
     3014                            hapData['Pref.Ori.'][5][item] = parmDict[pfx+item]
     3015                            if pfx+item in sigDict and not parmDict[pfx+'LeBail']:
     3016                                PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],})
     3017                    SizeMuStrSig.update({pfx+'Mustrain':[[0,0,0],[0 for i in range(len(hapData['Mustrain'][4]))]],
     3018                        pfx+'Size':[[0,0,0],[0 for i in range(len(hapData['Size'][4]))]],pfx+'HStrain':{}})                 
     3019                    for item in ['Mustrain','Size']:
     3020                        hapData[item][1][2] = parmDict[pfx+item+';mx']
     3021    #                    hapData[item][1][2] = min(1.,max(0.,hapData[item][1][2]))
     3022                        if pfx+item+';mx' in sigDict:
     3023                            SizeMuStrSig[pfx+item][0][2] = sigDict[pfx+item+';mx']
     3024                        if hapData[item][0] in ['isotropic','uniaxial']:                   
     3025                            hapData[item][1][0] = parmDict[pfx+item+';i']
    30203026                            if item == 'Size':
    3021                                 hapData[item][1][1] = min(10.,max(0.001,hapData[item][1][1]))                       
    3022                             if pfx+item+';a' in sigDict:
    3023                                 SizeMuStrSig[pfx+item][0][1] = sigDict[pfx+item+';a']
    3024                     else:       #generalized for mustrain or ellipsoidal for size
    3025                         Nterms = len(hapData[item][4])
    3026                         for i in range(Nterms):
    3027                             sfx = ';'+str(i)
    3028                             hapData[item][4][i] = parmDict[pfx+item+sfx]
    3029                             if pfx+item+sfx in sigDict:
    3030                                 SizeMuStrSig[pfx+item][1][i] = sigDict[pfx+item+sfx]
     3027                                hapData[item][1][0] = min(10.,max(0.001,hapData[item][1][0]))
     3028                            if pfx+item+';i' in sigDict:
     3029                                SizeMuStrSig[pfx+item][0][0] = sigDict[pfx+item+';i']
     3030                            if hapData[item][0] == 'uniaxial':
     3031                                hapData[item][1][1] = parmDict[pfx+item+';a']
     3032                                if item == 'Size':
     3033                                    hapData[item][1][1] = min(10.,max(0.001,hapData[item][1][1]))                       
     3034                                if pfx+item+';a' in sigDict:
     3035                                    SizeMuStrSig[pfx+item][0][1] = sigDict[pfx+item+';a']
     3036                        else:       #generalized for mustrain or ellipsoidal for size
     3037                            Nterms = len(hapData[item][4])
     3038                            for i in range(Nterms):
     3039                                sfx = ';'+str(i)
     3040                                hapData[item][4][i] = parmDict[pfx+item+sfx]
     3041                                if pfx+item+sfx in sigDict:
     3042                                    SizeMuStrSig[pfx+item][1][i] = sigDict[pfx+item+sfx]
     3043                else:
     3044                    SizeMuStrSig.update({pfx+'HStrain':{}})                 
    30313045                names = G2spc.HStrainNames(SGData)
    30323046                for i,name in enumerate(names):
     
    30383052                    if pfx+'LayerDisp' in sigDict:
    30393053                        SizeMuStrSig[pfx+'LayerDisp'] = sigDict[pfx+'LayerDisp']
    3040                 if Phases[phase]['General']['Type'] != 'magnetic':
     3054                if Phases[phase]['General']['Type'] != 'magnetic' and 'E' not in inst['Type'][0]:
    30413055                    for name in ['BabA','BabU']:
    30423056                        hapData['Babinet'][name][0] = parmDict[pfx+name]
     
    31043118                    pFile.write(' Bragg intensity sum = %.3g\n'%(Histogram['Residuals'][pfx+'sumInt']))
    31053119                   
    3106                     if parmDict[pfx+'LeBail']:
     3120                    if parmDict[pfx+'LeBail'] or 'E' in Inst['Type'][0]:
    31073121                        pFile.write(' Performed LeBail extraction for phase %s in histogram %s\n'%(phase,histogram))
    3108                     else:
    3109                         # if calcControls != None:    #skipped in seqRefine
    3110                         #     if 'X'in Inst['Type'][0]:
    3111                         #         PrintFprime(calcControls['FFtables'],hfx,pFile)
    3112                         #     elif 'NC' in Inst['Type'][0]:
    3113                         #         PrintBlength(calcControls['BLtables'],Inst['Lam'][1],pFile)
     3122                    elif 'E' not in Inst['Type'][0]:
    31143123                        if pfx+'Scale' in PhFrExtPOSig:
    31153124                            wtFr = hapData['Scale'][0]*General['Mass']/wtFrSum[hId]
     
    31243133                        else:
    31253134                            PrintSHPOAndSig(pfx,hapData['Pref.Ori.'],PhFrExtPOSig)
    3126                     PrintSizeAndSig(hapData['Size'],SizeMuStrSig[pfx+'Size'])
    3127                     PrintMuStrainAndSig(hapData['Mustrain'],SizeMuStrSig[pfx+'Mustrain'],SGData)
     3135                    if 'E' not in  Inst['Type'][0]:       
     3136                        PrintSizeAndSig(hapData['Size'],SizeMuStrSig[pfx+'Size'])
     3137                        PrintMuStrainAndSig(hapData['Mustrain'],SizeMuStrSig[pfx+'Mustrain'],SGData)
    31283138                    PrintHStrainAndSig(hapData['HStrain'],SizeMuStrSig[pfx+'HStrain'],SGData)
    31293139                    if pfx+'LayerDisp' in SizeMuStrSig:
    31303140                        pFile.write(' Layer displacement : %10.3f, sig %10.3f\n'%(hapData['Layer Disp'][0],SizeMuStrSig[pfx+'LayerDisp']))           
    3131                     if Phases[phase]['General']['Type'] != 'magnetic' and not parmDict[pfx+'LeBail']:
     3141                    if Phases[phase]['General']['Type'] != 'magnetic' and not parmDict[pfx+'LeBail'] and 'E' not in Inst['Type'][0]:
    31323142                        if len(BabSig):
    31333143                            PrintBabinetAndSig(pfx,hapData['Babinet'],BabSig)
     
    32103220    def GetInstParms(hId,Inst):
    32113221        #patch
    3212         if 'Z' not in Inst:
     3222        dataType = Inst['Type'][0]
     3223        if 'Z' not in Inst and 'E' not in dataType:
    32133224            Inst['Z'] = [0.0,0.0,False]
    3214         dataType = Inst['Type'][0]
    32153225        instDict = {}
    32163226        insVary = []
     
    32193229        insKeys.sort()
    32203230        for item in insKeys:
    3221             if item in 'Azimuth':
     3231            if 'Azimuth' in item:
    32223232                continue
    32233233            insName = pfx+item
     
    32373247            if not instDict[pfx+'beta-0'] and not instDict[pfx+'beta-1']:
    32383248                instDict[pfx+'beta-1'] = 1.0
     3249        elif 'E' in dataType:
     3250            pass
    32393251        return dataType,instDict,insVary
    32403252       
     
    33983410                pFile.write('\n Histogram: %s histogram Id: %d\n'%(histogram,hId))
    33993411                pFile.write(135*'='+'\n')
    3400                 Units = {'C':' deg','T':' msec','B':' deg'}
     3412                Units = {'C':' deg','T':' msec','B':' deg','E':'keV'}
    34013413                units = Units[controlDict[pfx+'histType'][2]]
    34023414                Limits = controlDict[pfx+'Limits']
  • trunk/GSASIIstrMath.py

    r5038 r5112  
    447447                hId = Histograms[hist]['hId']
    448448                phfx = '%d:%d:'%(pId,hId)
    449                 if calcControls[phfx+'poType'] == 'SH':
     449                if calcControls.get(phfx+'poType','') == 'SH':
    450450                    toler = calcControls[phfx+'SHtoler']
    451451                    wt = 1./toler**2
     
    26922692                Sum += parmDict[phfx+'Mustrain;'+str(i)]*strm
    26932693            Mgam = 0.018*refl[4+im]**2*tand(refl[5+im]/2.)*np.sqrt(Sum)/np.pi
     2694    elif 'E' in calcControls[hfx+'histType']:
     2695        return 0.,0.
    26942696    elif 'T' in calcControls[hfx+'histType']:       #All checked & OK
    26952697        #crystallite size
     
    28022804        gamDict[phfx+'Mustrain;mx'] = Mgam
    28032805        sigDict[phfx+'Mustrain;mx'] = -2.*Mgam**2*(1.-parmDict[phfx+'Mustrain;mx'])/ateln2
     2806    elif 'E' in calcControls[hfx+'histType']:
     2807        return {},{}
    28042808    else:   #'T'OF - All checked & OK
    28052809        if calcControls[phfx+'SizeType'] == 'isotropic':    #OK
     
    31983202            parmDict[hfx+'sig-2']*refl[4+im]**4+parmDict[hfx+'sig-q']*refl[4+im]
    31993203        gam = parmDict[hfx+'X']*refl[4+im]+parmDict[hfx+'Y']*refl[4+im]**2+parmDict[hfx+'Z']
     3204        Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)
     3205        sig += Ssig
     3206        gam += Sgam
     3207        return sig,gam
     3208   
     3209    def GetReflSigGamED(refl,im,G,GB,phfx,calcControls,parmDict):
     3210        sig = parmDict[hfx+'A']*refl[4+im]**2+parmDict[hfx+'B']*refl[4+im]+parmDict[hfx+'C']
     3211        gam = 0.001
    32003212        Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    32013213        sig += Ssig
     
    35883600            if 'T' in calcControls[hfx+'histType']:
    35893601                wave = refl[14+im]
    3590             dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)
     3602            if 'E' in calcControls[hfx+'histType']:
     3603                dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = [0.,0.,0.,0.,0.,0.,0.,0.]
     3604            else:
     3605                dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)
    35913606            if 'C' in calcControls[hfx+'histType']:        #CW powder
    35923607                Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl)
     
    35953610            elif 'B' in calcControls[hfx+'histType']:
    35963611                Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im]/1.e4,refl[7+im]/100.)
     3612            elif 'E' in calcControls[hfx+'histType']:
     3613                Wd,fmin,fmax = G2pwd.getWidthsED(refl[5+im],refl[10+im])
    35973614            iBeg = np.searchsorted(x,refl[5+im]-fmin)
    35983615            iFin = np.searchsorted(x,refl[5+im]+fmax)
     
    36423659                for i in range(6):
    36433660                    dMdpk[i] = refl[11+im]*refl[9+im]*dMdipk[i]
    3644                 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4]/1.e4,'gam':dMdpk[5]/100.}           
     3661                dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4]/1.e4,'gam':dMdpk[5]/100.}   
     3662            elif 'E' in calcControls[hfx+'histType']:
     3663                lenBF = iFin-iBeg
     3664                if lenBF < 0:   #bad peak coeff
     3665                    break
     3666                dMdpk = np.zeros(shape=(4,lenBF))
     3667                dMdipk = G2pwd.getdPsVoigt(refl[5+im],refl[12+im]*10**4,0.001,ma.getdata(x[iBeg:iFin]))
     3668                for i in range(4):
     3669                    dMdpk[i] = refl[11+im]*refl[9+im]*dMdipk[i]
     3670                dervDict = {'int':dMdpk[0],'pos':-dMdpk[1],'sig':dMdpk[4]*1.e4}   
    36453671            if Phase['General'].get('doPawley'):
    36463672                dMdpw = np.zeros(len(x))
     
    36863712                    hfx+'alpha-0':[1.0,'alp'],hfx+'alpha-1':[tanth,'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[tanth,'bet'],
    36873713                    hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],hfx+'DisplaceX':[dpdX,'pos'],hfx+'DisplaceY':[dpdY,'pos']}
     3714            elif 'E' in calcControls[hfx+'histType']:
     3715                dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY,dpdV = GetReflPosDerv(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict)
     3716                names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'],hfx+'Lam':[dpdw,'pos'],
     3717                    hfx+'Zero':[dpdZ,'pos'],hfx+'X':[1.0/costh,'gam'],hfx+'Y':[tanth,'gam'],hfx+'Z':[1.0,'gam'],
     3718                    hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'],hfx+'Polariz.':[dIdpola,'int'],
     3719                    hfx+'alpha-0':[1.0,'alp'],hfx+'alpha-1':[tanth,'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[tanth,'bet'],
     3720                    hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],hfx+'DisplaceX':[dpdX,'pos'],hfx+'DisplaceY':[dpdY,'pos']}
     3721               
    36883722            for name in names:
    36893723                item = names[name]
  • trunk/ISODISTORT.py

    r5070 r5112  
    3232            print('Could not open URL')
    3333
    34 def GetISODISTORT(Phase,parentcif):
     34def GetISODISTORT(Phase,parentcif,method=1):
    3535    '''Run Stokes & Campbell ISODISTORT.
    3636    This requires doing a post to the BYU upload site with a cif file, which returns a BYU local
     
    7474    out2 = requests.post(isoformsite,up2).text
    7575   
     76    ISOdata = Phase['ISODISTORT']
    7677    #recover required info for the distortion search; includes info from cif file (no longer needed)
    77    
    78     try:
    79         pos = out2.index('<p><FORM')
    80     except ValueError:
    81         HandleError(out2)
    82         return [],[]
    83     data = {}
    84     while True:
     78    if method == 1:
    8579        try:
    86             posB = out2[pos:].index('INPUT TYPE')+pos
    87             posF = out2[posB:].index('>')+posB
    88             items = out2[posB:posF].split('=',3)
    89             name = items[2].split()[0].replace('"','')
    90             if 'isosystem' in name:
     80            pos = out2.index('<p><FORM')
     81        except ValueError:
     82            HandleError(out2)
     83            return [],[]
     84        data = {}
     85        while True:
     86            try:
     87                posB = out2[pos:].index('INPUT TYPE')+pos
     88                posF = out2[posB:].index('>')+posB
     89                items = out2[posB:posF].split('=',3)
     90                name = items[2].split()[0].replace('"','')
     91                if 'isosystem' in name:
     92                    break
     93                vals = items[3].replace('"','')
     94                data[name] = vals
     95                pos = posF
     96            except ValueError:
    9197                break
    92             vals = items[3].replace('"','')
    93             data[name] = vals
    94             pos = posF
    95         except ValueError:
    96             break
    97     #save copy for future use
    98     data2 = copy.deepcopy(data)
    99            
    100     #no limits on space group or lattice
    101    
    102     data['isosubgroup'] = 'no choice'
    103     data['isolattice'] = 'no choice'
    104     data['isoplattice'] = 'no choice'
     98        #save copy for future use
     99        data2 = copy.deepcopy(data)
     100               
     101        #no limits on space group or lattice
     102       
     103        data['isosubgroup'] = 'no choice'
     104        data['isolattice'] = 'no choice'
     105        data['isoplattice'] = 'no choice'
    105106   
    106107    #do the distortion search - result is radio button list of choices
     
    122123            posF = out3[pos:].index('<BR>')+pos
    123124            num += 1
    124             items = out3[pos:posF].split('=',2)
    125             radio['orderparam%d'%num] = items[2].replace('"','')
     125            items = out3[pos:posF].split('=',2)[2].split('>')[0]
     126            radio['orderparam%d'%num] = items.replace('"','')
    126127            pos = out3[posF:].index('RADIO')+posF
    127128        except ValueError:
  • trunk/imports/G2phase_CIF.py

    r5083 r5112  
    235235                else:
    236236                    SpGrp = SpGrp.replace('_','')
     237                    SpGrp = G2spc.fullHM2shortHM(SpGrp)
    237238                    self.Phase['General']['Type'] = 'nuclear'
    238239#process space group symbol
     
    242243                if SpGrpNorm:
    243244                    E,SGData = G2spc.SpcGroup(SpGrpNorm)
    244             if E:   #try lookup from number  - found full symbol?               
    245                 SpGrpNorm = G2spc.spgbyNum[int(blk.get('_symmetry_Int_Tables_number'))]
    246                 if SpGrpNorm:
    247                     E,SGData = G2spc.SpcGroup(SpGrpNorm)
     245            # if E:   #try lookup from number  - found full symbol?               
     246            #     SpGrpNorm = G2spc.spgbyNum[int(blk.get('_symmetry_Int_Tables_number'))]
     247            #     if SpGrpNorm:
     248            #         E,SGData = G2spc.SpcGroup(SpGrpNorm)
    248249            # nope, try the space group "out of the Box"
    249250            if E:
  • trunk/imports/G2pwd_fxye.py

    r4192 r5112  
    175175            S = File.readline()
    176176            j = 0
     177            Ecoef = np.zeros(4)
     178            if 'EDS' in cons[4]:
     179               Ecoef = np.fromstring(' '.join(cons[5:9]),sep=' ')
    177180            while S and S[:4] != 'BANK' and S[0] != '#':
    178181                if 'TIME_MAP' in S or '\x1a' in S:
     
    182185                        break
    183186                    xi = start+step*j
     187                    if 'EDS' in Bank:   #Energy dispersive - convert CN to EkeV
     188                        xi = Ecoef[0]+(Ecoef[1]+(Ecoef[2]+Ecoef[3]*j)*j)*j
    184189                    ni = max(sint(S[i:i+2]),1)
    185190                    yi = max(sfloat(S[i+2:i+8]),0.0)
Note: See TracChangeset for help on using the changeset viewer.