Changeset 2766


Ignore:
Timestamp:
Mar 30, 2017 1:31:01 PM (8 years ago)
Author:
vondreele
Message:

add display of optional vertical lines to PlotXY (used for reflectometry model boundaries)
fix getCellEsd - bad analytic math; now done empirically - now works

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIplot.py

    r2764 r2766  
    28202820           
    28212821def PlotXY(G2frame,XY,XY2=None,labelX='X',labelY='Y',newPlot=False,
    2822     Title='',lines=False,names=[],names2=[]):
     2822    Title='',lines=False,names=[],names2=[],vertLines=[]):
    28232823    '''simple plot of xy data
    28242824   
     
    28332833    :param list of str names: legend names for each XY plot
    28342834    :param list of str names2: legend names for each XY2 plot
     2835    :param lists of vertical line x-positions list; can be one for each XY
    28352836    :return nothing
    28362837   
     
    29062907        else:
    29072908            Plot.plot(X,Y,colors[ixy%6]+'+',picker=False)
    2908     if XY2 and len(XY2):
     2909    if len(vertLines):
     2910        for ixy,X in enumerate(vertLines):
     2911            dX = Page.Offset[0]*(ixy+1)*Xmax/500.
     2912            for x in X:
     2913                Plot.axvline(x+dX,color=colors[ixy%6],dashes=(5,5),picker=False)
     2914    if XY2 is not None and len(XY2):
    29092915        for ixy,xy in enumerate(XY2):
    29102916            X,Y = XY2[ixy]
  • TabularUnified trunk/GSASIIpwdGUI.py

    r2763 r2766  
    47404740        SaveState()
    47414741        G2pwd.REFDRefine(Profile,ProfDict,Inst,Limits,Substances,data)
    4742         x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4743         ModelPlot(data,x,xr,y)
     4742#        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4743#        ModelPlot(data,x,xr,y)
    47444744        G2plt.PlotPatterns(G2frame,plotType='REFD')
    47454745        wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    47824782       
    47834783    def ModelPlot(data,x,xr,y):
     4784        nLines = len(data['Layers'])-1
     4785        linePos = np.zeros(nLines)
     4786        for ilay,layer in enumerate(data['Layers'][1:-1]):
     4787            linePos[ilay+1:] += layer['Thick'][0]
    47844788        if data['Zero']:
    47854789            XY = [[x,y],]
     
    47884792            XY = [[xr,y],]
    47894793            disLabel = r'$Distance\ from\ substrate,\ \AA$'
    4790         G2plt.PlotXY(G2frame,XY,labelX=disLabel,labelY=r'$SLD,\ 10^{10}cm^{-2}$',newPlot=False,
    4791             Title='Scattering length density',lines=True,names=[])
     4794        G2plt.PlotXY(G2frame,XY,labelX=disLabel,labelY=r'$SLD,\ 10^{10}cm^{-2}$',newPlot=True,
     4795            Title='Scattering length density',lines=True,names=[],vertLines=[linePos,])
    47924796       
    47934797    def OnUnDo(event):
     
    47974801        G2frame.dataFrame.REFDUndo.Enable(False)
    47984802        G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data)
    4799         x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4800         ModelPlot(data,x,xr,y)
     4803#        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4804#        ModelPlot(data,x,xr,y)
    48014805        G2plt.PlotPatterns(G2frame,plotType='REFD')
    48024806        wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    48224826        def OnRefPos(event):
    48234827            data['Zero'] = refpos.GetValue()
     4828            x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4829            ModelPlot(data,x,xr,y)
    48244830           
    48254831        def OnMinSel(event):
     
    49264932                return
    49274933            G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data)
    4928             x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4929             ModelPlot(data,x,xr,y)
     4934#            x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4935#            ModelPlot(data,x,xr,y)
    49304936            G2plt.PlotPatterns(G2frame,plotType='REFD')
    49314937            wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    50465052    Size = mainSizer.Fit(G2frame.dataFrame)
    50475053    Size[0] += 25
    5048     G2frame.dataFrame.setSizePosLeft(Size)   
     5054    G2frame.dataFrame.setSizePosLeft(Size)
     5055    x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     5056    ModelPlot(data,x,xr,y)
     5057   
    50495058   
    50505059################################################################################
  • TabularUnified trunk/GSASIIstrIO.py

    r2753 r2766  
    15341534def getCellEsd(pfx,SGData,A,covData):
    15351535    'needs a doc string'
    1536     dpr = 180./np.pi
    15371536    rVsq = G2lat.calc_rVsq(A)
    15381537    G,g = G2lat.A2Gmat(A)       #get recip. & real metric tensors
    1539     cell = np.array(G2lat.Gmat2cell(g))   #real cell
    1540     cellst = np.array(G2lat.Gmat2cell(G)) #recip. cell
    1541     scos = cosd(cellst[3:6])
    1542     ssin = sind(cellst[3:6])
    1543     scot = scos/ssin
    1544     rcos = cosd(cell[3:6])
    1545     rsin = sind(cell[3:6])
    1546     rcot = rcos/rsin
    15471538    RMnames = [pfx+'A0',pfx+'A1',pfx+'A2',pfx+'A3',pfx+'A4',pfx+'A5']
    15481539    varyList = covData['varyList']
     
    15591550        vcov[1,2] = vcov[2,1] = vcov[0,2]
    15601551    elif SGData['SGLaue'] in ['3R','3mR']:
    1561         vcov[0:2,0:2] = vcov[0,0]
    1562         vcov[4,4] = vcov[5,5] = vcov[3,3]
     1552        vcov[0:3,0:3] = vcov[0,0]
     1553#        vcov[4,4] = vcov[5,5] = vcov[3,3]
     1554        vcov[3:6,3:6] = vcov[3,3]
    15631555        vcov[0:3,3:6] = vcov[0,3]
    15641556        vcov[3:6,0:3] = vcov[3,0]
    1565     Ax = np.array(A)
    1566     Ax[3:] /= 2.
    1567     drVdA = np.array([
    1568         Ax[1]*Ax[2]-Ax[5]**2,
    1569         Ax[0]*Ax[2]-Ax[4]**2,
    1570         Ax[0]*Ax[1]-Ax[3]**2,
    1571         Ax[4]*Ax[5]-Ax[2]*Ax[3],
    1572         Ax[3]*Ax[5]-Ax[1]*Ax[4],
    1573         Ax[3]*Ax[4]-Ax[0]*Ax[5]])
     1557    delt = 1.e-9
     1558    drVdA = np.zeros(6)
     1559    for i in range(6):
     1560        A[i] += delt
     1561        drVdA[i] = G2lat.calc_rVsq(A)
     1562        A[i] -= 2*delt
     1563        drVdA[i] -= G2lat.calc_rVsq(A)
     1564        A[i] += delt
     1565    drVdA /= 2.*delt   
    15741566    srcvlsq = np.inner(drVdA,np.inner(drVdA,vcov))
    15751567    Vol = 1/np.sqrt(rVsq)
    15761568    sigVol = Vol**3*np.sqrt(srcvlsq)/2.         #ok - checks with GSAS
    15771569   
    1578     R123 = Ax[0]*Ax[1]*Ax[2]
    1579     dsasdg = np.zeros((3,6))
    1580     dadg = np.zeros((6,6))
    1581     for i0 in range(3):         #0  1   2
    1582         i1 = (i0+1)%3           #1  2   0
    1583         i2 = (i1+1)%3           #2  0   1
    1584         i3 = 5-i2               #3  5   4
    1585         i4 = 5-i1               #4  3   5
    1586         i5 = 5-i0               #5  4   3
    1587         dsasdg[i0][i1] = 0.5*scot[i0]*scos[i0]/Ax[i1]
    1588         dsasdg[i0][i2] = 0.5*scot[i0]*scos[i0]/Ax[i2]
    1589         dsasdg[i0][i5] = -scot[i0]/np.sqrt(Ax[i1]*Ax[i2])
    1590         denmsq = Ax[i0]*(R123-Ax[i1]*Ax[i4]**2-Ax[i2]*Ax[i3]**2)+(Ax[i4]*Ax[i3])**2
    1591         denom = np.sqrt(denmsq)
    1592         dadg[i5][i0] = -Ax[i5]/denom-rcos[i0]/denmsq*(R123-0.5*Ax[i1]*Ax[i4]**2-0.5*Ax[i2]*Ax[i3]**2)
    1593         dadg[i5][i1] = -0.5*rcos[i0]/denmsq*(Ax[i0]**2*Ax[i2]-Ax[i0]*Ax[i4]**2)
    1594         dadg[i5][i2] = -0.5*rcos[i0]/denmsq*(Ax[i0]**2*Ax[i1]-Ax[i0]*Ax[i3]**2)
    1595         dadg[i5][i3] = Ax[i4]/denom+rcos[i0]/denmsq*(Ax[i0]*Ax[i2]*Ax[i3]-Ax[i3]*Ax[i4]**2)
    1596         dadg[i5][i4] = Ax[i3]/denom+rcos[i0]/denmsq*(Ax[i0]*Ax[i1]*Ax[i4]-Ax[i3]**2*Ax[i4])
    1597         dadg[i5][i5] = -Ax[i0]/denom
    1598     for i0 in range(3):
    1599         i1 = (i0+1)%3
    1600         i2 = (i1+1)%3
    1601         i3 = 5-i2
    1602         for ij in range(6):
    1603             dadg[i0][ij] = cell[i0]*(rcot[i2]*dadg[i3][ij]/rsin[i2]-dsasdg[i1][ij]/ssin[i1])
    1604             if ij == i0:
    1605                 dadg[i0][ij] = dadg[i0][ij]-0.5*cell[i0]/Ax[i0]
    1606             dadg[i3][ij] = -dadg[i3][ij]*rsin[2-i0]*dpr
    1607 #    GSASIIpath.IPyBreak()
    1608     sigMat = np.inner(dadg,np.inner(dadg,vcov))
     1570    dcdA = np.zeros((6,6))
     1571    for i in range(6):
     1572        pdcdA =np.zeros(6)
     1573        A[i] += delt
     1574        pdcdA += G2lat.A2cell(A)
     1575        A[i] -= 2*delt
     1576        pdcdA -= G2lat.A2cell(A)
     1577        A[i] += delt
     1578        dcdA[i] = pdcdA/(2.*delt)
     1579   
     1580    sigMat = np.inner(dcdA,np.inner(dcdA,vcov))
    16091581    var = np.diag(sigMat)
    16101582    CS = np.where(var>0.,np.sqrt(var),0.)
Note: See TracChangeset for help on using the changeset viewer.