Changeset 245 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Feb 13, 2011 4:57:10 PM (11 years ago)
Author:
vondreele
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r239 r245  
    120120def FitDetector(rings,p0,wave):
    121121    from scipy.optimize import leastsq
    122     def ellipseCalc(B,xyd,wave):
     122       
     123    def ellipseCalcD(B,xyd,wave):
    123124        x = xyd[0]
    124125        y = xyd[1]
     
    138139        YR = X*npsind(phi)+Y*npcosd(phi)
    139140        return (XR/R0)**2+(YR/R1)**2-1
    140     result = leastsq(ellipseCalc,p0,args=(rings.T,wave))
    141     return result[0]
     141    def ellipseCalcW(C,xyd):
     142        dist,x0,y0,phi,tilt,wave = C
     143        B = dist,x0,y0,phi,tilt
     144        return ellipseCalcD(B,xyd,wave)
     145    result = leastsq(ellipseCalcD,p0,args=(rings.T,wave))
     146    if len(rings) > 1:
     147        p0 = result[0]
     148        p0 = np.append(p0,wave)
     149        resultW = leastsq(ellipseCalcW,p0,args=(rings.T,))
     150        return result[0],resultW[0][-1]
     151    else:
     152        return result[0],wave
    142153           
    143154def ImageLocalMax(image,w,Xpix,Ypix):
     
    173184            Y /= scaley
    174185            ring.append([X,Y,dsp])
    175     if len(ring) < 20:             #want more than 1/4 of a circle
     186    if len(ring) < 10:             #want more than 20deg
    176187        return []
    177188    return ring
     
    460471    rings = np.concatenate((data['rings']),axis=0)
    461472    p0 = [dist,cent[0],cent[1],phi,tilt]
    462     result = FitDetector(rings,p0,wave)
     473    result,newWave = FitDetector(rings,p0,wave)
     474    print 'Suggested new wavelength = ',('%.5f')%(newWave),' (not reliable if distance > 2m)'
    463475    data['distance'] = result[0]
    464476    data['center'] = result[1:3]
     
    537549    H0 = np.zeros(shape=(numAzms,numChans),order='F',dtype=np.float32)
    538550    imageN = len(image)
    539     nBlks = (imageN-1)/1024+1
    540     dlg = wx.ProgressDialog("Elapsed time","2D image integration",nBlks*nBlks*3+3,
     551    Nx,Ny = data['size']
     552    nXBlks = (Nx-1)/1024+1
     553    nYBlks = (Ny-1)/1024+1
     554    print Nx,Ny,nXBlks,nYBlks
     555    dlg = wx.ProgressDialog("Elapsed time","2D image integration",nXBlks*nYBlks*3+3,
    541556        style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE)
    542557    try:
     
    544559        Nup = 0
    545560        dlg.Update(Nup)
    546         for iBlk in range(nBlks):
     561        for iBlk in range(nYBlks):
    547562            iBeg = iBlk*1024
    548             iFin = min(iBeg+1024,imageN)
    549             for jBlk in range(nBlks):
     563            iFin = min(iBeg+1024,Ny)
     564            for jBlk in range(nXBlks):
    550565                jBeg = jBlk*1024
    551                 jFin = min(jBeg+1024,imageN)               
     566                jFin = min(jBeg+1024,Nx)               
    552567                print 'Process map block',iBlk,jBlk,iBeg,iFin,jBeg,jFin
    553568                TA,tam = Make2ThetaAzimuthMap(data,masks,(iBeg,iFin),(jBeg,jFin))           #2-theta & azimuth arrays & create position mask
Note: See TracChangeset for help on using the changeset viewer.