Changeset 2772
- Timestamp:
- Apr 4, 2017 3:34:02 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r2766 r2772 2837 2837 2838 2838 ''' 2839 global xylim 2839 2840 def OnKeyPress(event): 2840 2841 if event.key == 'u': … … 2855 2856 if XY2 != None: 2856 2857 G2IO.XYsave(G2frame,XY2,labelX,labelY,names2) 2857 else: 2858 # print 'no binding for key',event.key 2859 #GSASIIpath.IPyBreak() 2860 return 2861 wx.CallAfter(PlotXY,G2frame,XY,XY2,labelX,labelY,False,Title,lines,names) 2858 # else: 2859 # return 2860 Draw() 2862 2861 2863 2862 def OnMotion(event): … … 2870 2869 except TypeError: 2871 2870 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 2871 2872 def Draw(): 2873 global xylim 2874 print Page.Offset 2875 Plot.clear() 2876 Plot.set_title(Title) 2877 Plot.set_xlabel(r''+labelX,fontsize=14) 2878 Plot.set_ylabel(r''+labelY,fontsize=14) 2879 colors=['b','r','g','c','m','k'] 2880 Page.keyPress = OnKeyPress 2881 Xmax = 0. 2882 Ymax = 0. 2883 for ixy,xy in enumerate(XY): 2884 X,Y = XY[ixy] 2885 Xmax = max(Xmax,max(X)) 2886 Ymax = max(Ymax,max(Y)) 2887 if lines: 2888 dX = Page.Offset[0]*(ixy)*Xmax/500. 2889 dY = Page.Offset[1]*(ixy)*Ymax/100. 2890 if len(names): 2891 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names[ixy]) 2892 else: 2893 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False) 2894 else: 2895 Plot.plot(X,Y,colors[ixy%6]+'+',picker=False) 2896 if len(vertLines): 2897 for ixy,X in enumerate(vertLines): 2898 dX = Page.Offset[0]*(ixy)*Xmax/500. 2899 for x in X: 2900 Plot.axvline(x+dX,color=colors[ixy%6],dashes=(5,5),picker=False) 2901 if XY2 is not None and len(XY2): 2902 for ixy,xy in enumerate(XY2): 2903 X,Y = XY2[ixy] 2904 dX = Page.Offset[0]*(ixy+1)*Xmax/500. 2905 dY = Page.Offset[1]*(ixy+1)*Ymax/100. 2906 if len(names2): 2907 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names2[ixy]) 2908 else: 2909 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False) 2910 if len(names): 2911 Plot.legend(loc='best') 2912 if not newPlot: 2913 Page.toolbar.push_current() 2914 Plot.set_xlim(xylim[0]) 2915 Plot.set_ylim(xylim[1]) 2916 xylim = [] 2917 Page.toolbar.push_current() 2918 Page.toolbar.draw() 2919 Page.canvas.draw() 2920 else: 2921 Page.canvas.draw() 2872 2922 2873 2923 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'mpl') 2924 Page.Offset = [0,0] 2874 2925 if not new: 2875 2926 if not newPlot: … … 2886 2937 else: 2887 2938 Page.Choice = None 2888 G2frame.G2plotNB.status.DestroyChildren() 2889 Plot.set_title(Title) 2890 Plot.set_xlabel(r''+labelX,fontsize=14) 2891 Plot.set_ylabel(r''+labelY,fontsize=14) 2892 colors=['b','g','r','c','m','k'] 2893 Page.keyPress = OnKeyPress 2894 Xmax = 0. 2895 Ymax = 0. 2896 for ixy,xy in enumerate(XY): 2897 X,Y = XY[ixy] 2898 Xmax = max(Xmax,max(X)) 2899 Ymax = max(Ymax,max(Y)) 2900 if lines: 2901 dX = Page.Offset[0]*(ixy+1)*Xmax/500. 2902 dY = Page.Offset[1]*(ixy+1)*Ymax/100. 2903 if len(names): 2904 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names[ixy]) 2905 else: 2906 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False) 2907 else: 2908 Plot.plot(X,Y,colors[ixy%6]+'+',picker=False) 2909 if len(vertLines): 2910 for ixy,X in enumerate(vertLines): 2911 dX = Page.Offset[0]*(ixy+1)*Xmax/500. 2912 for x in X: 2913 Plot.axvline(x+dX,color=colors[ixy%6],dashes=(5,5),picker=False) 2914 if XY2 is not None and len(XY2): 2915 for ixy,xy in enumerate(XY2): 2916 X,Y = XY2[ixy] 2917 dX = Page.Offset[0]*(ixy+1)*Xmax/500. 2918 dY = Page.Offset[1]*(ixy+1)*Ymax/100. 2919 if len(names2): 2920 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names2[ixy]) 2921 else: 2922 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False) 2923 if len(names): 2924 Plot.legend(loc='best') 2925 if not newPlot: 2926 Page.toolbar.push_current() 2927 Plot.set_xlim(xylim[0]) 2928 Plot.set_ylim(xylim[1]) 2929 xylim = [] 2930 Page.toolbar.push_current() 2931 Page.toolbar.draw() 2932 else: 2933 Page.canvas.draw() 2939 Draw() 2940 2934 2941 2935 2942 ################################################################################ -
trunk/GSASIIpwd.py
r2767 r2772 1915 1915 1916 1916 def REFDRefine(Profile,ProfDict,Inst,Limits,Substances,data): 1917 print 'fit REFD data by '+data['Minimizer'] 1917 print 'fit REFD data by '+data['Minimizer']+' using %.2f%% data resolution'%(data['Resolution'][0]) 1918 1918 1919 1919 def GetModelParms(): … … 1922 1922 values = [] 1923 1923 bounds = [] 1924 parmDict['Res'] = data['Resolution'][0]/100. #%-->decimal 1924 1925 for parm in ['Scale','FltBack']: 1925 1926 parmDict[parm] = data[parm][0] … … 1985 1986 Scale = parmDict['Scale'] 1986 1987 Nlayers = parmDict['nLayers'] 1988 Res = parmDict['Res'] 1989 Gaus = np.zeros((9,len(Q))) 1987 1990 depth = np.zeros(Nlayers) 1988 1991 rho = np.zeros(Nlayers) … … 2006 2009 2007 2010 Q,Io,wt,Ic,Ib,Ifb = Profile[:6] 2011 if data.get('2% weight'): 2012 wt = 1./(0.02*Io)**2 2008 2013 Qmin = Limits[1][0] 2009 2014 Qmax = Limits[1][1] -
trunk/GSASIIpwdGUI.py
r2771 r2772 4755 4755 return 4756 4756 plotList = [] 4757 od = {'label_1':'Zero at substrate','value_1':False }4757 od = {'label_1':'Zero at substrate','value_1':False,'label_2':'Show layer transitions','value_2':True} 4758 4758 dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame,'Plot reflectivity models for:', 4759 4759 'Plot SLD models', histList,extraOpts=od) … … 4762 4762 for i in dlg.GetSelections(): 4763 4763 plotList.append(histList[i]) 4764 else: 4765 dlg.Destroy() 4766 return 4764 4767 finally: 4765 4768 dlg.Destroy() 4766 4769 XY = [] 4770 LinePos = [] 4767 4771 for item in plotList: 4768 4772 mId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item) … … 4776 4780 XY.append([x,y]) 4777 4781 disLabel = r'$Distance\ from\ top\ surface,\ \AA$' 4782 if od['value_2']: 4783 nLines = len(model['Layers'])-1 4784 linePos = np.zeros(nLines) 4785 for ilay,layer in enumerate(model['Layers'][1:-1]): 4786 linePos[ilay+1:] += layer.get('Thick',[0.,False])[0] 4787 if od['value_1']: 4788 linePos = linePos[-1]-linePos 4789 LinePos.append(linePos) 4778 4790 G2plt.PlotXY(G2frame,XY,labelX=disLabel,labelY=r'$SLD,\ 10^{10}cm^{-2}$',newPlot=True, 4779 Title='Scattering length density',lines=True,names=[] )4791 Title='Scattering length density',lines=True,names=[],vertLines=LinePos) 4780 4792 4781 4793 def OnFitModelAll(event): … … 4788 4800 for ilay,layer in enumerate(data['Layers'][1:-1]): 4789 4801 linePos[ilay+1:] += layer.get('Thick',[0.,False])[0] 4790 if data['Zero'] :4802 if data['Zero'] == 'Top': 4791 4803 XY = [[x,y],] 4792 4804 disLabel = r'$Distance\ from\ top\ surface,\ \AA$' 4793 4805 else: 4794 4806 XY = [[xr,y],] 4807 linePos = linePos[-1]-linePos 4795 4808 disLabel = r'$Distance\ from\ substrate,\ \AA$' 4796 4809 G2plt.PlotXY(G2frame,XY,labelX=disLabel,labelY=r'$SLD,\ 10^{10}cm^{-2}$',newPlot=True, … … 4833 4846 def OnMinSel(event): 4834 4847 data['Minimizer'] = minSel.GetValue() 4848 4849 def OnWeight(event): 4850 data['2% weight'] = weight.GetValue() 4835 4851 4836 4852 controlSizer = wx.BoxSizer(wx.VERTICAL) … … 4854 4870 minimiz.Add(wx.StaticText(G2frame.dataDisplay,label=' Tolerance: '),0,WACV) 4855 4871 minimiz.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'Toler',nDig=(10,1,'g'),typeHint=float),0,WACV) 4872 weight = wx.CheckBox(G2frame.dataDisplay,label='Use 2% sig. weights') 4873 weight.SetValue(data.get('2% weight',False)) 4874 weight.Bind(wx.EVT_CHECKBOX, OnWeight) 4875 minimiz.Add(weight,0,WACV) 4876 4856 4877 #Recomb':0.5, needed?? 4857 4878 controlSizer.Add(minimiz,0,WACV) -
trunk/imports/G2img_1TIF.py
r2756 r2772 23 23 import GSASIIpath 24 24 import numpy as np 25 import time 25 26 DEBUG = False 26 27 GSASIIpath.SetVersionNumber("$Revision$") … … 152 153 [nx,ny] = sizexy 153 154 Npix = nx*ny 155 time0 = time.time() 154 156 if 34710 in IFD: 155 157 print 'Read MAR CCD tiff file: ',filename … … 206 208 File.seek(8) 207 209 print 'Read GE-detector tiff file: ',filename 208 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 210 image = np.fromfile(File,dtype=np.int16,count=2*Npix)[:Npix] 211 # image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 209 212 elif IFD[258][2][0] == 32: 210 213 tifType = 'CHESS' … … 231 234 File.seek(512) 232 235 print 'Read DND SAX/WAX-detector tiff file: ',filename 233 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 236 image = np.fromfile(File,dtype=np.int16,count=2*Npix)[:Npix] 237 # image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 234 238 elif sizexy == [1536,1536]: 235 239 tifType = 'APS Gold' … … 237 241 File.seek(64) 238 242 print 'Read Gold tiff file:',filename 239 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 243 image = np.fromfile(File,dtype=np.int16,count=2*Npix)[:Npix] 244 # image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 240 245 elif sizexy == [2048,2048] or sizexy == [1024,1024] or sizexy == [3072,3072]: 241 246 if IFD[273][2][0] == 8: … … 246 251 print 'Read APS PE-detector tiff file: ',filename 247 252 if dataType == 5: 248 image = np.array(ar.array('f',File.read(4*Npix)),dtype=np.int32) 253 image = np.fromfile(File,dtype=np.float32,count=4*Npix)[:Npix] 254 # image = np.array(ar.array('f',File.read(4*Npix)),dtype=np.int32) 249 255 else: 250 image = np.array(ar.array('I',File.read(4*Npix)),dtype=np.int32) 256 image = np.fromfile(File,dtype=np.int,count=4*Npix)[:Npix] 257 # image = np.array(ar.array('I',File.read(4*Npix)),dtype=np.int32) 251 258 elif IFD[258][2][0] == 16: 252 259 tifType = 'MedOptics D1' … … 265 272 File.seek(4096) 266 273 print 'Read MAR CCD tiff file: ',filename 267 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 274 image = np.fromfile(File,dtype=np.int16,count=2*Npix)[:Npix] 275 # image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 268 276 elif IFD[273][2][0] == 512: 269 277 tifType = '11-ID-C' … … 286 294 File.seek(8) 287 295 print 'Read PE 4Kx4K tiff file: ',filename 288 image = np.array(ar.array('f',File.read(4*Npix)),dtype=np.int32) 296 image = np.fromfile(File,dtype=np.uint,count=4*Npix)[:Npix] 297 if np.max(image) > 2**31: 298 image = np.array(image-2**30,dtype=np.int32) 299 else: 300 image = np.array(image,dtype=np.int32) 301 # arry = ar.array('I',File.read(4*Npix)) 302 # image = np.array(arry)/2**16 289 303 elif IFD[273][2][0] == 4096: 290 304 tifType = 'Rayonix' … … 292 306 File.seek(4096) 293 307 print 'Read Rayonix MX300HE tiff file: ',filename 294 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 308 image = np.fromfile(File,dtype=np.int16,count=2*Npix)[:Npix] 309 # image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 295 310 # elif sizexy == [960,960]: 296 311 # tiftype = 'PE-BE' … … 308 323 lines = ['not a known detector tiff file',] 309 324 return lines,0,0,0 310 325 print 'image read time: %.3f'%(time.time()-time0) 311 326 image = np.reshape(image,(sizexy[1],sizexy[0])) 312 327 center = (not center[0]) and [pixy[0]*sizexy[0]/2000,pixy[1]*sizexy[1]/2000] or center
Note: See TracChangeset
for help on using the changeset viewer.