Changeset 397 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Oct 21, 2011 12:15:50 PM (10 years ago)
Author:
vondreele
Message:

collect default settings for Sample in one routine
add recalibrate routine for images
azimuths from image integration are now the center angle of each azimuth bin
put in 1/2 pixel offset in image calibration/integration calcs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r396 r397  
    376376    tay = ma.compressed(ma.array(tay.flatten(),mask=tam))
    377377    return zip(tax,tay)
     378   
     379def ImageRecalibrate(self,data):
     380    import copy
     381    import ImageCalibrants as calFile
     382    print 'Image recalibration:'
     383    time0 = time.time()
     384    pixelSize = data['pixelSize']
     385    scalex = 1000./pixelSize[0]
     386    scaley = 1000./pixelSize[1]
     387    pixLimit = data['pixLimit']
     388    cutoff = data['cutoff']
     389    data['rings'] = []
     390    data['ellipses'] = []
     391    if not data['calibrant']:
     392        print 'no calibration material selected'
     393        return True
     394   
     395    skip = data['calibskip']
     396    dmin = data['calibdmin']
     397    Bravais,Cells = calFile.Calibrants[data['calibrant']][:2]
     398    HKL = []
     399    for bravais,cell in zip(Bravais,Cells):
     400        A = G2lat.cell2A(cell)
     401        hkl = G2lat.GenHBravais(dmin,bravais,A)[skip:]
     402        HKL += hkl
     403    HKL = G2lat.sortHKLd(HKL,True,False)
     404    wave = data['wavelength']
     405    cent = data['center']   
     406    dist = data['distance']
     407    cent = data['center']
     408    tilt = data['tilt']
     409    phi = data['rotation']
     410    for H in HKL:
     411        dsp = H[3]
     412        ellipse = GetEllipse(dsp,data)
     413        Ring,delt = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
     414        if Ring:
     415            numZ = len(Ring)
     416            data['rings'].append(np.array(Ring))
     417            data['ellipses'].append(copy.deepcopy(ellipse+('r',)))
     418        else:
     419            continue
     420    rings = np.concatenate((data['rings']),axis=0)
     421    p0 = [dist,cent[0],cent[1],phi,tilt]
     422    result,newWave = FitDetector(rings,p0,wave)
     423    data['distance'] = result[0]
     424    data['center'] = result[1:3]
     425    data['rotation'] = np.mod(result[3],360.0)
     426    data['tilt'] = result[4]
     427    N = len(data['ellipses'])
     428    data['ellipses'] = []           #clear away individual ellipse fits
     429    for H in HKL[:N]:
     430        ellipse = GetEllipse(H[3],data)
     431        data['ellipses'].append(copy.deepcopy(ellipse+('b',)))
     432   
     433    print 'calibration time = ',time.time()-time0
     434    G2plt.PlotImage(self,newImage=True)       
     435    return True
     436   
    378437           
    379438def ImageCalibrate(self,data):
     
    545604    p0 = [dist,cent[0],cent[1],phi,tilt]
    546605    result,newWave = FitDetector(rings,p0,wave)
    547 #    print 'Suggested new wavelength = ',('%.5f')%(newWave),' (not reliable if distance > 2m)'
    548606    data['distance'] = result[0]
    549607    data['center'] = result[1:3]
Note: See TracChangeset for help on using the changeset viewer.