Changeset 420


Ignore:
Timestamp:
Nov 17, 2011 1:35:34 PM (12 years ago)
Author:
vondreele
Message:

small fixes including
move msg = in SetVaryFlags? outside loop
arrange so plot shows Yo-Yc (was other way around)
put Yo-Yc at bottom in multiplot plots
more on seq refinement plots

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r415 r420  
    8080] = [wx.NewId() for _init_coll_Export_Items in range(7)]
    8181
    82 [wxID_HELPABOUT, wxID_HELPHELP, 
     82[wxID_HELPABOUT, wxID_HELPHELP,
    8383] = [wx.NewId() for _init_coll_Help_Items in range(2)]
    8484
     
    15051505        self.OnFileSave(event)
    15061506        #works - but it'd be better if it could restore plots
    1507         dlg = wx.ProgressDialog('Residual','Powder profile Rwp =',101.0,
     1507        dlg = wx.ProgressDialog('Residual','wRp =',101.0,
    15081508            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT)
    15091509        screenSize = wx.ClientDisplayRect()
  • trunk/GSASIIgrid.py

    r415 r420  
    7979    wxID_PDFCOMPUTE, wxID_PDFCOMPUTEALL, wxID_PDFADDELEMENT, wxID_PDFDELELEMENT,
    8080] = [wx.NewId() for _init_coll_PDF_Items in range(7)]
     81
     82[ wxID_HELP,
     83] = [wx.NewId() for _init_coll_Help_Items in range(1)]
    8184
    8285VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    309312        self.PDFCompute = parent.Append(help='Compute all PDFs', id=wxID_PDFCOMPUTEALL, kind=wx.ITEM_NORMAL,
    310313            text='Compute all PDFs')
    311        
    312 
     314           
    313315    def _init_utils(self):
    314316        self.BlankMenu = wx.MenuBar()
     
    742744                'title' - histogram name; same as dict item name
    743745                'newAtomDict' - new atom parameters after shifts applied
     746                'newCellDict' - new cell parameters after shifts to A0-A5 applied'
    744747    """
    745748    if not data:
     
    747750        return
    748751    histNames = data['histNames']
    749    
     752       
     753    def GetSampleParms():
     754        sampleParmDict = {'Temperature':[],'Pressure':[],'Humidity':[],'Voltage':[],'Force':[],}
     755        sampleParm = {}
     756        for name in histNames:
     757            Id = GetPatternTreeItemId(self,self.root,name)
     758            sampleData = self.PatternTree.GetItemPyData(GetPatternTreeItemId(self,Id,'Sample Parameters'))
     759            for item in sampleParmDict:
     760                sampleParmDict[item].append(sampleData[item])
     761        for item in sampleParmDict:
     762            frstValue = sampleParmDict[item][0]
     763            if np.any(np.array(sampleParmDict[item])-frstValue):
     764                sampleParm[item] = sampleParmDict[item]           
     765        return sampleParm
     766           
    750767    def GetSigData(parm):
    751768        sigData = []
     
    770787                plotNames.append(self.SeqTable.GetColLabelValue(col))
    771788            plotData = np.array(plotData)
    772             G2plt.PlotSeq(self,plotData,plotSig,plotNames)
     789            G2plt.PlotSeq(self,plotData,plotSig,plotNames,sampleParms)
    773790        elif rows:
    774791            name = histNames[rows[0]]
     
    782799        if item in data['varyList']:
    783800            atomList[newAtomDict[item][0]] = item
     801    sampleParms = GetSampleParms()
    784802    self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu)
    785803    self.dataFrame.SetLabel('Sequental refinement results')
     
    788806    Types = len(data['varyList']+atomList.keys())*[wg.GRID_VALUE_FLOAT,]
    789807    seqList = [list(data[name]['variables']) for name in histNames]
     808   
    790809    for i,item in enumerate(seqList):
    791810        newAtomDict = data[histNames[i]]['newAtomDict']
     
    11221141    self.dataFrame.Bind(wx.EVT_MENU, OnAddEquivalence, id=wxID_EQUIVADD)
    11231142    self.dataFrame.Bind(wx.EVT_MENU, OnAddHold, id=wxID_HOLDADD)
     1143    self.dataFrame.Bind(wx.EVT_MENU, OnHelp, id=wxID_HELP)
    11241144    self.dataDisplay = GSNoteBook(parent=self.dataFrame,size=self.dataFrame.GetClientSize())
    11251145   
     
    15181538        G2plt.PlotPatterns(self)
    15191539     
     1540def OnHelp(event):
     1541    Obj = event.GetEventObject()
     1542    print 'Help on '+Obj.GetTitle()
  • trunk/GSASIImapvars.py

    r419 r420  
    403403    '''
    404404    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict
     405    msg = ""
    405406    for varlist,mapvars,multarr in zip(dependentParmList,indParmList,arrayList):
    406         msg = ""
    407407        for mv in mapvars:
    408408            varied = []
  • trunk/GSASIIplot.py

    r404 r420  
    5555    def __init__(self,parent,id=-1,dpi=None,**kwargs):
    5656        wx.Panel.__init__(self,parent,id=id,**kwargs)
    57         mpl.rcParams['legend.fontsize'] = 8
     57        mpl.rcParams['legend.fontsize'] = 10
    5858        self.figure = mpl.figure.Figure(dpi=dpi,figsize=(5,7))
    5959        self.canvas = Canvas(self,-1,self.figure)
     
    639639                Z = xye[3]+offset*N
    640640                W = xye[4]+offset*N
    641                 D = xye[5]+offset*N-Ymax*.02
     641                D = xye[5]-Ymax*.02
    642642                if self.Weight:
    643643                    W2 = np.sqrt(xye[2])
     
    14461446    Page.canvas.draw()
    14471447   
    1448 def PlotSeq(self,SeqData,SeqSig,SeqNames):
     1448def PlotSeq(self,SeqData,SeqSig,SeqNames,sampleParm):
    14491449   
     1450    def OnKeyPress(event):
     1451        if event.key == 's' and sampleParm:
     1452            if self.xAxis:
     1453                self.xAxis = False
     1454            else:
     1455                self.xAxis = True
     1456            Draw(False)
    14501457    try:
    14511458        plotNum = self.G2plotNB.plotList.index('Sequential refinement')
     
    14591466        plotNum = self.G2plotNB.plotList.index('Sequential refinement')
    14601467        Page = self.G2plotNB.nb.GetPage(plotNum)
    1461        
    1462     Page.SetFocus()
    1463     self.G2plotNB.status.SetFields(['',''])
    1464     if len(SeqData):   
    1465         X = np.arange(0,len(SeqData[0]),1)
    1466         for Y,sig,name in zip(SeqData,SeqSig,SeqNames):
    1467             Plot.errorbar(X,Y,yerr=sig,label=name)       
    1468         Plot.legend(loc='best')
    1469         Page.canvas.draw()
     1468        Page.canvas.mpl_connect('key_press_event', OnKeyPress)
     1469        self.xAxis = False
     1470       
     1471    def Draw(newPlot):
     1472        Page.SetFocus()
     1473        self.G2plotNB.status.SetFields(['','press s to toggle x-axis = sample environment parameter'])
     1474        if len(SeqData):
     1475            Plot.clear()
     1476            if self.xAxis:   
     1477                xName = sampleParm.keys()[0]
     1478                X = sampleParm[xName]
     1479            else:
     1480                X = np.arange(0,len(SeqData[0]),1)
     1481                xName = 'Data sequence number'
     1482            for Y,sig,name in zip(SeqData,SeqSig,SeqNames):
     1483                Plot.errorbar(X,Y,yerr=sig,label=name)       
     1484            Plot.legend(loc='best')
     1485            Plot.set_ylabel('Parameter values')
     1486            Plot.set_xlabel(xName)
     1487            Page.canvas.draw()           
     1488    Draw(True)
    14701489           
    14711490def PlotExposedImage(self,newPlot=False,event=None):
  • trunk/GSASIIstruct.py

    r419 r420  
    664664    return vcov
    665665   
     666def cellFill(pfx,SGData,parmDict,sigDict):
     667    if SGData['SGLaue'] in ['-1',]:
     668        A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
     669            parmDict[pfx+'A3'],parmDict[pfx+'A4'],parmDict[pfx+'A5']]
     670        sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
     671            sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']]
     672    elif SGData['SGLaue'] in ['2/m',]:
     673        if SGData['SGUniq'] == 'a':
     674            A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
     675                parmDict[pfx+'A3'],0,0]
     676            sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
     677                sigDict[pfx+'A3'],0,0]
     678        elif SGData['SGUniq'] == 'b':
     679            A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
     680                0,parmDict[pfx+'A4'],0]
     681            sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
     682                0,sigDict[pfx+'A4'],0]
     683        else:
     684            A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
     685                0,0,parmDict[pfx+'A5']]
     686            sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
     687                0,0,sigDict[pfx+'A5']]
     688    elif SGData['SGLaue'] in ['mmm',]:
     689        A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],0,0,0]
     690        sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0]
     691    elif SGData['SGLaue'] in ['4/m','4/mmm']:
     692        A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],0,0,0]
     693        sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]
     694    elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']:
     695        A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],
     696            parmDict[pfx+'A0'],0,0]
     697        sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]
     698    elif SGData['SGLaue'] in ['3R', '3mR']:
     699        A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],
     700            parmDict[pfx+'A3'],parmDict[pfx+'A3'],parmDict[pfx+'A3']]
     701        sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0]
     702    elif SGData['SGLaue'] in ['m3m','m3']:
     703        A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],0,0,0]
     704        sigA = [sigDict[pfx+'A0'],0,0,0,0,0]
     705    return A,sigA
     706       
    666707def getCellEsd(pfx,SGData,A,covData):
    667708    dpr = 180./np.pi
     
    724765def SetPhaseData(parmDict,sigDict,Phases,covData):
    725766   
    726     def cellFill(pfx,SGData,parmDict,sigDict):
    727         if SGData['SGLaue'] in ['-1',]:
    728             A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
    729                 parmDict[pfx+'A3'],parmDict[pfx+'A4'],parmDict[pfx+'A5']]
    730             sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
    731                 sigDict[pfx+'A3'],sigDict[pfx+'A4'],sigDict[pfx+'A5']]
    732         elif SGData['SGLaue'] in ['2/m',]:
    733             if SGData['SGUniq'] == 'a':
    734                 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
    735                     parmDict[pfx+'A3'],0,0]
    736                 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
    737                     sigDict[pfx+'A3'],0,0]
    738             elif SGData['SGUniq'] == 'b':
    739                 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
    740                     0,parmDict[pfx+'A4'],0]
    741                 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
    742                     0,sigDict[pfx+'A4'],0]
    743             else:
    744                 A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
    745                     0,0,parmDict[pfx+'A5']]
    746                 sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],
    747                     0,0,sigDict[pfx+'A5']]
    748         elif SGData['SGLaue'] in ['mmm',]:
    749             A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],0,0,0]
    750             sigA = [sigDict[pfx+'A0'],sigDict[pfx+'A1'],sigDict[pfx+'A2'],0,0,0]
    751         elif SGData['SGLaue'] in ['4/m','4/mmm']:
    752             A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],0,0,0]
    753             sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]
    754         elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']:
    755             A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A2'],
    756                 parmDict[pfx+'A0'],0,0]
    757             sigA = [sigDict[pfx+'A0'],0,sigDict[pfx+'A2'],0,0,0]
    758         elif SGData['SGLaue'] in ['3R', '3mR']:
    759             A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],
    760                 parmDict[pfx+'A3'],parmDict[pfx+'A3'],parmDict[pfx+'A3']]
    761             sigA = [sigDict[pfx+'A0'],0,0,sigDict[pfx+'A3'],0,0]
    762         elif SGData['SGLaue'] in ['m3m','m3']:
    763             A = [parmDict[pfx+'A0'],parmDict[pfx+'A0'],parmDict[pfx+'A0'],0,0,0]
    764             sigA = [sigDict[pfx+'A0'],0,0,0,0,0]
    765         return A,sigA
    766        
    767767    def PrintAtomsAndSig(General,Atoms,atomsSig):
    768768        print '\n Atoms:'
     
    17201720    parmdict.update(zip(varylist,values))
    17211721   
     1722def GetNewCellParms(parmDict,varyList):
     1723    newCellDict = {}
     1724    Dchoices = ['D11','D22','D33','D12','D13','D23']
     1725    Achoices = ['A'+str(i) for i in range(6)]
     1726   
     1727   
     1728    return newCellDict
     1729   
    17221730def ApplyXYZshifts(parmDict,varyList):
    17231731    ''' takes atom x,y,z shift and applies it to corresponding atom x,y,z value
     
    23382346                        dMdv[varylist.index(name)] += item[0]*dervDict[item[1]]
    23392347                    if name in dependentVars:
     2348                        item = names[name]
    23402349                        depDerivDict[name] += item[0]*dervDict[item[1]]
    23412350
     
    24442453                varylist,Histogram,Phases,calcControls,pawleyLookup)
    24452454            yc[xB:xF] += yb[xB:xF]
    2446             yd[xB:xF] = yc[xB:xF]-y[xB:xF]          #yc-yo then all dydv have no '-' needed
     2455            yd[xB:xF] = y[xB:xF]-yc[xB:xF]
    24472456            Histogram['sumwYd'] = np.sum(np.sqrt(w[xB:xF])*(yd[xB:xF]))
    2448             wdy = np.sqrt(w[xB:xF])*(yd[xB:xF])
     2457            wdy = -np.sqrt(w[xB:xF])*(yd[xB:xF])
    24492458            Histogram['wRp'] = min(100.,np.sqrt(np.sum(wdy**2)/Histogram['sumwYo'])*100.)
    24502459            M = np.concatenate((M,wdy))
     
    24532462    Rwp = min(100.,np.sqrt(np.sum(M**2)/sumwYo)*100.)
    24542463    if dlg:
    2455         GoOn = dlg.Update(Rwp,newmsg='%s%8.3f%s'%('Powder profile wRp =',Rwp,'%'))[0]
     2464        GoOn = dlg.Update(Rwp,newmsg='%s%8.3f%s'%('wRp =',Rwp,'%'))[0]
    24562465        if not GoOn:
    24572466            parmDict['saved values'] = values
     
    25112520        raise Exception       
    25122521    G2mv.Map2Dict(parmDict,varyList)
    2513     print G2mv.VarRemapShow(varyList)
     2522#    print G2mv.VarRemapShow(varyList)
    25142523
    25152524    while True:
     
    25332542        Values2Dict(parmDict, varyList, result[0])
    25342543        G2mv.Dict2Map(parmDict,varyList)
     2544        newCellDict = GetNewCellParms(parmDict,varyList)
    25352545        newAtomDict = ApplyXYZshifts(parmDict,varyList)
    25362546       
     
    25592569                    break
    25602570
    2561     print 'dependentParmList: ',G2mv.dependentParmList
    2562     print 'arrayList: ',G2mv.arrayList
    2563     print 'invarrayList: ',G2mv.invarrayList
    2564     print 'indParmList: ',G2mv.indParmList
    2565     print 'fixedDict: ',G2mv.fixedDict
    2566     print 'test1'
     2571#    print 'dependentParmList: ',G2mv.dependentParmList
     2572#    print 'arrayList: ',G2mv.arrayList
     2573#    print 'invarrayList: ',G2mv.invarrayList
     2574#    print 'indParmList: ',G2mv.indParmList
     2575#    print 'fixedDict: ',G2mv.fixedDict
     2576#    print 'test1'
    25672577    GetFobsSq(Histograms,Phases,parmDict,calcControls)
    2568     print 'test2'
     2578#    print 'test2'
    25692579    sigDict = dict(zip(varyList,sig))
    25702580    covData = {'variables':result[0],'varyList':varyList,'sig':sig,
    2571         'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict}
     2581        'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict,'newCellDict':newCellDict}
    25722582    SetPhaseData(parmDict,sigDict,Phases,covData)
    25732583    SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms)
     
    25762586    SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,covData)
    25772587#for testing purposes!!!
    2578     file = open('structTestdata.dat','wb')
    2579     cPickle.dump(parmDict,file,1)
    2580     cPickle.dump(varyList,file,1)
    2581     for histogram in Histograms:
    2582         if 'PWDR' in histogram[:4]:
    2583             Histogram = Histograms[histogram]
    2584     cPickle.dump(Histogram,file,1)
    2585     cPickle.dump(Phases,file,1)
    2586     cPickle.dump(calcControls,file,1)
    2587     cPickle.dump(pawleyLookup,file,1)
    2588     file.close()
     2588#    file = open('structTestdata.dat','wb')
     2589#    cPickle.dump(parmDict,file,1)
     2590#    cPickle.dump(varyList,file,1)
     2591#    for histogram in Histograms:
     2592#        if 'PWDR' in histogram[:4]:
     2593#            Histogram = Histograms[histogram]
     2594#    cPickle.dump(Histogram,file,1)
     2595#    cPickle.dump(Phases,file,1)
     2596#    cPickle.dump(calcControls,file,1)
     2597#    cPickle.dump(pawleyLookup,file,1)
     2598#    file.close()
    25892599
    25902600def SeqRefine(GPXfile,dlg):
     
    26832693            Values2Dict(parmDict, varyList, result[0])
    26842694            G2mv.Dict2Map(parmDict,varyList)
     2695            newCellDict = GetNewCellParms(parmDict,varyList)
    26852696            newAtomDict = ApplyXYZshifts(parmDict,varyList)
    26862697           
     
    27112722        sigDict = dict(zip(varyList,sig))
    27122723        covData = {'variables':result[0],'varyList':varyList,'sig':sig,
    2713             'covMatrix':covMatrix,'title':histogram,'newAtomDict':newAtomDict}
     2724            'covMatrix':covMatrix,'title':histogram,'newAtomDict':newAtomDict,'newCellDict':newCellDict}
    27142725        SetHistogramPhaseData(parmDict,sigDict,Phases,Histo,ifPrint)
    27152726        SetHistogramData(parmDict,sigDict,Histo,ifPrint)
Note: See TracChangeset for help on using the changeset viewer.