Changeset 2367 for trunk


Ignore:
Timestamp:
Jul 9, 2016 10:45:12 AM (9 years ago)
Author:
vondreele
Message:

add display of inverse pole figure for each histogram - works but are they valid?

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIddataGUI.py

    r2154 r2367  
    101101       
    102102        plotSizer = wx.BoxSizer(wx.VERTICAL)
    103         choice = ['None','Mustrain','Size','Preferred orientation']
     103        choice = ['None','Mustrain','Size','Preferred orientation','Inv. pole figure']
    104104        plotSel = wx.RadioBox(DData,wx.ID_ANY,'Select plot type:',choices=choice,
    105105            majorDimension=1,style=wx.RA_SPECIFY_COLS)
     
    115115            poAxis.Bind(wx.EVT_KILL_FOCUS,OnPOhkl)
    116116            POhklSizer.Add(poAxis,0,WACV)
    117             plotSizer.Add(POhklSizer)           
     117            plotSizer.Add(POhklSizer)
     118        elif generalData['Data plot type'] == 'Inv. pole figure':
     119            pass    #might need something here?     
    118120        return plotSizer
    119121       
  • TabularUnified trunk/GSASIIlattice.py

    r2233 r2367  
    371371    return A,B
    372372   
    373 
    374373def cell2AB(cell):
    375374    """Computes orthogonalization matrix from unit cell constants
     
    392391    B = nl.inv(A)
    393392    return A,B
     393   
     394def HKL2SpAng(H,cell,SGData):
     395    """Computes spherical coords for hkls; view along 001
     396
     397    :param array H: arrays of hkl
     398    :param tuple cell: a,b,c, alpha, beta, gamma (degrees)
     399    :param dict SGData: space group dictionary
     400    :returns: arrays of r,phi,psi (radius,inclination,azimuth) about 001
     401    """
     402    A,B = cell2AB(cell)
     403    xH = np.inner(B,H)
     404    r = np.sqrt(np.sum(xH**2,axis=0))
     405    phi = acosd(xH[2]/r)
     406    psi = atan2d(xH[1],xH[0])
     407    phi = np.where(phi>90.,180.-phi,phi)
     408#    GSASIIpath.IPyBreak()
     409    return r,phi,psi
    394410   
    395411def U6toUij(U6):
  • TabularUnified trunk/GSASIIplot.py

    r2366 r2367  
    30123012    '''
    30133013   
    3014     PatternId = G2frame.PatternId
     3014    import scipy.interpolate as si
    30153015    generalData = data['General']
    30163016    SGData = generalData['SGData']
     
    30193019        ptx.pyqlmninit()
    30203020        Start = False
    3021 #    MuStrKeys = G2spc.MustrainNames(SGData)
    30223021    cell = generalData['Cell'][1:]
    30233022    A,B = G2lat.cell2AB(cell[:6])
     
    30263025    phase = generalData['Name']
    30273026    plotType = generalData['Data plot type']
    3028     plotDict = {'Mustrain':'Mustrain','Size':'Size','Preferred orientation':'Pref.Ori.'}
     3027    plotDict = {'Mustrain':'Mustrain','Size':'Size','Preferred orientation':'Pref.Ori.','Inv. pole figure':''}
    30293028    for ptype in plotDict:
    30303029        G2frame.G2plotNB.Delete(ptype)
     
    30603059    Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI))
    30613060    try:        #temp patch instead of 'mustrain' for old files with 'microstrain'
    3062         coeff = useList[hist][plotDict[plotType]]
     3061        if plotDict[plotType]:
     3062            coeff = useList[hist][plotDict[plotType]]
    30633063    except KeyError:
    30643064        return
     
    31433143            Plot.set_ylabel(r'Y, $\mu$strain')
    31443144            Plot.set_zlabel(r'Z, $\mu$strain')
    3145     else:
     3145    elif plotType in ['Preferred orientation',]:
    31463146        h,k,l = generalData['POhkl']
    31473147        if coeff[0] == 'MD':
     
    31633163            Plot.set_xlabel(r'$\psi$',fontsize=16)
    31643164            Plot.set_ylabel('MRD',fontsize=14)
     3165    elif plotType in ['Inv. pole figure',]:
     3166        Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,hist)
     3167        rId = G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists')
     3168        RefData = G2frame.PatternTree.GetItemPyData(rId)[phase]
     3169        Type = RefData['Type']
     3170        Refs = RefData['RefList'].T
     3171        ns = 0
     3172        if RefData['Super']:
     3173            ns = 1
     3174        if 'C' in Type:
     3175            obsRMD = Refs[12+ns]
     3176        else:
     3177            obsRMD = Refs[15+ns]
     3178        ObsIVP = []
     3179        Phi = []
     3180        Beta = []
     3181        Rmd = []
     3182        refSets = [G2spc.GenHKLf(hkl,SGData)[2] for hkl in Refs[:3].T]
     3183        refSets = [[np.fromstring(item.strip('[]').replace('-0','0'),sep=' ')    \
     3184            for item in list(set([str(ref) for ref in refSet]))] for refSet in refSets]
     3185        for ir,refSet in enumerate(refSets):
     3186            refSet = [np.where(ref[2]<0,-1*ref,ref) for ref in refSet]
     3187            refSets[ir] = refSet
     3188            r,beta,phi = G2lat.HKL2SpAng(refSet,cell[:6],SGData)    #radius, inclination, azimuth
     3189#            beta,phi = G2lat.CrsAng(np.array(refSet),cell[:6],SGData)
     3190            phi *= np.pi/180.
     3191            beta *= np.pi/180.
     3192            Phi += list(phi)
     3193            Beta += list(beta)
     3194            Rmd += len(phi)*[obsRMD[ir],]
     3195        Beta = np.abs(np.array(Beta))
     3196        Phi = np.array(Phi)
     3197        Phi=np.where(Phi<0.,Phi+2.*np.pi,Phi)
     3198        Rmd = np.array(Rmd)
     3199        Rmd = np.where(Rmd<0.,0.,Rmd)
     3200        y,x = np.sin(Beta)*np.cos(Phi),np.sin(Beta)*np.sin(Phi)       
     3201        sq2 = 1.0/math.sqrt(2.0)
     3202        npts = 201
     3203        X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts))
     3204        R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten()
     3205        P=np.where(P<0.,P+360.,P)
     3206        R = np.where(R <= 1.,2.*npatand(R),0.0)
     3207        Z = np.zeros_like(R)
     3208#        GSASIIpath.IPyBreak()
     3209        try:
     3210            lut = si.SmoothSphereBivariateSpline(Beta,Phi,Rmd,s=len(Beta))
     3211            Z = [lut(r*np.pi/180.,p*np.pi/180.) for r,p in zip(list(R),list(P))]
     3212        except AttributeError:
     3213            print 'scipy needs to be 0.11.0 or newer'
     3214            return       
     3215        Z = np.reshape(Z,(npts,npts))
     3216        try:
     3217            CS = Plot.contour(Y,X,Z,aspect='equal')
     3218            Plot.clabel(CS,fontsize=9,inline=1)
     3219        except ValueError:
     3220            pass
     3221        Img = Plot.imshow(Z.T,aspect='equal',cmap=G2frame.ContourColor,extent=[-1,1,-1,1])
     3222        Plot.plot(x,y,'+')
     3223        Page.figure.colorbar(Img)
     3224        Plot.axis('off')
     3225        Plot.set_title('0 0 1 Inverse pole figure for %s'%(phase))
     3226        Plot.set_xlabel(G2frame.Projection.capitalize()+' projection')
     3227       
    31653228    Page.canvas.draw()
    31663229   
  • TabularUnified trunk/GSASIIspc.py

    r2289 r2367  
    11531153    else:
    11541154        return zip(XYZEquiv,Idup,Cell)
     1155       
     1156def GenHKL(HKL,SGData):
     1157    ''' Generates all equivlent reflections including Friedel pairs
     1158    :param HKL:  [h,k,l] must be integral values
     1159    :param SGData: space group data obtained from SpcGroup
     1160    :returns: array Uniq: equivalent reflections
     1161    '''
     1162   
     1163    Ops = SGData['SGOps']
     1164    OpM = np.array([op[0] for op in Ops])
     1165    Uniq = np.inner(OpM,HKL)
     1166    Uniq = list(Uniq)+list(-1*Uniq)
     1167    return np.array(Uniq)
    11551168
    11561169def GenHKLf(HKL,SGData):
Note: See TracChangeset for help on using the changeset viewer.