Changeset 1107


Ignore:
Timestamp:
Oct 15, 2013 3:01:21 PM (8 years ago)
Author:
vondreele
Message:

make reflist np.array
fix bug - hfx+'Type' needs to be in parmDict

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r1106 r1107  
    31143114        G,g = G2lat.cell2Gmat(Cell)
    31153115        for iref,ref in enumerate(reflData['RefList']):
    3116             H = ref[:3]
     3116            H = list(ref[:3])
    31173117            ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G))
    31183118            iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData)
     
    48914891            reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    48924892            reflData = reflSets[phaseName]
    4893             if isinstance(reflDict,list):       #patch for old reflection data
     4893            if isinstance(reflData,list):       #patch for old reflection data
    48944894                RefData = {'RefList':[],'Uniq':[],'Phi':[],'FF':[]}
    4895                 for ref in reflDict:
     4895                for ref in reflData:
    48964896                    RefData['RefList'].append(ref[:11]+[ref[13],])
    48974897                    RefData['Uniq'].append(ref[11])
    48984898                    RefData['Phi'].append(ref[12])
    48994899                    RefData['FF'].append(ref[14])
    4900                 reflDict = RefData
     4900                RefData['RefList'] = np.array(RefData['RefList'])
     4901                reflData = RefData
    49014902        elif 'HKLF' in reflName:
    49024903            PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
     
    49914992                    RefData['Phi'].append(ref[12])
    49924993                    RefData['FF'].append(ref[14])
     4994                RefData['RefList'] = np.array(RefData['RefList'])
    49934995                reflDict = RefData
    49944996        elif 'HKLF' in reflName:
  • trunk/GSASIIplot.py

    r1106 r1107  
    883883                except TypeError:
    884884                    peaks = Phases[phase]
    885                 if not peaks:
     885                if not len(peaks):
    886886                    continue
    887887                peak = np.array([[peak[4],peak[5]] for peak in peaks])
  • trunk/GSASIIpwdGUI.py

    r1106 r1107  
    20352035            I100 *= 100.0/Imax
    20362036        refs = np.vstack((refList.T[:11],I100)).T
    2037     for i in range(len(refList)): rowLabels.append(str(i))
     2037    for i in range(len(refs)): rowLabels.append(str(i))
    20382038    if HKLF:
    20392039        colLabels = ['H','K','L','mul','d','Fosq','sig','Fcsq','FoTsq','FcTsq','phase',]
  • trunk/GSASIIstrIO.py

    r1106 r1107  
    303303                        RefData['Phi'].append(ref[12])
    304304                        RefData['FF'].append(ref[14])
     305                    RefData['RefList'] = np.array(RefData['RefList'])
    305306                    datum[1][1] = RefData
    306307#end patch
     
    17721773                        else:
    17731774                            raise ValueError
    1774                     Histogram['Reflection Lists'][phase] = {'RefList':refList,'Uniq':Uniq,'Phi':Phi,'FF':FF}
     1775                    Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList),
     1776                        'Uniq':Uniq,'Phi':Phi,'FF':FF}
    17751777            elif 'HKLF' in histogram:
    17761778                inst = Histogram['Instrument Parameters'][0]
     
    17781780                hfx = ':%d:'%(hId)
    17791781                for item in inst:
    1780                     if type(inst) is not list: continue # skip over non-refined items (such as InstName)
     1782                    if type(inst) is not list and item != 'Type': continue # skip over non-refined items (such as InstName)
    17811783                    hapDict[hfx+item] = inst[item][1]
    17821784                pfx = str(pId)+':'+str(hId)+':'
  • trunk/GSASIIstrMath.py

    r1106 r1107  
    529529   
    530530def StructureFactor(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
     531    ''' Compute structure factors for all h,k,l for phase
     532    puts the result, F^2, in each ref[8] in refList
     533    input:
     534   
     535    :param dict refDict: where
     536        'RefList' list where each ref = h,k,l,m,d,...
     537        'Uniq' list of [equiv h,k,l]
     538        'Phi' list of phase[equiv]
     539        'FF' dict of form factors - filed in below
     540    :param np.array G:      reciprocal metric tensor
     541    :param str pfx:    phase id string
     542    :param dict SGData: space group info. dictionary output from SpcGroup
     543    :param dict calcControls:
     544    :param dict ParmDict:
     545
     546    '''       
     547    twopi = 2.0*np.pi
     548    twopisq = 2.0*np.pi**2
     549    phfx = pfx.split(':')[0]+hfx
     550    ast = np.sqrt(np.diag(G))
     551    Mast = twopisq*np.multiply.outer(ast,ast)
     552    FFtables = calcControls['FFtables']
     553    BLtables = calcControls['BLtables']
     554    Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict)
     555    FF = np.zeros(len(Tdata))
     556    if 'N' in calcControls[hfx+'histType']:
     557        FP,FPP = G2el.BlenRes(Tdata,BLtables,parmDict[hfx+'Lam'])
     558    else:
     559        FP = np.array([FFtables[El][hfx+'FP'] for El in Tdata])
     560        FPP = np.array([FFtables[El][hfx+'FPP'] for El in Tdata])
     561    Uij = np.array(G2lat.U6toUij(Uijdata))
     562    bij = Mast*Uij.T
     563    for iref,refl in enumerate(refDict['RefList']):
     564        fbs = np.array([0,0])
     565        H = refl[:3]
     566        SQ = 1./(2.*refl[4])**2
     567        SQfactor = 4.0*SQ*twopisq
     568        Bab = parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor)
     569        if not len(refDict['FF'][iref]):                #no form factors
     570            if 'N' in calcControls[hfx+'histType']:
     571                refDict['FF'][iref] = G2el.getBLvalues(BLtables)
     572            else:       #'X'
     573                refDict['FF'][iref] = G2el.getFFvalues(FFtables,SQ)
     574        for i,El in enumerate(Tdata):
     575            FF[i] = refDict['FF'][iref][El]           
     576        phase = twopi*(np.inner(refDict['Uniq'][iref],(dXdata.T+Xdata.T))+refDict['Phi'][iref][:,np.newaxis])
     577        sinp = np.sin(phase)
     578        cosp = np.cos(phase)
     579        occ = Mdata*Fdata/len(refDict['Uniq'][iref])
     580        biso = -SQfactor*Uisodata
     581        Tiso = np.where(biso<1.,np.exp(biso),1.0)
     582        HbH = np.array([-np.inner(h,np.inner(bij,h)) for h in refDict['Uniq'][iref]])
     583        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)
     584        Tcorr = Tiso*Tuij
     585        fa = np.array([(FF+FP-Bab)*occ*cosp*Tcorr,-FPP*occ*sinp*Tcorr])
     586        fas = np.sum(np.sum(fa,axis=1),axis=1)        #real
     587        if not SGData['SGInv']:
     588            fb = np.array([(FF+FP-Bab)*occ*sinp*Tcorr,FPP*occ*cosp*Tcorr])
     589            fbs = np.sum(np.sum(fb,axis=1),axis=1)
     590        fasq = fas**2
     591        fbsq = fbs**2        #imaginary
     592        refl[9] = np.sum(fasq)+np.sum(fbsq)
     593        refl[10] = atan2d(fbs[0],fas[0])
     594   
     595def StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
    531596    ''' Compute structure factors for all h,k,l for phase
    532597    puts the result, F^2, in each ref[8] in refList
  • trunk/imports/G2sfact.py

    r1106 r1107  
    5555                self.RefDict['Phi'].append([])
    5656                self.RefDict['FF'].append({})
     57            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
    5758            self.UpdateControls(Type='Fosq',FcalcPresent=False) # set Fobs type & if Fcalc values are loaded
    5859            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
     
    104105                self.RefDict['Phi'].append([])
    105106                self.RefDict['FF'].append({})
     107            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
    106108            self.UpdateControls(Type='Fosq',FcalcPresent=False) # set Fobs type & if Fcalc values are loaded
    107109            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
  • trunk/imports/G2sfact_CIF.py

    r1106 r1107  
    154154                        HKL.append('.')
    155155                #h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
    156                 ref = HKL+[0,0,0,0,0,0,0,0,[],[],0,{}]
    157 #                ref = HKL+[0,0,0,0,0,0,0,0,0]
     156                ref = HKL+[0,0,0,0,0, 0,0,0,0,0, 0]
    158157                if '_refln_f_squared_meas' in itemkeys:
    159158                    try:
     
    217216                self.RefDict['Phi'].append([])
    218217                self.RefDict['FF'].append({})
     218            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
    219219            self.UpdateControls(Type='Fosq',FcalcPresent=FcalcPresent) # set Fobs type & if Fcalc values are loaded
    220220            if blk.get('_diffrn_radiation_probe'):
Note: See TracChangeset for help on using the changeset viewer.