Changeset 2015 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Oct 17, 2015 4:32:42 PM (6 years ago)
Author:
toby
Message:

redo image read to avoid reloads; prevent open of Edit image parms on reread; fix multilevel TIF read error; cleanup self in GSASIIimage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r1834 r2015  
    501501    return tam.T
    502502   
    503 def ImageRecalibrate(self,data,masks):
     503def ImageRecalibrate(G2frame,data,masks):
    504504    'Needs a doc string'
    505505    import ImageCalibrants as calFile
     
    536536    wave = data['wavelength']
    537537    frame = masks['Frames']
    538     tam = ma.make_mask_none(self.ImageZ.shape)
     538    tam = ma.make_mask_none(G2frame.ImageZ.shape)
    539539    if frame:
    540540        tam = ma.mask_or(tam,MakeFrameMask(data,frame))
     
    547547            break
    548548        ellipse = GetEllipse(dsp,data)
    549         Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,ma.array(self.ImageZ,mask=tam))
     549        Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,ma.array(G2frame.ImageZ,mask=tam))
    550550        if Ring:
    551551            if iH >= skip:
     
    574574        data['ellipses'].append(copy.deepcopy(ellipse+('b',)))   
    575575    print 'calibration time = ',time.time()-time0
    576     G2plt.PlotImage(self,newImage=True)       
     576    G2plt.PlotImage(G2frame,newImage=True)       
    577577    return True
    578578           
    579 def ImageCalibrate(self,data):
     579def ImageCalibrate(G2frame,data):
    580580    'Needs a doc string'
    581581    import copy
     
    611611    #setup 360 points on that ring for "good" fit
    612612    data['ellipses'].append(ellipse[:]+('g',))
    613     Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
     613    Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,G2frame.ImageZ)
    614614    if Ring:
    615615        ellipse = FitEllipse(Ring)
    616         Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)    #do again
     616        Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,G2frame.ImageZ)    #do again
    617617        ellipse = FitEllipse(Ring)
    618618    else:
     
    624624    data['ellipses'].append(ellipse[:]+('r',))
    625625    data['rings'].append(np.array(Ring))
    626     G2plt.PlotImage(self,newImage=True)
     626    G2plt.PlotImage(G2frame,newImage=True)
    627627   
    628628#setup for calibration
     
    658658        tth = npatan2d(radii[0],dist)
    659659        data['wavelength'] = wave =  2.0*dsp*sind(tth/2.0)
    660     Ring0 = makeRing(dsp,ellipse,3,cutoff,scalex,scaley,self.ImageZ)
     660    Ring0 = makeRing(dsp,ellipse,3,cutoff,scalex,scaley,G2frame.ImageZ)
    661661    ttth = nptand(tth)
    662662    stth = npsind(tth)
     
    694694            ellipsep = GetEllipse2(tth,0.,dist,centp,tilt,phi)
    695695            print fmt%('plus ellipse :',ellipsep[0][0],ellipsep[0][1],ellipsep[1],ellipsep[2][0],ellipsep[2][1])
    696             Ringp = makeRing(dsp,ellipsep,3,cutoff,scalex,scaley,self.ImageZ)
     696            Ringp = makeRing(dsp,ellipsep,3,cutoff,scalex,scaley,G2frame.ImageZ)
    697697            parmDict = {'dist':dist,'det-X':centp[0],'det-Y':centp[1],
    698698                'tilt':tilt,'phi':phi,'wave':wave,'dep':0.0}       
     
    708708            ellipsem = GetEllipse2(tth,0.,dist,centm,-tilt,phi)
    709709            print fmt%('minus ellipse:',ellipsem[0][0],ellipsem[0][1],ellipsem[1],ellipsem[2][0],ellipsem[2][1])
    710             Ringm = makeRing(dsp,ellipsem,3,cutoff,scalex,scaley,self.ImageZ)
     710            Ringm = makeRing(dsp,ellipsem,3,cutoff,scalex,scaley,G2frame.ImageZ)
    711711            if len(Ringm) > 10:
    712712                parmDict['tilt'] *= -1
     
    732732        data['ellipses'].append(ellipsem[:]+('r',))
    733733        data['rings'].append(np.array(Ringm))
    734         G2plt.PlotImage(self,newImage=True)
     734        G2plt.PlotImage(G2frame,newImage=True)
    735735    parmDict = {'dist':data['distance'],'det-X':data['center'][0],'det-Y':data['center'][1],
    736736        'tilt':data['tilt'],'phi':data['rotation'],'wave':data['wavelength'],'dep':data['DetDepth']}
     
    748748        data['ellipses'].append(copy.deepcopy(ellipse+('g',)))
    749749        if debug:   print fmt%('predicted ellipse:',elcent[0],elcent[1],phi,radii[0],radii[1])
    750         Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
     750        Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,G2frame.ImageZ)
    751751        if Ring:
    752752            data['rings'].append(np.array(Ring))
     
    763763                if debug:   print fmt2%('fitted ellipse:   ',elcent[0],elcent[1],phi,radii[0],radii[1],chisq,len(rings))
    764764            data['ellipses'].append(copy.deepcopy(ellipse+('r',)))
    765 #            G2plt.PlotImage(self,newImage=True)
     765#            G2plt.PlotImage(G2frame,newImage=True)
    766766        else:
    767767            if debug:   print 'insufficient number of points in this ellipse to fit'
    768768#            break
    769     G2plt.PlotImage(self,newImage=True)
    770     fullSize = len(self.ImageZ)/scalex
     769    G2plt.PlotImage(G2frame,newImage=True)
     770    fullSize = len(G2frame.ImageZ)/scalex
    771771    if 2*radii[1] < .9*fullSize:
    772772        print 'Are all usable rings (>25% visible) used? Try reducing Min ring I/Ib'
     
    784784        data['ellipses'].append(copy.deepcopy(ellipse+('b',)))
    785785    print 'calibration time = ',time.time()-time0
    786     G2plt.PlotImage(self,newImage=True)       
     786    G2plt.PlotImage(G2frame,newImage=True)       
    787787    return True
    788788   
Note: See TracChangeset for help on using the changeset viewer.