Changeset 262


Ignore:
Timestamp:
Mar 11, 2011 4:16:46 PM (11 years ago)
Author:
vondreele
Message:

GSASIIimage.py - fix for nonsquare images
& a try at fixing Pilatus 100 problem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r261 r262  
    5656    return np.roll(np.roll(M,Axis,axis=0),Axis,axis=1)
    5757                   
    58 def FitRing(ring):
    59     err,parms = FitEllipse(ring)
     58def FitRing(ring,delta):
     59    parms = []
     60    if delta:
     61        err,parms = FitEllipse(ring)
    6062    errc,parmsc = FitCircle(ring)
    6163    errc = errc[0]/(len(ring)*parmsc[2][0]**2)
    62 #    print 'Ellipse?',err,parms
     64#    print 'Ellipse?',err,parms,len(ring)
    6365#    print 'Circle? ',errc,parmsc
    6466    if not parms or errc < .1:
     
    155157def ImageLocalMax(image,w,Xpix,Ypix):
    156158    w2 = w*2
    157     size = len(image)
     159    sizey,sizex = image.shape
    158160    xpix = int(Xpix)            #get reference corner of pixel chosen
    159161    ypix = int(Ypix)
    160     if (w < xpix < size-w) and (w < ypix < size-w) and image[ypix,xpix]:
     162    if (w < xpix < sizex-w) and (w < ypix < sizey-w) and image[ypix,xpix]:
    161163        Z = image[ypix-w:ypix+w,xpix-w:xpix+w]
    162164        Zmax = np.argmax(Z)
     
    173175    sphi = sind(phi)
    174176    ring = []
     177    amin = 180
     178    amax = -180
    175179    for a in range(-180,180,1):
    176180        x = radii[0]*cosd(a)
     
    184188            X /= scalex                         #convert to mm
    185189            Y /= scaley
     190            amin = min(amin,a)
     191            amax = max(amax,a)
    186192            ring.append([X,Y,dsp])
    187193    if len(ring) < 20:             #want more than 20 deg
    188         return []
    189     return ring
     194        return [],amax-amin
     195    return ring,amax-amin > 90
    190196   
    191197def makeIdealRing(ellipse,azm=None):
     
    328334    #fit start points on inner ring
    329335    data['ellipses'] = []
    330     outE = FitRing(ring)
     336    outE = FitRing(ring,True)
    331337    if outE:
    332338        print 'start ellipse:',outE
     
    336342       
    337343    #setup 360 points on that ring for "good" fit
    338     Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
     344    Ring,delt = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
    339345    if Ring:
    340         ellipse = FitRing(Ring)
    341         Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)    #do again
    342         ellipse = FitRing(Ring)
     346        ellipse = FitRing(Ring,delt)
     347        Ring,delt = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)    #do again
     348        ellipse = FitRing(Ring,delt)
    343349    else:
    344350        print '1st ring not sufficiently complete to proceed'
     
    396402        elcent = [cent[0]+zsinp,cent[1]-zcosp]
    397403        ratio = radii[1]/radii[0]
    398         Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
     404        Ring,delt = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
    399405        if Ring:
    400406            numZ = len(Ring)
    401407            data['rings'].append(np.array(Ring))
    402             newellipse = FitRing(Ring)
     408            newellipse = FitRing(Ring,delt)
    403409            elcent,phi,radii = newellipse               
    404410            if abs(phi) > 45. and phi < 0.:
     
    407413            distR = 1.-dist/data['distance']
    408414            if abs(distR) > 0.01:
    409 #                print distR,dist,data['distance']
    410 #                del data['rings'][-1]
    411415                continue
    412416            if distR > 0.001:
Note: See TracChangeset for help on using the changeset viewer.