Changeset 1158


Ignore:
Timestamp:
Nov 27, 2013 2:34:56 PM (8 years ago)
Author:
vondreele
Message:

the mask frame now limits points used in Recalibrate (not Calibrate)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r1155 r1158  
    2020import numpy as np
    2121import numpy.linalg as nl
     22import numpy.ma as ma
     23import polymask as pm
    2224from scipy.optimize import leastsq
    2325import copy
     
    465467    return zip(tax,tay)
    466468   
    467 def ImageRecalibrate(self,data):
     469def 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   
     497def ImageRecalibrate(self,data,masks):
    468498    'Needs a doc string'
    469499    import ImageCalibrants as calFile
     
    479509    if not data['calibrant']:
    480510        print 'no calibration material selected'
    481         return True
    482    
     511        return True   
    483512    skip = data['calibskip']
    484513    dmin = data['calibdmin']
     
    495524    Found = False
    496525    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))
    497530    for iH,H in enumerate(HKL):
    498531        dsp = H[3]
     
    502535            break
    503536        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))
    505538        if Ring:
    506539            if iH >= skip:
     
    690723def Make2ThetaAzimuthMap(data,masks,iLim,jLim):
    691724    'Needs a doc string'
    692     import numpy.ma as ma
    693     import polymask as pm
    694725    #transforms 2D image from x,y space to 2-theta,azimuth space based on detector orientation
    695726    pixelSize = data['pixelSize']
     
    728759def Fill2ThetaAzimuthMap(masks,TA,tam,image):
    729760    'Needs a doc string'
    730     import numpy.ma as ma
    731761    Zlim = masks['Thresholds'][1]
    732762    rings = masks['Rings']
  • trunk/GSASIIimgGUI.py

    r1153 r1158  
    6262       
    6363    def OnRecalibrate(event):
    64         G2img.ImageRecalibrate(G2frame,data)
     64        G2img.ImageRecalibrate(G2frame,data,masks)
    6565        UpdateImageControls(G2frame,data,masks)
    6666       
Note: See TracChangeset for help on using the changeset viewer.