Changeset 1158
- Timestamp:
- Nov 27, 2013 2:34:56 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r1155 r1158 20 20 import numpy as np 21 21 import numpy.linalg as nl 22 import numpy.ma as ma 23 import polymask as pm 22 24 from scipy.optimize import leastsq 23 25 import copy … … 465 467 return zip(tax,tay) 466 468 467 def ImageRecalibrate(self,data): 469 def MakeFrameMask(data,frame): 470 pixelSize = data['pixelSize'] 471 scalex = pixelSize[0]/1000. 472 scaley = pixelSize[1]/1000. 473 blkSize = 512 474 Nx,Ny = data['size'] 475 nXBlks = (Nx-1)/blkSize+1 476 nYBlks = (Ny-1)/blkSize+1 477 tam = ma.make_mask_none(data['size']) 478 for iBlk in range(nXBlks): 479 iBeg = iBlk*blkSize 480 iFin = min(iBeg+blkSize,Nx) 481 for jBlk in range(nYBlks): 482 jBeg = jBlk*blkSize 483 jFin = min(jBeg+blkSize,Ny) 484 nI = iFin-iBeg 485 nJ = jFin-jBeg 486 tax,tay = np.mgrid[iBeg+0.5:iFin+.5,jBeg+.5:jFin+.5] #bin centers not corners 487 tax = np.asfarray(tax*scalex,dtype=np.float32) 488 tay = np.asfarray(tay*scaley,dtype=np.float32) 489 tamp = ma.make_mask_none((1024*1024)) 490 tamp = ma.make_mask(pm.polymask(nI*nJ,tax.flatten(), 491 tay.flatten(),len(frame),frame,tamp)[:nI*nJ])-True #switch to exclude around frame 492 if tamp.shape: 493 tamp = np.reshape(tamp[:nI*nJ],(nI,nJ)) 494 tam[iBeg:iFin,jBeg:jFin] = ma.mask_or(tamp[0:nI,0:nJ],tam[iBeg:iFin,jBeg:jFin]) 495 return tam.T 496 497 def ImageRecalibrate(self,data,masks): 468 498 'Needs a doc string' 469 499 import ImageCalibrants as calFile … … 479 509 if not data['calibrant']: 480 510 print 'no calibration material selected' 481 return True 482 511 return True 483 512 skip = data['calibskip'] 484 513 dmin = data['calibdmin'] … … 495 524 Found = False 496 525 wave = data['wavelength'] 526 frame = masks['Frames'] 527 tam = ma.make_mask_none(self.ImageZ.shape) 528 if frame: 529 tam = ma.mask_or(tam,MakeFrameMask(data,frame)) 497 530 for iH,H in enumerate(HKL): 498 531 dsp = H[3] … … 502 535 break 503 536 ellipse = GetEllipse(dsp,data) 504 Ring,delt,sumI = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley, self.ImageZ)537 Ring,delt,sumI = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,ma.array(self.ImageZ,mask=tam)) 505 538 if Ring: 506 539 if iH >= skip: … … 690 723 def Make2ThetaAzimuthMap(data,masks,iLim,jLim): 691 724 'Needs a doc string' 692 import numpy.ma as ma693 import polymask as pm694 725 #transforms 2D image from x,y space to 2-theta,azimuth space based on detector orientation 695 726 pixelSize = data['pixelSize'] … … 728 759 def Fill2ThetaAzimuthMap(masks,TA,tam,image): 729 760 'Needs a doc string' 730 import numpy.ma as ma731 761 Zlim = masks['Thresholds'][1] 732 762 rings = masks['Rings'] -
trunk/GSASIIimgGUI.py
r1153 r1158 62 62 63 63 def OnRecalibrate(event): 64 G2img.ImageRecalibrate(G2frame,data )64 G2img.ImageRecalibrate(G2frame,data,masks) 65 65 UpdateImageControls(G2frame,data,masks) 66 66
Note: See TracChangeset
for help on using the changeset viewer.