Changeset 1392
- Timestamp:
- Jun 23, 2014 4:18:14 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElem.py
r1391 r1392 327 327 328 328 def BlenResTOF(El,BLtables,wave): 329 #FP = np.zeros(len(wave))329 FP = np.zeros(len(wave)) 330 330 FPP = np.zeros(len(wave)) 331 331 BL = BLtables[El][1] -
trunk/GSASIIimage.py
r1387 r1392 78 78 :param int Axis: 0 for rotation about x, 1 for about y, etc. 79 79 ''' 80 cs = cosd(Angle)81 ss = sind(Angle)80 cs = npcosd(Angle) 81 ss = npsind(Angle) 82 82 M = np.array(([1.,0.,0.],[0.,cs,-ss],[0.,ss,cs]),dtype=np.float32) 83 83 return np.roll(np.roll(M,Axis,axis=0),Axis,axis=1) … … 363 363 return GetDetectorXY(dsp,azm,data) 364 364 365 def GetTthAzmDsp(x,y,data): 365 def GetTthAzmDsp(x,y,data): #expensive 366 366 'Needs a doc string - checked OK for ellipses & hyperbola' 367 wave = data['wavelength']368 cent = data['center']369 367 tilt = data['tilt'] 370 dist = data['distance']/cosd(tilt) 371 x0 = data['distance']*tand(tilt) 372 phi = data['rotation'] 373 dep = data['DetDepth'] 374 LRazim = data['LRazimuth'] 375 azmthoff = data['azmthOff'] 376 dx = np.array(x-cent[0],dtype=np.float32) 377 dy = np.array(y-cent[1],dtype=np.float32) 368 dist = data['distance']/npcosd(tilt) 369 x0 = data['distance']*nptand(tilt) 370 dx = x-data['center'][0] 371 dy = y-data['center'][1] 378 372 D = ((dx-x0)**2+dy**2+data['distance']**2) #sample to pixel distance 379 X = np.array(([dx,dy,np.zeros_like(dx)]),dtype=np.float32).T 380 X = np.dot(X,makeMat(phi,2)) 381 Z = np.dot(X,makeMat(tilt,0)).T[2] 373 X = np.dstack([dx,dy,np.zeros_like(dx)]) 374 M = makeMat(data['rotation'],2) 375 N = makeMat(tilt,0) 376 NM = np.inner(N,M) 377 Z = np.dot(X,NM).T[2] 382 378 tth = npatand(np.sqrt(dx**2+dy**2-Z**2)/(dist-Z)) 383 dxy = peneCorr(tth,d ep,tilt,npatan2d(dy,dx))379 dxy = peneCorr(tth,data['DetDepth'],tilt,npatan2d(dy,dx)) 384 380 DX = dist-Z+dxy 385 381 DY = np.sqrt(dx**2+dy**2-Z**2) 386 382 tth = npatan2d(DY,DX) 387 dsp = wave/(2.*npsind(tth/2.))388 azm = (npatan2d(dy,dx)+ azmthoff+720.)%360.383 dsp = data['wavelength']/(2.*npsind(tth/2.)) 384 azm = (npatan2d(dy,dx)+data['azmthOff']+720.)%360. 389 385 G = D/data['distance']**2 #for geometric correction = 1/cos(2theta)^2 if tilt=0. 390 return np.array([tth,azm,G,dsp])386 return tth,azm,G,dsp 391 387 392 388 def GetTth(x,y,data): … … 398 394 return GetTthAzmDsp(x,y,data)[0:2] 399 395 400 def GetTthAzm D(x,y,data):401 '''Give 2-theta, azimuth & d-spacingvalues for detector x,y position;396 def GetTthAzmG(x,y,data): 397 '''Give 2-theta, azimuth & geometric corr. values for detector x,y position; 402 398 calibration info in data 403 399 ''' … … 744 740 return True 745 741 746 def Make2ThetaAzimuthMap(data,masks,iLim,jLim ):742 def Make2ThetaAzimuthMap(data,masks,iLim,jLim,times): #most expensive part of integration! 747 743 'Needs a doc string' 748 744 #transforms 2D image from x,y space to 2-theta,azimuth space based on detector orientation … … 756 752 nI = iLim[1]-iLim[0] 757 753 nJ = jLim[1]-jLim[0] 754 t0 = time.time() 758 755 #make position masks here 759 756 frame = masks['Frames'] … … 776 773 tamp = ma.getmask(ma.masked_less((tax-X)**2+(tay-Y)**2,(diam/2.)**2)) 777 774 tam = ma.mask_or(tam,tamp) 778 TA = np.array(GetTthAzmD(tax,tay,data)) #includes geom. corr. as dist**2/d0**2 775 times[0] += time.time()-t0 776 t0 = time.time() 777 TA = np.array(GetTthAzmG(tax,tay,data)) #includes geom. corr. as dist**2/d0**2 - most expensive step 778 times[1] += time.time()-t0 779 779 TA[1] = np.where(TA[1]<0,TA[1]+360,TA[1]) 780 780 return np.array(TA),tam #2-theta, azimuth & geom. corr. arrays & position mask … … 830 830 nYBlks = (Ny-1)/blkSize+1 831 831 Nup = nXBlks*nYBlks*3+3 832 t 0= time.time()832 tbeg = time.time() 833 833 Nup = 0 834 834 if dlg: 835 835 dlg.Update(Nup) 836 times = [0,0,0,0,0] 836 837 for iBlk in range(nYBlks): 837 838 iBeg = iBlk*blkSize … … 839 840 for jBlk in range(nXBlks): 840 841 jBeg = jBlk*blkSize 841 jFin = min(jBeg+blkSize,Nx) 842 TA,tam = Make2ThetaAzimuthMap(data,masks,(iBeg,iFin),(jBeg,jFin)) #2-theta & azimuth arrays & create position mask843 842 jFin = min(jBeg+blkSize,Nx) 843 # next is most expensive step! 844 TA,tam = Make2ThetaAzimuthMap(data,masks,(iBeg,iFin),(jBeg,jFin),times) #2-theta & azimuth arrays & create position mask 844 845 Nup += 1 845 846 if dlg: 846 847 dlg.Update(Nup) 847 848 Block = image[iBeg:iFin,jBeg:jFin] 849 t0 = time.time() 848 850 tax,tay,taz,tad,tabs = Fill2ThetaAzimuthMap(masks,TA,tam,Block) #and apply masks 851 times[2] += time.time()-t0 849 852 Nup += 1 850 853 if dlg: … … 862 865 elif 'q' == data['binType']: 863 866 tay = 4.*np.pi*npsind(tay/2.)/data['wavelength'] 867 t0 = time.time() 864 868 if any([tax.shape[0],tay.shape[0],taz.shape[0]]): 865 869 NST,H0 = h2d.histogram2d(len(tax),tax,tay,taz*tad/tabs, 866 870 numAzms,numChans,LRazm,lutth,Dazm,dtth,NST,H0) 871 times[3] += time.time()-t0 867 872 Nup += 1 868 873 if dlg: 869 874 dlg.Update(Nup) 875 t0 = time.time() 870 876 NST = np.array(NST,dtype=np.float) 871 877 H0 = np.divide(H0,NST) … … 892 898 if dlg: 893 899 dlg.Update(Nup) 894 t1 = time.time() 900 times[4] += time.time()-t0 901 print 'Step times: \n apply masks %8.3fs xy->th,azm %8.3fs fill map %8.3fs \ 902 \n binning %8.3fs cleanup %8.3fs'%(times[0],times[1],times[2],times[3],times[4]) 903 print "Elapsed time:","%8.3fs"%(time.time()-tbeg) 895 904 print 'Integration complete' 896 print "Elapsed time:","%8.3f"%(t1-t0), "s"897 905 return H0,H1,H2 898 906 -
trunk/GSASIIimgGUI.py
r1389 r1392 64 64 mainSizer.Add(wx.StaticText(G2frame.dataDisplay, 65 65 label='Do not change anything here unless you are absolutely sure!'),0,WACV) 66 mainSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Image size: %d by %d'%(data['size'][0],data['size'][1])),0,WACV) 66 67 pixSize = wx.FlexGridSizer(0,4,5,5) 67 pixLabels = [u' Pixel X-dimension (\xb5m)',u'Pixel Y-dimension (\xb5m)']68 pixLabels = [u' Pixel X-dimension (\xb5m)',u' Pixel Y-dimension (\xb5m)'] 68 69 Indx = {} 69 70 for i,[pixLabel,pix] in enumerate(zip(pixLabels,data['pixelSize'])):
Note: See TracChangeset
for help on using the changeset viewer.