Changeset 1180


Ignore:
Timestamp:
Jan 2, 2014 11:38:59 AM (8 years ago)
Author:
vondreele
Message:
 
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r1179 r1180  
    872872    for ring in StrSta['d-zero']:       #get observed x,y,d points for the d-zeros
    873873        ellipse = GetEllipse(ring['Dset'],StaControls)
    874         Ring = makeRing(ring['Dset'],ellipse,ring['pixLimit'],ring['cutoff'],scalex,scaley,Image)
    875         Ring = np.array(Ring).T
     874        Ring = np.array(makeRing(ring['Dset'],ellipse,ring['pixLimit'],ring['cutoff'],scalex,scaley,Image)).T
    876875        ring['ImxyObs'] = np.array(Ring[:2])      #need to apply masks to this to eliminate bad points
    877         Ring[:2] = GetTthAzm(Ring[0],Ring[1],StaControls)       #convert x,y to tth,azm
     876        ring['ImtaObs'] = GetTthAzm(Ring[0],Ring[1],StaControls)       #convert x,y to tth,azm
     877        ring['ImtaCalc'] = np.zeros_like(ring['ImtaObs'])
    878878        Ring[0] /= 2.                                           #convert to theta
    879879        if len(rings):
     
    883883    E = StrSta['strain']
    884884    p0 = [E[0][0],E[1][1],E[2][2],E[0][1],E[0][2],E[1][2]]
    885     E = FitStrain(rings,p0,wave,phi)
     885    E,dth = FitStrain(rings,p0,wave,phi)
     886    for ring in StrSta['d-zero']:
     887        th,azm = ring['ImtaObs']
     888        th0 = npasind(wave/(2.*ring['Dset']))
     889        V = np.sum(np.sum(E*calcFij(90.,phi,azm,th0).T,axis=2),axis=1)
     890        dth = 180.*V/(np.pi*10e6) #in degrees & microstrain units
     891        ring['ImtaCalc'] = np.array([(th0-dth)/2,azm])
    886892    StrSta['strain'] = E
    887893
     
    891897    Uses parameters as defined by Bob He & Kingsley Smith, Adv. in X-Ray Anal. 41, 501 (1997)
    892898
    893     :param omg: his omega = sample omega rotation; 0 when incident beam || sample surface, 90 when perp. to sample surface
     899    :param omg: his omega = sample omega rotation; 0 when incident beam || sample surface,
     900        90 when perp. to sample surface
    894901    :param phi: his phi = sample phi rotation; usually = 0, axis rotates with omg.
    895902    :param azm: his chi = azimuth around incident beam
     
    930937        th,azm,dsp = xyd
    931938        th0 = npasind(wave/(2.*dsp))
    932         dth = 180.*np.sum(E*calcFij(phi,0.,azm,th).T)/(np.pi*1.e6) #in degrees & microstrain units
     939        V = np.sum(np.sum(E*calcFij(90.,phi,azm,th).T,axis=2),axis=1)
     940        dth = 180.*V/(np.pi*10e6) #in degrees & microstrain units
    933941        th0 += dth
    934         return (th-th0)**2
     942        return th-th0
    935943       
    936944    names = ['e11','e22','e33','e12','e13','e23']
    937945    fmt = ['%12.2f','%12.2f','%12.2f','%12.2f','%12.2f','%12.5f']
    938     p1 = [p0[0],p0[1]]   
     946    p1 = [1,-1]   
    939947    result = leastsq(strainCalc,p1,args=(rings,wave,phi),full_output=True)
    940948    vals = list(result[0])
     
    944952    StrainPrint(ValSig)
    945953#    return np.array([[vals[0],vals[3],vals[4]],[vals[3],vals[1],vals[5]],[vals[4],vals[5],vals[2]]])
    946     return np.array([[vals[0],0,0],[0,vals[1],0],[0,0,0]])
    947    
    948        
     954    return np.array([[vals[0],0,0],[0,vals[1],0],[0,0,0]]),result[2]['fvec']
     955   
     956       
  • trunk/GSASIIimgGUI.py

    r1174 r1180  
    13951395            G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Image Controls'))
    13961396        G2img.FitStrSta(G2frame.ImageZ,data,Controls,Masks)
     1397        UpdateStressStrain(G2frame,data)
    13971398        G2plt.PlotExposedImage(G2frame,event=event)
     1399        G2plt.PlotStrain(G2frame,data,newPlot=False,type='Strain')
    13981400       
    13991401    def SamSizer():
  • trunk/GSASIIplot.py

    r1163 r1180  
    11931193################################################################################
    11941194           
    1195 def PlotXY(G2frame,XY,newPlot=False,type=''):
     1195def PlotXY(G2frame,XY,XY2=None,labelX=None,labelY=None,newPlot=False,type=''):
    11961196    '''simple plot of xy data, used for diagnostic purposes
    11971197    '''
     
    12251225    G2frame.G2plotNB.status.DestroyChildren()
    12261226    Plot.set_title(type)
    1227     Plot.set_xlabel(r'X',fontsize=14)
    1228     Plot.set_ylabel(r''+type,fontsize=14)
     1227    if xLabel:
     1228        Plot.set_xlabel(r''+xLabel,fontsize=14)
     1229    else:
     1230        Plot.set_xlabel(r'X',fontsize=14)
     1231    if yLabel:
     1232        Plot.set_ylabel(r''+yLabel,fontsize=14)
     1233    else:
     1234        Plot.set_ylabel(r'Y',fontsize=14)
    12291235    colors=['b','g','r','c','m','k']
    1230     Ymax = 1.0
    1231     lenX = 0
    1232     X,Y = XY[:2]
    1233     Ymax = max(Ymax,max(Y))
    1234     Plot.plot(X,Y,'k',picker=False)
     1236    for ixy,xy in enumerate(XY):
     1237        X,Y = xy
     1238        Plot.plot(X,Y,color(ixy%6)+'+',picker=False)
     1239    if len(XY2):
     1240        for ixy,xy in enumerate(XY2):
     1241            X,Y = xy
     1242            Plot.plot(X,Y,color(ixy%6),picker=False)
     1243    if not newPlot:
     1244        Page.toolbar.push_current()
     1245        Plot.set_xlim(xylim[0])
     1246        Plot.set_ylim(xylim[1])
     1247        xylim = []
     1248        Page.toolbar.push_current()
     1249        Page.toolbar.draw()
     1250    else:
     1251        Page.canvas.draw()
     1252
     1253################################################################################
     1254##### PlotStrain
     1255################################################################################
     1256           
     1257def PlotStrain(G2frame,data,newPlot=False,type=''):
     1258    '''plot of strain data, used for diagnostic purposes
     1259    '''
     1260    def OnMotion(event):
     1261        xpos = event.xdata
     1262        if xpos:                                        #avoid out of frame mouse position
     1263            ypos = event.ydata
     1264            Page.canvas.SetCursor(wx.CROSS_CURSOR)
     1265            try:
     1266                G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3f'%(xpos,type,ypos),1)                   
     1267            except TypeError:
     1268                G2frame.G2plotNB.status.SetStatusText('Select '+type+' pattern first',1)
     1269
     1270    try:
     1271        plotNum = G2frame.G2plotNB.plotList.index(type)
     1272        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     1273        if not newPlot:
     1274            Plot = Page.figure.gca()
     1275            xylim = Plot.get_xlim(),Plot.get_ylim()
     1276        Page.figure.clf()
     1277        Plot = Page.figure.gca()
     1278    except ValueError:
     1279        newPlot = True
     1280        Plot = G2frame.G2plotNB.addMpl(type).gca()
     1281        plotNum = G2frame.G2plotNB.plotList.index(type)
     1282        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     1283        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
     1284   
     1285    Page.Choice = None
     1286    Page.SetFocus()
     1287    G2frame.G2plotNB.status.DestroyChildren()
     1288    Plot.set_title(type)
     1289    Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
     1290    Plot.set_ylabel(r'Azimuth',fontsize=14)
     1291    colors=['b','g','r','c','m','k']
     1292    for N,item in enumerate(data['d-zero']):
     1293        X,Y = np.array(item['ImtaObs'])
     1294        Plot.plot(X,Y,colors[N%6]+'+',picker=False)
     1295        X,Y = np.array(item['ImtaCalc'])
     1296        Plot.plot(X,Y,colors[N%6],picker=False)
    12351297    if not newPlot:
    12361298        Page.toolbar.push_current()
     
    25342596        if G2frame.PatternTree.GetItemText(G2frame.PickId) in 'Stress/Strain':
    25352597            print 'plot stress/strain stuff'
    2536             for ring in StrSta['d-zero']:
     2598            for N,ring in enumerate(StrSta['d-zero']):
    25372599                xring,yring = ring['ImxyObs']
    2538                 Plot.plot(xring,yring,'r+')
    2539 #                for xring,yring in ring['ImxyCalc'].T:
    2540 #                    Plot.add_artist(Polygon(ring['ImxyCalc'].T,ec='b',fc='none'))
    2541 #                    Plot.plot(xring,yring)
     2600                Plot.plot(xring,yring,colors[N%6]+'+')
     2601                for xring,yring in np.array(ring['ImxyCalc']).T:
     2602                    Plot.add_artist(Polygon(ring['ImxyCalc'].T,ec='b',fc='none'))
     2603                    Plot.plot(xring,yring)
    25422604        #masks - mask lines numbered after integration limit lines
    25432605        spots = Masks['Points']
Note: See TracChangeset for help on using the changeset viewer.