Changeset 420
- Timestamp:
- Nov 17, 2011 1:35:34 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r415 r420 80 80 ] = [wx.NewId() for _init_coll_Export_Items in range(7)] 81 81 82 [wxID_HELPABOUT, wxID_HELPHELP, 82 [wxID_HELPABOUT, wxID_HELPHELP, 83 83 ] = [wx.NewId() for _init_coll_Help_Items in range(2)] 84 84 … … 1505 1505 self.OnFileSave(event) 1506 1506 #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, 1508 1508 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT) 1509 1509 screenSize = wx.ClientDisplayRect() -
trunk/GSASIIgrid.py
r415 r420 79 79 wxID_PDFCOMPUTE, wxID_PDFCOMPUTEALL, wxID_PDFADDELEMENT, wxID_PDFDELELEMENT, 80 80 ] = [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)] 81 84 82 85 VERY_LIGHT_GREY = wx.Colour(235,235,235) … … 309 312 self.PDFCompute = parent.Append(help='Compute all PDFs', id=wxID_PDFCOMPUTEALL, kind=wx.ITEM_NORMAL, 310 313 text='Compute all PDFs') 311 312 314 313 315 def _init_utils(self): 314 316 self.BlankMenu = wx.MenuBar() … … 742 744 'title' - histogram name; same as dict item name 743 745 'newAtomDict' - new atom parameters after shifts applied 746 'newCellDict' - new cell parameters after shifts to A0-A5 applied' 744 747 """ 745 748 if not data: … … 747 750 return 748 751 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 750 767 def GetSigData(parm): 751 768 sigData = [] … … 770 787 plotNames.append(self.SeqTable.GetColLabelValue(col)) 771 788 plotData = np.array(plotData) 772 G2plt.PlotSeq(self,plotData,plotSig,plotNames )789 G2plt.PlotSeq(self,plotData,plotSig,plotNames,sampleParms) 773 790 elif rows: 774 791 name = histNames[rows[0]] … … 782 799 if item in data['varyList']: 783 800 atomList[newAtomDict[item][0]] = item 801 sampleParms = GetSampleParms() 784 802 self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) 785 803 self.dataFrame.SetLabel('Sequental refinement results') … … 788 806 Types = len(data['varyList']+atomList.keys())*[wg.GRID_VALUE_FLOAT,] 789 807 seqList = [list(data[name]['variables']) for name in histNames] 808 790 809 for i,item in enumerate(seqList): 791 810 newAtomDict = data[histNames[i]]['newAtomDict'] … … 1122 1141 self.dataFrame.Bind(wx.EVT_MENU, OnAddEquivalence, id=wxID_EQUIVADD) 1123 1142 self.dataFrame.Bind(wx.EVT_MENU, OnAddHold, id=wxID_HOLDADD) 1143 self.dataFrame.Bind(wx.EVT_MENU, OnHelp, id=wxID_HELP) 1124 1144 self.dataDisplay = GSNoteBook(parent=self.dataFrame,size=self.dataFrame.GetClientSize()) 1125 1145 … … 1518 1538 G2plt.PlotPatterns(self) 1519 1539 1540 def OnHelp(event): 1541 Obj = event.GetEventObject() 1542 print 'Help on '+Obj.GetTitle() -
trunk/GSASIImapvars.py
r419 r420 403 403 ''' 404 404 global dependentParmList,arrayList,invarrayList,indParmList,fixedDict 405 msg = "" 405 406 for varlist,mapvars,multarr in zip(dependentParmList,indParmList,arrayList): 406 msg = ""407 407 for mv in mapvars: 408 408 varied = [] -
trunk/GSASIIplot.py
r404 r420 55 55 def __init__(self,parent,id=-1,dpi=None,**kwargs): 56 56 wx.Panel.__init__(self,parent,id=id,**kwargs) 57 mpl.rcParams['legend.fontsize'] = 857 mpl.rcParams['legend.fontsize'] = 10 58 58 self.figure = mpl.figure.Figure(dpi=dpi,figsize=(5,7)) 59 59 self.canvas = Canvas(self,-1,self.figure) … … 639 639 Z = xye[3]+offset*N 640 640 W = xye[4]+offset*N 641 D = xye[5] +offset*N-Ymax*.02641 D = xye[5]-Ymax*.02 642 642 if self.Weight: 643 643 W2 = np.sqrt(xye[2]) … … 1446 1446 Page.canvas.draw() 1447 1447 1448 def PlotSeq(self,SeqData,SeqSig,SeqNames ):1448 def PlotSeq(self,SeqData,SeqSig,SeqNames,sampleParm): 1449 1449 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) 1450 1457 try: 1451 1458 plotNum = self.G2plotNB.plotList.index('Sequential refinement') … … 1459 1466 plotNum = self.G2plotNB.plotList.index('Sequential refinement') 1460 1467 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) 1470 1489 1471 1490 def PlotExposedImage(self,newPlot=False,event=None): -
trunk/GSASIIstruct.py
r419 r420 664 664 return vcov 665 665 666 def 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 666 707 def getCellEsd(pfx,SGData,A,covData): 667 708 dpr = 180./np.pi … … 724 765 def SetPhaseData(parmDict,sigDict,Phases,covData): 725 766 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,sigA766 767 767 def PrintAtomsAndSig(General,Atoms,atomsSig): 768 768 print '\n Atoms:' … … 1720 1720 parmdict.update(zip(varylist,values)) 1721 1721 1722 def 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 1722 1730 def ApplyXYZshifts(parmDict,varyList): 1723 1731 ''' takes atom x,y,z shift and applies it to corresponding atom x,y,z value … … 2338 2346 dMdv[varylist.index(name)] += item[0]*dervDict[item[1]] 2339 2347 if name in dependentVars: 2348 item = names[name] 2340 2349 depDerivDict[name] += item[0]*dervDict[item[1]] 2341 2350 … … 2444 2453 varylist,Histogram,Phases,calcControls,pawleyLookup) 2445 2454 yc[xB:xF] += yb[xB:xF] 2446 yd[xB:xF] = y c[xB:xF]-y[xB:xF] #yc-yo then all dydv have no '-' needed2455 yd[xB:xF] = y[xB:xF]-yc[xB:xF] 2447 2456 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]) 2449 2458 Histogram['wRp'] = min(100.,np.sqrt(np.sum(wdy**2)/Histogram['sumwYo'])*100.) 2450 2459 M = np.concatenate((M,wdy)) … … 2453 2462 Rwp = min(100.,np.sqrt(np.sum(M**2)/sumwYo)*100.) 2454 2463 if dlg: 2455 GoOn = dlg.Update(Rwp,newmsg='%s%8.3f%s'%(' Powder profilewRp =',Rwp,'%'))[0]2464 GoOn = dlg.Update(Rwp,newmsg='%s%8.3f%s'%('wRp =',Rwp,'%'))[0] 2456 2465 if not GoOn: 2457 2466 parmDict['saved values'] = values … … 2511 2520 raise Exception 2512 2521 G2mv.Map2Dict(parmDict,varyList) 2513 print G2mv.VarRemapShow(varyList)2522 # print G2mv.VarRemapShow(varyList) 2514 2523 2515 2524 while True: … … 2533 2542 Values2Dict(parmDict, varyList, result[0]) 2534 2543 G2mv.Dict2Map(parmDict,varyList) 2544 newCellDict = GetNewCellParms(parmDict,varyList) 2535 2545 newAtomDict = ApplyXYZshifts(parmDict,varyList) 2536 2546 … … 2559 2569 break 2560 2570 2561 print 'dependentParmList: ',G2mv.dependentParmList2562 print 'arrayList: ',G2mv.arrayList2563 print 'invarrayList: ',G2mv.invarrayList2564 print 'indParmList: ',G2mv.indParmList2565 print 'fixedDict: ',G2mv.fixedDict2566 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' 2567 2577 GetFobsSq(Histograms,Phases,parmDict,calcControls) 2568 print 'test2'2578 # print 'test2' 2569 2579 sigDict = dict(zip(varyList,sig)) 2570 2580 covData = {'variables':result[0],'varyList':varyList,'sig':sig, 2571 'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict }2581 'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict,'newCellDict':newCellDict} 2572 2582 SetPhaseData(parmDict,sigDict,Phases,covData) 2573 2583 SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms) … … 2576 2586 SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,covData) 2577 2587 #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() 2589 2599 2590 2600 def SeqRefine(GPXfile,dlg): … … 2683 2693 Values2Dict(parmDict, varyList, result[0]) 2684 2694 G2mv.Dict2Map(parmDict,varyList) 2695 newCellDict = GetNewCellParms(parmDict,varyList) 2685 2696 newAtomDict = ApplyXYZshifts(parmDict,varyList) 2686 2697 … … 2711 2722 sigDict = dict(zip(varyList,sig)) 2712 2723 covData = {'variables':result[0],'varyList':varyList,'sig':sig, 2713 'covMatrix':covMatrix,'title':histogram,'newAtomDict':newAtomDict }2724 'covMatrix':covMatrix,'title':histogram,'newAtomDict':newAtomDict,'newCellDict':newCellDict} 2714 2725 SetHistogramPhaseData(parmDict,sigDict,Phases,Histo,ifPrint) 2715 2726 SetHistogramData(parmDict,sigDict,Histo,ifPrint)
Note: See TracChangeset
for help on using the changeset viewer.