Changeset 1204
- Timestamp:
- Jan 22, 2014 2:41:42 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r1203 r1204 43 43 DEBUG = False #=True for various prints 44 44 TRANSP = False #=true to transpose images for testing 45 npsind = lambda x: np.sin(x*np.pi/180.) 45 46 46 47 def sfloat(S): … … 831 832 azms = G2frame.Integrate[1] 832 833 X = G2frame.Integrate[2][:-1] 833 Xminmax = [X[0],X[-1]]834 834 N = len(X) 835 835 Id = G2frame.PatternTree.GetItemParent(PickId) … … 843 843 names = ['Type','Lam','Zero','Azimuth'] 844 844 codes = [0 for i in range(4)] 845 X = 4.*np.pi*npsind(X/2.)/data['wavelength'] #convert to q 846 Xminmax = [X[0],X[-1]] 845 847 LRazm = data['LRazimuth'] 846 848 Azms = [] -
trunk/GSASIIimage.py
r1203 r1204 837 837 elif 'q' == data['binType']: 838 838 tay = 4.*np.pi*npsind(tay/2.)/data['wavelength'] 839 #change 2-theta (tay) to q or log(q) here? then LUtth & Dtth need to be changed also840 839 if any([tax.shape[0],tay.shape[0],taz.shape[0]]): 841 840 NST,H0 = h2d.histogram2d(len(tax),tax,tay,taz*tad*tabs,numAzms,numChans,LRazm,lutth,Dazm,dtth,NST,H0) … … 851 850 H2 = 2.*npasind(np.exp(H2)*data['wavelength']/(4.*np.pi)) 852 851 elif 'q' == data['binType']: 853 H2 = 2.*npasind(H2*data['wavelength']/(4.*np.pi)) 852 H2 = 2.*npasind(H2*data['wavelength']/(4.*np.pi)) 854 853 if Dazm: 855 854 H1 = np.array([azm for azm in np.linspace(LRazm[0],LRazm[1],numAzms+1)]) … … 860 859 H0 /= G2pwd.Oblique(data['Oblique'][0],H2[:-1]) 861 860 if 'SASD' in data['type'] and data['PolaVal'][1]: 862 H0 /= np.array([G2pwd.Polarization(data['PolaVal'][0],H2[:-1],Azm=azm)[0] for azm in H1[:-1]+np.diff(H1)/2.])861 H0 /= np.array([G2pwd.Polarization(data['PolaVal'][0],H2[:-1],Azm=azm)[0] for azm in (H1[:-1]+np.diff(H1)/2.)]) 863 862 Nup += 1 864 863 if dlg: -
trunk/GSASIIimgGUI.py
r1203 r1204 57 57 data['SampleAbs'] = [0.0,False] 58 58 if 'binType' not in data: 59 data['binType'] = '2-theta' 59 if 'PWDR' in data['type']: 60 data['binType'] = '2-theta' 61 elif 'SASD' in data['type']: 62 data['binType'] = 'log(q)' 60 63 #end patch 61 64 … … 88 91 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 89 92 try: 90 if data['background image'][0]: 91 maskCopy = copy.deepcopy(masks) 92 backImg = data['background image'][0] 93 backScale = data['background image'][1] 94 id = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, backImg) 95 Npix,imagefile = G2frame.PatternTree.GetItemPyData(id) 96 backImage = G2IO.GetImageData(G2frame,imagefile,True)*backScale 97 sumImage = G2frame.ImageZ+backImage 98 G2frame.Integrate = G2img.ImageIntegrate(sumImage,data,maskCopy,blkSize,dlg) 99 else: 100 G2frame.Integrate = G2img.ImageIntegrate(G2frame.ImageZ,data,masks,blkSize,dlg) 93 sumImg = G2frame.ImageZ 94 darkImg,darkScale = data['dark image'] 95 if darkImg: 96 Did = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, darkImg) 97 Npix,imagefile = G2frame.PatternTree.GetItemPyData(Did) 98 darkImage = G2IO.GetImageData(G2frame,imagefile,True) 99 sumImg += darkImage*darkScale 100 backImg,backScale = data['background image'] 101 if backImg: #ignores any transmission effect in the background image 102 Bid = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, backImg) 103 Npix,imagefile = G2frame.PatternTree.GetItemPyData(Bid) 104 backImage = G2IO.GetImageData(G2frame,imagefile,True) 105 Bdata = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Bid,'Image Controls')) 106 BdarkImg,BdarkScale = Bdata['dark image'] 107 if BdarkImg: 108 BDid = G2gd.GetPatternTreeItemId(G2frame, G2frame.root,BdarkImg) 109 Npix,imagefile = G2frame.PatternTree.GetItemPyData(BDid) 110 BdarkImage = G2IO.GetImageData(G2frame,imagefile,True) 111 backImage += BdarkImage*BdarkScale 112 sumImg += backImage*backScale 113 G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,dlg) 101 114 # G2plt.PlotIntegration(G2frame,newPlot=True) 102 115 G2IO.SaveIntegration(G2frame,G2frame.PickId,data) … … 277 290 def OnDataType(event): 278 291 data['type'] = typeSel.GetValue()[:4] 279 if 'SASD' in data['type'] and not data['SampleAbs'][0]: 280 data['SampleAbs'][0] = 1.0 #switch from muT=0 to trans=1! 292 if 'SASD' in data['type']: 293 data['SampleAbs'][0] = np.exp(-data['SampleAbs'][0]) #switch from muT to trans! 294 if data['binType'] == '2-theta': data['binType'] = 'log(q)' #switch default bin type 295 elif 'PWDR' in data['type']: 296 data['SampleAbs'][0] = -np.log(data['SampleAbs'][0]) #switch from trans to muT! 297 if data['binType'] == 'log(q)': data['binType'] = '2-theta' #switch default bin type 281 298 wx.CallAfter(UpdateImageControls,G2frame,data,masks) 282 299 … … 598 615 wx.ALIGN_CENTER_VERTICAL) 599 616 dataSizer.Add((5,0),0) 600 binChoice = ['2-theta','q','log(q)'] 601 dataSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Bin style: Constant'),0, 617 if 'PWDR' in data['type']: 618 binChoice = ['2-theta','q'] 619 elif 'SASD' in data['type']: 620 binChoice = ['q','log(q)'] 621 dataSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Bin style: Constant step bins in'),0, 602 622 wx.ALIGN_CENTER_VERTICAL) 603 623 binSel = wx.ComboBox(parent=G2frame.dataDisplay,value=data['binType'],choices=binChoice, … … 718 738 data['background image'][0] = backImage.GetValue() 719 739 740 def OnDarkImage(event): 741 data['dark image'][0] = darkImage.GetValue() 742 720 743 def OnBackMult(event): 721 744 try: … … 726 749 backMult.SetValue("%.3f" % (data['background image'][1])) #reset in case of error 727 750 751 def OnDarkMult(event): 752 try: 753 mult = float(darkMult.GetValue()) 754 data['dark image'][1] = mult 755 except ValueError: 756 pass 757 darkMult.SetValue("%.3f" % (data['dark image'][1])) #reset in case of error 758 728 759 backSizer = wx.FlexGridSizer(1,4,5,5) 760 761 backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Dark image'),0,wx.ALIGN_CENTER_VERTICAL) 762 Choices = ['',]+G2gd.GetPatternTreeDataNames(G2frame,['IMG ',]) 763 darkImage = wx.ComboBox(parent=G2frame.dataDisplay,value=data['dark image'][0],choices=Choices, 764 style=wx.CB_READONLY|wx.CB_DROPDOWN) 765 darkImage.Bind(wx.EVT_COMBOBOX,OnDarkImage) 766 backSizer.Add(darkImage) 767 backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' multiplier'),0,wx.ALIGN_CENTER_VERTICAL) 768 darkMult = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (data['dark image'][1])), 769 style=wx.TE_PROCESS_ENTER) 770 darkMult.Bind(wx.EVT_TEXT_ENTER,OnDarkMult) 771 darkMult.Bind(wx.EVT_KILL_FOCUS,OnDarkMult) 772 backSizer.Add(darkMult,0,wx.ALIGN_CENTER_VERTICAL) 773 729 774 backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Background image'),0,wx.ALIGN_CENTER_VERTICAL) 730 775 Choices = ['',]+G2gd.GetPatternTreeDataNames(G2frame,['IMG ',]) … … 875 920 data['azmthOff'] = 0.0 876 921 if 'background image' not in data: 877 data['background image'] = ['',1.0] 922 data['background image'] = ['',-1.0] 923 if 'dark image' not in data: 924 data['dark image'] = ['',-1.0] 878 925 if 'centerAzm' not in data: 879 926 data['centerAzm'] = False -
trunk/GSASIIplot.py
r1203 r1204 451 451 G2frame.SinglePlot = False 452 452 G2frame.Offset = [0.,0.] 453 elif event.key == 'q' :453 elif event.key == 'q' and 'PWDR' in plottype: 454 454 newPlot = True 455 455 if G2frame.qPlot: … … 489 489 dlg.Destroy() 490 490 491 PlotPatterns(G2frame,newPlot=newPlot,plotType=plottype)491 wx.CallAfter(PlotPatterns,G2frame,newPlot=newPlot,plotType=plottype) 492 492 493 493 def OnMotion(event): … … 500 500 if 'C' in Parms['Type'][0]: 501 501 wave = G2mth.getWave(Parms) 502 if G2frame.qPlot :502 if G2frame.qPlot and 'PWDR' in plottype: 503 503 try: 504 504 xpos = 2.0*asind(xpos*wave/(4*math.pi)) … … 506 506 pass 507 507 dsp = 0.0 508 if abs(xpos) > 0.: #avoid possible singularity at beam center 509 dsp = wave/(2.*sind(abs(xpos)/2.0)) 510 q = 2.*np.pi/dsp 508 if abs(xpos) > 0.: 509 if 'PWDR' in plottype: #avoid possible singularity at beam center 510 dsp = wave/(2.*sind(abs(xpos)/2.0)) 511 q = 2.*np.pi/dsp 512 elif 'SASD' in plottype: 513 dsp = 2*np.pi/xpos 514 q = xpos 511 515 if G2frame.Contour: 512 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 516 if 'PWDR' in plottype: 517 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f pattern ID =%5d'%(xpos,dsp,q,int(ypos)),1) 518 elif 'SASD' in plottype: 519 G2frame.G2plotNB.status.SetStatusText('d =%9.5f q = %9.5f pattern ID =%5d'%(dsp,q,int(ypos)),1) 513 520 else: 514 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 521 if 'PWDR' in plottype: 522 G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 523 elif 'SASD' in plottype: 524 G2frame.G2plotNB.status.SetStatusText('d =%9.5f q = %9.5f Intensity =%12.5g'%(dsp,q,ypos),1) 515 525 else: #TOF neutrons 516 526 dsp = 0.0 … … 576 586 data = G2frame.PatternTree.GetItemPyData(LimitId) 577 587 if 'C' in Parms['Type'][0]: #CW data - TOF later in an elif 578 if G2frame.qPlot : #qplot - convert back to 2-theta588 if G2frame.qPlot and 'PWDR' in plottype: #qplot - convert back to 2-theta 579 589 xy[0] = 2.0*asind(xy[0]*wave/(4*math.pi)) 580 590 if G2frame.ifGetExclude: … … 612 622 for line in G2frame.Lines: 613 623 lines.append(line.get_xdata()[0]) 614 # print G2frame.itemPicked.get_xdata() 615 lineNo = lines.index(G2frame.itemPicked.get_xdata()[0]) 624 try: 625 lineNo = lines.index(G2frame.itemPicked.get_xdata()[0]) 626 except ValueError: 627 lineNo = -1 616 628 if lineNo in [0,1] or lineNo in exclLines: 617 629 LimitId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Limits') … … 619 631 id = lineNo/2+1 620 632 id2 = lineNo%2 621 if G2frame.qPlot :633 if G2frame.qPlot and 'PWDR' in plottype: 622 634 if 'C' in Parms['Type'][0]: 623 635 data[id][id2] = 2.0*asind(wave*xpos/(4*math.pi)) … … 631 643 if G2frame.PatternTree.GetItemText(G2frame.PickId) == 'Limits': 632 644 G2pdG.UpdateLimitsGrid(G2frame,data) 633 el se:645 elif lineNo > 1: 634 646 PeakId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Peak List') 635 647 data = G2frame.PatternTree.GetItemPyData(PeakId) … … 692 704 Page.Choice = (' key press','l: offset left','r: offset right','d: offset down', 693 705 'u: offset up','o: reset offset','n: log(I) on','c: contour on', 694 ' q: toggle q plot','s: toggle single plot','+: no selection')706 's: toggle single plot','+: no selection') 695 707 Page.keyPress = OnPlotKeyPress 696 708 … … 753 765 Title = 'log('+Title+')' 754 766 Plot.set_title(Title) 755 if G2frame.qPlot :767 if G2frame.qPlot or 'SASD' in plottype: 756 768 Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=16) 757 769 else: … … 795 807 for excl in excls: 796 808 xye[0] = ma.masked_inside(xye[0],excl[0],excl[1]) 797 if G2frame.qPlot :809 if G2frame.qPlot and 'PWDR' in plottype: 798 810 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2]) 799 811 if 'C' in Parms['Type'][0]: … … 809 821 elif 'SASD' in plottype: 810 822 Y = xye[1]*Sample['Scale'][0]+offset*N 811 if LimitId :823 if LimitId and ifpicked: 812 824 limits = np.array(G2frame.PatternTree.GetItemPyData(LimitId)) 813 if G2frame.qPlot :825 if G2frame.qPlot and 'PWDR' in plottype: 814 826 if 'C' in Parms['Type'][0]: 815 827 limits = 4*np.pi*npsind(limits/2.0)/wave
Note: See TracChangeset
for help on using the changeset viewer.