Changeset 4265 for trunk


Ignore:
Timestamp:
Jan 25, 2020 12:47:07 PM (5 years ago)
Author:
vondreele
Message:

add bond direction plots to RMCProfile results

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIphsGUI.py

    r4264 r4265  
    44684468                    'atSeq':atSeq,'Pairs':Pairs,'histogram':['',1.0],'files':files,'metadata':metadata,
    44694469                    'runTimes':runTimes,'ReStart':[False,False],'BVS':BVS,'Oxid':atOxid,'useBVS':False,'Swaps':[],
    4470                     'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Stretch search':10.,
     4470                    'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],
     4471                    'Stretch search':10.,'Pot. Temp.':300.,
    44714472                    }}
    44724473            RMCPdict = data['RMC']['RMCProfile']
     
    44924493                RMCPdict.update({'AveCN':[],'FxCN':[]})
    44934494            if 'Potentials' not in RMCPdict:
    4494                 RMCPdict.update({'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Stretch search':10.}})
     4495                RMCPdict.update({'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Stretch search':10.,'Pot. Temp.':300.,}})
     4496            if 'Pot. Temp.' not in RMCPdict['Potentials']:
     4497                RMCPdict['Potentials']['Pot. Temp.'] = 300.
    44954498            if 'Swaps' not in RMCPdict:
    44964499                RMCPdict['Swaps'] = []
     
    49134916               
    49144917            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
     4918            pottempBox = wx.BoxSizer(wx.HORIZONTAL)
     4919            pottempBox.Add(wx.StaticText(G2frame.FRMC,label=' Potential temperature (K): '),0,WACV)
     4920            pottempBox.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Potentials'],'Pot. Temp.',min=0.,max=1000.,size=(50,25)),0,WACV)
     4921            mainSizer.Add(pottempBox,0,WACV)
     4922            bondpotBox = wx.BoxSizer(wx.HORIZONTAL)
     4923            bondpotAdd = wx.Button(G2frame.FRMC,label='Add')
     4924            bondpotAdd.Bind(wx.EVT_BUTTON,OnAddBondPot)
     4925            bondpotBox.Add(bondpotAdd,0,WACV)
     4926            bondpotBox.Add(wx.StaticText(G2frame.FRMC,label=' A-B stretch potential restraints, search range (%): '),0,WACV)
     4927            bondpotBox.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Potentials'],'Stretch search',min=0.,max=100.,size=(50,25)),0,WACV)
     4928            mainSizer.Add(bondpotBox,0,WACV)
     4929            if len(RMCPdict['Potentials']['Stretch']):
     4930                mainSizer.Add(GetBondSizer(),0,WACV)
     4931
    49154932            angpotBox = wx.BoxSizer(wx.HORIZONTAL)
    49164933            angpotAdd = wx.Button(G2frame.FRMC,label='Add')
     
    49234940                mainSizer.Add(GetAngleSizer(),0,WACV)
    49244941               
    4925             G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    4926             bondpotBox = wx.BoxSizer(wx.HORIZONTAL)
    4927             bondpotAdd = wx.Button(G2frame.FRMC,label='Add')
    4928             bondpotAdd.Bind(wx.EVT_BUTTON,OnAddBondPot)
    4929             bondpotBox.Add(bondpotAdd,0,WACV)
    4930             bondpotBox.Add(wx.StaticText(G2frame.FRMC,label=' A-B stretch potential restraints, search range (%): '),0,WACV)
    4931             bondpotBox.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Potentials'],'Stretch search',min=0.,max=100.,size=(50,25)),0,WACV)
    4932             mainSizer.Add(bondpotBox,0,WACV)
    4933             if len(RMCPdict['Potentials']['Stretch']):
    4934                 mainSizer.Add(GetBondSizer(),0,WACV)
    4935 
    49364942            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    49374943            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' Select data:'),0,WACV)
     
    51715177            generalData = data['General']
    51725178            RMCPdict = data['RMC']['RMCProfile']
     5179            atSeq = RMCPdict['atSeq']
    51735180            pName = generalData['Name'].replace(' ','_')
    51745181            dlg = wx.FileDialog(G2frame, "Choose any RMCProfile csv results file for "+pName+":",
     
    52755282                    labelY=r'$\mathsf{\chi^2}$',newPlot=True,Title='RMCP Chi^2 for '+pName,
    52765283                    lines=True,names=Names[3:])
    5277        
     5284#bond odf plots               
     5285            nPot = len(RMCPdict['Potentials']['Stretch'])
     5286            for iPot in range(nPot):
     5287                fname = pName+'.bondodf_%d'%(iPot+1)
     5288                bond = RMCPdict['Potentials']['Stretch'][iPot]
     5289                if os.path.exists(os.path.join(path,fname)):
     5290                    OutFile = open(fname,'r')
     5291                    odfFile = OutFile.readlines()
     5292                    if len(odfFile) > 1:
     5293                        OutFile.seek(0)
     5294                        odfData = np.fromfile(OutFile,sep=' ')
     5295                        numx,numy = odfData[:2]
     5296                        G2plt.Plot3dXYZ(G2frame,int(numx),int(numy),odfData[2:],newPlot=False,Title='Bond %s-%s'%(bond[0],bond[1]))       
    52785297       
    52795298           
  • TabularUnified trunk/GSASIIplot.py

    r4236 r4265  
    51095109       
    51105110################################################################################
     5111##### Plot3dXYZ
     5112################################################################################
     5113       
     5114def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX='X',labelY='Y',labelZ='Z',newPlot=False,Title=''):
     5115   
     5116    def OnMotion(event):
     5117        xpos = event.xdata
     5118        if xpos:                                        #avoid out of frame mouse position
     5119            ypos = event.ydata
     5120            G2frame.G2plotNB.status.SetStatusText('X =%.3f Y =%.4f'%(xpos,ypos),1)                   
     5121           
     5122    def OnKeyPress(event):
     5123        if event.key == 'g':
     5124            mpl.rcParams['axes.grid'] = not mpl.rcParams['axes.grid']
     5125
     5126    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'3d')
     5127    if not new:
     5128        if not Page.IsShown():
     5129            Page.Show()
     5130    else:
     5131        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
     5132    Page.Choice = None
     5133    G2frame.G2plotNB.status.SetStatusText('',1)
     5134    Zmul = Zdat.reshape((nX,-1)).T
     5135    PHI = np.linspace(0.,360.,int(nY),True)
     5136    PSI = np.linspace(0.,180.,int(nX),True)
     5137    X = Zmul*np.outer(npcosd(PHI),npsind(PSI))/2.
     5138    Y = Zmul*np.outer(npsind(PHI),npsind(PSI))/2.
     5139    Z = Zmul*np.outer(np.ones(np.size(PHI)),npcosd(PSI))/2.
     5140   
     5141    if np.any(X) and np.any(Y) and np.any(Z):
     5142        np.seterr(all='ignore')
     5143        Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1)
     5144        xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T
     5145        XYZlim = [min(xyzlim[0]),max(xyzlim[1])]
     5146        Plot.contour(X,Y,Z,10,zdir='x',offset=XYZlim[0])
     5147        Plot.contour(X,Y,Z,10,zdir='y',offset=XYZlim[1])
     5148        Plot.contour(X,Y,Z,10,zdir='z',offset=XYZlim[0])
     5149        Plot.set_xlim3d(XYZlim)
     5150        Plot.set_ylim3d(XYZlim)
     5151        Plot.set_zlim3d(XYZlim)
     5152        try:
     5153            Plot.set_aspect('equal')
     5154        except: #broken in mpl 3.1.1; worked in mpl 3.0.3
     5155            pass
     5156        Plot.set_title(Title)
     5157        Plot.set_xlabel(labelX)
     5158        Plot.set_ylabel(labelY)
     5159        Plot.set_zlabel(labelZ)
     5160    Page.canvas.draw()
     5161       
     5162################################################################################
    51115163##### PlotHist
    51125164################################################################################
  • TabularUnified trunk/GSASIIpwd.py

    r4264 r4265  
    23582358        fl.write('\n')
    23592359        fl.write('POTENTIALS ::\n')
     2360        fl.write('  > TEMPERATURE :: %.1f K\n'%RMCPdict['Potentials']['Pot. Temp.'])
     2361        fl.write('  > PLOT :: pixels=400, colour=red, zangle=90, zrotation=45 deg\n')
    23602362        if len(RMCPdict['Potentials']['Stretch']):
    23612363            fl.write('  > STRETCH_SEARCH :: %.1f%%\n'%RMCPdict['Potentials']['Stretch search'])
Note: See TracChangeset for help on using the changeset viewer.