Changeset 81


Ignore:
Timestamp:
Jun 3, 2010 1:52:07 PM (12 years ago)
Author:
vondreel
Message:

split out image stuff into GSASIIimage.py

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r78 r81  
    1414import GSASIIpath
    1515import GSASIIIO as G2IO
    16 import GSASIIcomp as G2cmp
    1716import GSASIIgrid as G2gd
    1817import GSASIIplot as G2plt
  • trunk/GSASIIcomp.py

    r80 r81  
    283283    return True,smin,Rwp,runtime,GoOn
    284284   
    285 #GSASII image calculations: ellipse fitting & image integration       
    286        
    287 def makeMat(Angle,Axis):
    288     #Make rotation matrix from Angle in degrees,Axis =0 for rotation about x, =1 for about y, etc.
    289     cs = cosd(Angle)
    290     ss = sind(Angle)
    291     M = np.array(([1.,0.,0.],[0.,cs,-ss],[0.,ss,cs]),dtype=np.float32)
    292     return np.roll(np.roll(M,Axis,axis=0),Axis,axis=1)
    293                    
    294 def FitRing(ring):
    295     Err,parms = FitCircle(ring)
    296     Err /= len(ring)
    297 #    print 'circle error:','%8f'%(Err)
    298     if Err > 20000.:
    299         eparms = FitEllipse(ring)
    300         if eparms:
    301             parms = eparms
    302     return parms
    303        
    304 def FitCircle(ring):
    305     import numpy.linalg as nl
    306    
    307     def makeParmsCircle(B):
    308         cent = [-B[0]/2,-B[1]/2]
    309         phi = 0.
    310         sr1 = sr2 = math.sqrt(cent[0]**2+cent[1]**2-B[2])
    311         return cent,phi,[sr1,sr2]
    312        
    313     ring = np.array(ring)
    314     x = np.asarray(ring.T[0])
    315     y = np.asarray(ring.T[1])
    316    
    317     M = np.array((x,y,np.ones_like(x)))
    318     B = np.array(-(x**2+y**2))
    319     result = nl.lstsq(M.T,B)
    320     return result[1],makeParmsCircle(result[0])
    321        
    322 def FitEllipse(ring):
    323     import numpy.linalg as nl
    324            
    325     def makeParmsEllipse(B):
    326         det = 4.*(1.-B[0]**2)-B[1]**2
    327         if det < 0.:
    328             print 'hyperbola!'
    329             return 0
    330         elif det == 0.:
    331             print 'parabola!'
    332             return 0
    333         cent = [(B[1]*B[3]-2.*(1.-B[0])*B[2])/det, \
    334             (B[1]*B[2]-2.*(1.+B[0])*B[3])/det]
    335         phi = 0.5*atand(0.5*B[1]/B[0])
    336        
    337         a = (1.+B[0])/cosd(2*phi)
    338         b = 2.-a
    339         f = (1.+B[0])*cent[0]**2+(1.-B[0])*cent[1]**2+B[1]*cent[0]*cent[1]-B[4]
    340         if f/a < 0 or f/b < 0:
    341             return 0
    342         sr1 = math.sqrt(f/a)
    343         sr2 = math.sqrt(f/b)
    344         if sr1 > sr2:
    345             sr1,sr2 = sr2,sr1
    346             phi -= 90.
    347             if phi < -90.:
    348                 phi += 180.
    349         return cent,phi,[sr1,sr2]
    350                
    351     ring = np.array(ring)
    352     x = np.asarray(ring.T[0])
    353     y = np.asarray(ring.T[1])
    354     M = np.array((x**2-y**2,x*y,x,y,np.ones_like(x)))
    355     B = np.array(-(x**2+y**2))
    356     result = nl.lstsq(M.T,B)
    357     return makeParmsEllipse(result[0])
    358    
    359 def FitDetector(rings,p0,wave):
    360     from scipy.optimize import leastsq
    361     def ellipseCalc(B,xyd,wave):
    362         x = xyd[0]
    363         y = xyd[1]
    364         dsp = xyd[2]
    365         dist,x0,y0,phi,tilt = B
    366         tth = 2.0*npasind(wave/(2.*dsp))
    367         ttth = nptand(tth)
    368         radius = dist*ttth
    369         stth = npsind(tth)
    370         cosb = npcosd(tilt)
    371         R1 = dist*stth*npcosd(tth)*cosb/(cosb**2-stth**2)
    372         R0 = np.sqrt(R1*radius*cosb)
    373         zdis = R1*ttth*nptand(tilt)
    374         X = x-x0+zdis*npsind(phi)
    375         Y = y-y0-zdis*npcosd(phi)
    376         XR = X*npcosd(phi)-Y*npsind(phi)
    377         YR = X*npsind(phi)+Y*npcosd(phi)
    378         return (XR/R0)**2+(YR/R1)**2-1
    379     result = leastsq(ellipseCalc,p0,args=(rings.T,wave))
    380     return result[0]
    381            
    382 def ImageLocalMax(image,w,Xpix,Ypix):
    383     w2 = w*2
    384     size = len(image)
    385     xpix = int(Xpix)            #get reference corner of pixel chosen
    386     ypix = int(Ypix)
    387     if (w < xpix < size-w) and (w < ypix < size-w) and image[ypix,xpix]:
    388         Z = image[ypix-w:ypix+w,xpix-w:xpix+w]
    389         Zmax = np.argmax(Z)
    390         Zmin = np.argmin(Z)
    391         xpix += Zmax%w2-w
    392         ypix += Zmax/w2-w
    393         return xpix,ypix,np.ravel(Z)[Zmax],np.ravel(Z)[Zmin]
    394     else:
    395         return 0,0,0,0
    396    
    397 def makeRing(dsp,ellipse,pix,reject,scalex,scaley,image):
    398     cent,phi,radii = ellipse
    399     cphi = cosd(phi)
    400     sphi = sind(phi)
    401     ring = []
    402     for a in range(-180,180,2):
    403         x = radii[0]*cosd(a)
    404         y = radii[1]*sind(a)
    405         X = (cphi*x-sphi*y+cent[0])*scalex      #convert mm to pixels
    406         Y = (sphi*x+cphi*y+cent[1])*scaley
    407         X,Y,I,J = ImageLocalMax(image,pix,X,Y)     
    408         if I and J and I/J > reject:
    409             X += .5                             #set to center of pixel
    410             Y += .5
    411             X /= scalex                         #convert to mm
    412             Y /= scaley
    413             ring.append([X,Y,dsp])
    414     if len(ring) < 45:             #want more than 1/4 of a circle
    415         return []
    416     return ring
    417    
    418 def makeIdealRing(ellipse):
    419     cent,phi,radii = ellipse
    420     cphi = cosd(phi)
    421     sphi = sind(phi)
    422     ring = []
    423     for a in range(0,360,2):
    424         x = radii[0]*cosd(a)
    425         y = radii[1]*sind(a)
    426         X = (cphi*x-sphi*y+cent[0])
    427         Y = (sphi*x+cphi*y+cent[1])
    428         ring.append([X,Y])
    429     return ring
    430    
    431 def calcDist(radii,tth):
    432     stth = sind(tth)
    433     ctth = cosd(tth)
    434     ttth = tand(tth)
    435     return math.sqrt(radii[0]**4/(ttth**2*((radii[0]*ctth)**2+(radii[1]*stth)**2)))
    436    
    437 def calcZdisCosB(radius,tth,radii):
    438     cosB = sinb = radii[0]**2/(radius*radii[1])
    439     if cosB > 1.:
    440         return 0.,1.
    441     else:
    442         cosb = math.sqrt(1.-sinb**2)
    443         ttth = tand(tth)
    444         zdis = radii[1]*ttth*cosb/sinb
    445         return zdis,cosB
    446    
    447 def GetEllipse(dsp,data):
    448     dist = data['distance']
    449     cent = data['center']
    450     tilt = data['tilt']
    451     phi = data['rotation']
    452     radii = [0,0]
    453     tth = 2.0*asind(data['wavelength']/(2.*dsp))
    454     ttth = tand(tth)
    455     stth = sind(tth)
    456     ctth = cosd(tth)
    457     cosb = cosd(tilt)
    458     radius = dist*ttth
    459     radii[1] = dist*stth*ctth*cosb/(cosb**2-stth**2)
    460     if radii[1] > 0:
    461         radii[0] = math.sqrt(radii[1]*radius*cosb)
    462         zdis = radii[1]*ttth*tand(tilt)
    463         elcent = [cent[0]-zdis*sind(phi),cent[1]+zdis*cosd(phi)]
    464         return elcent,phi,radii
    465     else:
    466         return False
    467        
    468 def GetDetectorXY(dsp,azm,data):
    469     from scipy.optimize import fsolve
    470     def func(xy,*args):
    471        azm,phi,R0,R1,A,B = args
    472        cp = cosd(phi)
    473        sp = sind(phi)
    474        x,y = xy
    475        out = []
    476        out.append(y-x*tand(azm))
    477        out.append(R0**2*((x+A)*sp-(y+B)*cp)**2+R1**2*((x+A)*cp+(y+B)*sp)**2-(R0*R1)**2)
    478        return out
    479     elcent,phi,radii = GetEllipse(dsp,data)
    480     cent = data['center']
    481     tilt = data['tilt']
    482     phi = data['rotation']
    483     wave = data['wavelength']
    484     dist = data['distance']
    485     tth = 2.0*asind(wave/(2.*dsp))
    486     ttth = tand(tth)
    487     radius = dist*ttth
    488     stth = sind(tth)
    489     cosb = cosd(tilt)
    490     R1 = dist*stth*cosd(tth)*cosb/(cosb**2-stth**2)
    491     R0 = math.sqrt(R1*radius*cosb)
    492     zdis = R1*ttth*tand(tilt)
    493     A = zdis*sind(phi)
    494     B = -zdis*cosd(phi)
    495     xy0 = [radius*cosd(azm),radius*sind(azm)]
    496     xy = fsolve(func,xy0,args=(azm,phi,R0,R1,A,B))+cent
    497     return xy
    498                    
    499 def GetTthAzmDsp(x,y,data):
    500     wave = data['wavelength']
    501     dist = data['distance']
    502     cent = data['center']
    503     tilt = data['tilt']
    504     phi = data['rotation']
    505     dx = np.array(x-cent[0],dtype=np.float32)
    506     dy = np.array(y-cent[1],dtype=np.float32)
    507     X = np.array(([dx,dy,np.zeros_like(dx)]),dtype=np.float32).T
    508     X = np.dot(X,makeMat(phi,2))
    509     Z = np.dot(X,makeMat(tilt,0)).T[2]
    510     tth = npatand(np.sqrt(dx**2+dy**2-Z**2)/(dist-Z))
    511     dsp = wave/(2.*npsind(tth/2.))
    512     azm = npatan2d(dy,dx)
    513     return tth,azm,dsp
    514    
    515 def GetTth(x,y,data):
    516     return GetTthAzmDsp(x,y,data)[0]
    517    
    518 def GetTthAzm(x,y,data):
    519     return GetTthAzmDsp(x,y,data)[0:2]
    520    
    521 def GetDsp(x,y,data):
    522     return GetTthAzmDsp(x,y,data)[2]
    523        
    524 def ImageCompress(image,scale):
    525     if scale == 1:
    526         return image
    527     else:
    528         return image[::scale,::scale]
    529        
    530 def ImageCalibrate(self,data):
    531     import copy
    532     import ImageCalibrants as calFile
    533     print 'image calibrate'
    534     ring = data['ring']
    535     pixelSize = data['pixelSize']
    536     scalex = 1000./pixelSize[0]
    537     scaley = 1000./pixelSize[1]
    538     cutoff = data['cutoff']
    539     if len(ring) < 5:
    540         print 'not enough inner ring points for ellipse'
    541         return False
    542        
    543     #fit start points on inner ring
    544     data['ellipses'] = []
    545     outE = FitRing(ring)
    546     if outE:
    547         print 'start ellipse:',outE
    548         ellipse = outE
    549     else:
    550         return False
    551        
    552     #setup 180 points on that ring for "good" fit
    553     Ring = makeRing(1.0,ellipse,20,cutoff,scalex,scaley,self.ImageZ)
    554     if Ring:
    555         ellipse = FitRing(Ring)
    556         Ring = makeRing(1.0,ellipse,20,cutoff,scalex,scaley,self.ImageZ)    #do again
    557         ellipse = FitRing(Ring)
    558     else:
    559         print '1st ring not sufficiently complete to proceed'
    560         return False
    561     print 'inner ring:',ellipse
    562     data['center'] = copy.copy(ellipse[0])           #not right!! (but useful for now)
    563     data['ellipses'].append(ellipse[:]+('r',))
    564     G2plt.PlotImage(self)
    565    
    566     #setup for calibration
    567     data['rings'] = []
    568     data['ellipses'] = []
    569     if not data['calibrant']:
    570         print 'no calibration material selected'
    571         return True
    572        
    573     Bravais,cell = calFile.Calibrants[data['calibrant']]
    574     A = G2lat.cell2A(cell)
    575     wave = data['wavelength']
    576     cent = data['center']
    577     pixLimit = data['pixLimit']
    578     elcent,phi,radii = ellipse
    579     HKL = G2lat.GenHBravais(0.5,Bravais,A)
    580     dsp = HKL[0][3]
    581     tth = 2.0*asind(wave/(2.*dsp))
    582     ttth = tand(tth)
    583     data['distance'] = dist = calcDist(radii,tth)
    584     radius = dist*tand(tth)
    585     zdis,cosB = calcZdisCosB(radius,tth,radii)
    586     cent1 = []
    587     cent2 = []
    588     xSum = 0
    589     ySum = 0
    590     zxSum = 0
    591     zySum = 0
    592     phiSum = 0
    593     tiltSum = 0
    594     distSum = 0
    595     Zsum = 0
    596     for i,H in enumerate(HKL):
    597         dsp = H[3]
    598         tth = 2.0*asind(0.5*wave/dsp)
    599         stth = sind(tth)
    600         ctth = cosd(tth)
    601         ttth = tand(tth)
    602         radius = dist*ttth
    603         elcent,phi,radii = ellipse
    604         radii[1] = dist*stth*ctth*cosB/(cosB**2-stth**2)
    605         radii[0] = math.sqrt(radii[1]*radius*cosB)
    606         zdis,cosB = calcZdisCosB(radius,tth,radii)
    607         zsinp = zdis*sind(phi)
    608         zcosp = zdis*cosd(phi)
    609         cent = data['center']
    610         elcent = [cent[0]+zsinp,cent[1]-zcosp]
    611         ratio = radii[1]/radii[0]
    612         Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)
    613         if Ring:
    614             numZ = len(Ring)
    615             data['rings'].append(np.array(Ring))
    616             ellipse = FitRing(Ring)
    617             elcent,phi,radii = ellipse               
    618             if abs(phi) > 45. and phi < 0.:
    619                 phi += 180.
    620             dist = calcDist(radii,tth)
    621             distR = 1.-dist/data['distance']
    622             if distR > 0.001:
    623                 print 'Wavelength too large?'
    624             elif distR < -0.001:
    625                 print 'Wavelength too small?'
    626             else:
    627                 if abs((radii[1]/radii[0]-ratio)/ratio) > 0.01:
    628                     print 'Bad fit for ring # %i. Try reducing Pixel search range'%(i)
    629                     return False
    630             zdis,cosB = calcZdisCosB(radius,tth,radii)
    631             Tilt = acosd(cosB)          # 0 <= tilt <= 90
    632             zsinp = zdis*sind(ellipse[1])
    633             zcosp = zdis*cosd(ellipse[1])
    634             cent1.append(np.array([elcent[0]+zsinp,elcent[1]-zcosp]))
    635             cent2.append(np.array([elcent[0]-zsinp,elcent[1]+zcosp]))
    636             if i:
    637                 d1 = cent1[-1]-cent1[-2]        #get shift of 2 possible center solutions
    638                 d2 = cent2[-1]-cent2[-2]
    639                 if np.dot(d2,d2) > np.dot(d1,d1):  #right solution is the larger shift
    640                     data['center'] = cent1[-1]
    641                 else:
    642                     data['center'] = cent2[-1]
    643                 Zsum += numZ
    644                 phiSum += numZ*phi
    645                 distSum += numZ*dist
    646                 xSum += numZ*data['center'][0]
    647                 ySum += numZ*data['center'][1]
    648                 tiltSum += numZ*abs(Tilt)
    649             cent = data['center']
    650             print ('for ring # %2i dist %.3f rotate %6.2f tilt %6.2f Xcent %.3f Ycent %.3f Npts %d'
    651                 %(i,dist,phi,Tilt,cent[0],cent[1],numZ))
    652             data['ellipses'].append(copy.deepcopy(ellipse+('r',)))
    653             G2plt.PlotImage(self)
    654         else:
    655             break
    656     fullSize = len(self.ImageZ)/scalex
    657     if 2*radii[1] < .9*fullSize:
    658         print 'Are all usable rings (>25% visible) used? Try reducing Min ring I/Ib'
    659     if not Zsum:
    660         print 'Only one ring fitted. Check your wavelength.'
    661         return False
    662     cent = data['center'] = [xSum/Zsum,ySum/Zsum]
    663     wave = data['wavelength']
    664     dist = data['distance'] = distSum/Zsum
    665    
    666     #possible error if no. of rings < 3! Might need trap here
    667     d1 = cent1[-1]-cent1[1]             #compare last ring to 2nd ring
    668     d2 = cent2[-1]-cent2[1]
    669     Zsign = 1
    670     len1 = math.sqrt(np.dot(d1,d1))
    671     len2 = math.sqrt(np.dot(d2,d2))
    672     t1 = d1/len1
    673     t2 = d2/len2
    674     if len2 > len1:
    675         if -135. < atan2d(t2[1],t2[0]) < 45.:
    676             Zsign = -1
    677     else:
    678         if -135. < atan2d(t1[1],t1[0]) < 45.:
    679             Zsign = -1
    680    
    681     tilt = data['tilt'] = Zsign*tiltSum/Zsum
    682     phi = data['rotation'] = phiSum/Zsum
    683     rings = np.concatenate((data['rings']),axis=0)
    684     p0 = [dist,cent[0],cent[1],phi,tilt]
    685     result = FitDetector(rings,p0,wave)
    686     data['distance'] = result[0]
    687     data['center'] = result[1:3]
    688     data['rotation'] = np.mod(result[3],360.0)
    689     data['tilt'] = result[4]
    690     N = len(data['ellipses'])
    691     data['ellipses'] = []           #clear away individual ellipse fits
    692     for H in HKL[:N]:
    693         ellipse = GetEllipse(H[3],data)
    694         data['ellipses'].append(copy.deepcopy(ellipse+('b',)))
    695     G2plt.PlotImage(self)       
    696     return True
    697    
    698 def Make2ThetaAzimuthMap(data,imageN):
    699     #transforms 2D image from x,y space to 2-theta,azimuth space based on detector orientation
    700     pixelSize = data['pixelSize']
    701     scalex = pixelSize[0]/1000.
    702     scaley = pixelSize[1]/1000.
    703     tax,tay = np.mgrid[0.5:imageN+.5,0.5:imageN+.5]         #bin centers not corners
    704     tax = np.asfarray(tax*scalex,dtype=np.float32)
    705     tay = np.asfarray(tay*scaley,dtype=np.float32)
    706     return GetTthAzm(tay,tax,data)           #2-theta & azimuth arrays
    707 
    708 def Fill2ThetaAzimuthMap(data,TA,image):
    709     import numpy.ma as ma
    710     LUtth = data['IOtth']
    711     if data['fullIntegrate']:
    712         LRazm = [-180,180]
    713     else:
    714         LRazm = data['LRazimuth']
    715     imageN = len(image)
    716     TA = np.reshape(TA,(2,imageN,imageN))
    717     TA = np.dstack((ma.getdata(TA[1]),ma.getdata(TA[0])))    #azimuth, 2-theta
    718     tax,tay = np.dsplit(TA,2)    #azimuth, 2-theta
    719     tax = ma.masked_outside(tax.flatten(),LRazm[0],LRazm[1])
    720     tay = ma.masked_outside(tay.flatten(),LUtth[0],LUtth[1])
    721     tam = ma.getmask(tax)+ma.getmask(tay)
    722     taz = ma.masked_where(tam,image.flatten())
    723     return tax,tay,taz,tam
    724    
    725 def Bin2ThetaAzimuthMap(data,tax,tay,taz):
    726     import numpy.ma as ma
    727     LUtth = data['IOtth']
    728     if data['fullIntegrate']:
    729         LRazm = [-180,180]
    730     else:
    731         LRazm = data['LRazimuth']
    732     numAzms = data['outAzimuths']
    733     numChans = data['outChannels']
    734     NST = np.histogram2d(tax,tay,normed=False,bins=(numAzms,numChans),range=[LRazm,LUtth])
    735     HST = np.histogram2d(tax,tay,normed=False,bins=(numAzms,numChans),range=[LRazm,LUtth],weights=taz)
    736     return NST,HST
    737 
    738 def ImageIntegrate(self,data):
    739     dlg = wx.ProgressDialog("Elapsed time","2D image integration",5,
    740         style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE)
    741     try:
    742         print 'Begin image integration'
    743         print 'Create 2-theta,azimuth map'
    744         t0 = time.time()
    745         dlg.Update(0)
    746         imageN = len(self.ImageZ)
    747         TA = Make2ThetaAzimuthMap(data,imageN)           #2-theta & azimuth arrays
    748         dlg.Update(1)
    749         print 'Fill map with 2-theta/azimuth values'
    750         tax,tay,taz,tam = Fill2ThetaAzimuthMap(data,TA,self.ImageZ)
    751         del TA
    752         dlg.Update(2)
    753         print 'Bin image by 2-theta/azimuth intervals'
    754         NST,HST = Bin2ThetaAzimuthMap(data,tax,tay,taz)
    755         del tax,tay,taz
    756         dlg.Update(3)
    757         print 'Form normalized 1D pattern(s)'
    758         self.Integrate = [HST[0]/NST[0],HST[1],HST[2]]
    759         del NST,HST
    760         dlg.Update(4)
    761         t1 = time.time()
    762         print 'Integration complete'
    763         print "Elapsed time:","%8.3f"%(t1-t0), "s"
    764     finally:
    765         dlg.Destroy()
    766285           
    767286       
  • trunk/GSASIIgrid.py

    r79 r81  
    1010import GSASIIlattice as G2lat
    1111import GSASIIindex as G2indx
     12import GSASIIimage as G2img
    1213import GSASIIspc as G2spc
    1314import GSASIIElem as G2elem
     
    13071308        self.ifGetRing = False
    13081309       
    1309         if G2cmp.ImageCalibrate(self,data):
     1310        if G2img.ImageCalibrate(self,data):
    13101311            Status.SetStatusText('Calibration successful')
    13111312            cent = data['center']
     
    13191320                   
    13201321    def OnIntegrate(event):
    1321         G2cmp.ImageIntegrate(self,data)
     1322        G2img.ImageIntegrate(self,data)
    13221323        G2plt.PlotIntegration(self,newPlot=True)
    13231324        self.dataFrame.ImageEdit.Enable(id=wxID_SAVEINTG,enable=True)
     
    13501351                            Id = GetPatternTreeItemId(self,id, 'Image Controls')
    13511352                            Data = self.PatternTree.GetItemPyData(Id)
    1352                             G2cmp.ImageIntegrate(self,Data)
     1353                            G2img.ImageIntegrate(self,Data)
    13531354                            G2plt.PlotIntegration(self,newPlot=True)
    13541355                            self.dataFrame.ImageEdit.Enable(id=wxID_SAVEINTG,enable=True)
  • trunk/GSASIIplot.py

    r77 r81  
    88import GSASIIpath
    99import GSASIIgrid as G2gd
    10 import GSASIIcomp as G2cmp
     10import GSASIIimage as G2img
    1111import GSASIIIO as G2IO
    1212from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
     
    585585                        Page.canvas.SetToolTipString('%6d deg'%(ang))
    586586                    elif 'line1' in  str(item) or 'line2' in str(item):
    587                         tth = G2cmp.GetTth(event.xdata,event.ydata,Data)
     587                        tth = G2img.GetTth(event.xdata,event.ydata,Data)
    588588                        Page.canvas.SetToolTipString('%8.3fdeg'%(tth))                           
    589589            else:
     
    594594                if (0 <= xpix <= size) and (0 <= ypix <= size):
    595595                    Page.canvas.SetToolTipString('%6d'%(self.ImageZ[ypix][xpix]))
    596                 tth,azm,dsp = G2cmp.GetTthAzmDsp(xpos,ypos,Data)
     596                tth,azm,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
    597597                Q = 2.*math.pi/dsp
    598598                self.G2plotNB.status.SetFields(\
     
    635635                    Xpix = Xpos*scalex
    636636                    Ypix = Ypos*scaley
    637                     xpos,ypos,I,J = G2cmp.ImageLocalMax(self.ImageZ,20,Xpix,Ypix)
     637                    xpos,ypos,I,J = G2img.ImageLocalMax(self.ImageZ,20,Xpix,Ypix)
    638638                    if I and J:
    639639                        xpos += .5                              #shift to pixel center
     
    655655                            rings.remove(ring)                                                                       
    656656                else:
    657                     tth,azm,dsp = G2cmp.GetTthAzmDsp(xpos,ypos,Data)
     657                    tth,azm,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
    658658                    if 'Line2D' in str(self.itemPicked):
    659659                        if 'line1' in str(self.itemPicked):
     
    669669                            Data['LRazimuth'][1] += 360
    670670                        if  Data['IOtth'][0] > Data['IOtth'][1]:
    671                             Data['IOtth'] = G2cmp.SwapXY(Data['IOtth'][0],Data['IOtth'][1])
     671                            Data['IOtth'][0],Data['IOtth'][1] = Data['IOtth'][1],Data['IOtth'][0]
    672672                           
    673673                        self.InnerTth.SetValue("%8.2f" % (Data['IOtth'][0]))
     
    726726    Plot.set_ylabel('Image y-axis, mm',fontsize=12)
    727727    #need "applyMask" routine here
    728     A = G2cmp.ImageCompress(self.ImageZ,imScale)
     728    A = G2img.ImageCompress(self.ImageZ,imScale)
    729729    Img = Plot.imshow(A,aspect='equal',cmap=acolor,
    730730        interpolation='nearest',vmin=Imin,vmax=Imax,extent=[0,Xmax,Xmax,0])
     
    736736        wave = Data['wavelength']
    737737        dspI = wave/(2.0*sind(IOtth[0]/2.0))
    738         ellI = G2cmp.GetEllipse(dspI,Data)           #=False if dsp didn't yield an ellipse (ugh! a parabola or a hyperbola)
     738        ellI = G2img.GetEllipse(dspI,Data)           #=False if dsp didn't yield an ellipse (ugh! a parabola or a hyperbola)
    739739        dspO = wave/(2.0*sind(IOtth[1]/2.0))
    740         ellO = G2cmp.GetEllipse(dspO,Data)           #Ditto & more likely for outer ellipse
     740        ellO = G2img.GetEllipse(dspO,Data)           #Ditto & more likely for outer ellipse
    741741        if Data['fullIntegrate']:
    742742            Azm = np.array(range(0,361))
     
    746746            xyI = []
    747747            for azm in Azm:
    748                 xyI.append(G2cmp.GetDetectorXY(dspI,azm,Data))
     748                xyI.append(G2img.GetDetectorXY(dspI,azm,Data))
    749749            xyI = np.array(xyI)
    750750            arcxI,arcyI = xyI.T
     
    753753            xyO = []
    754754            for azm in Azm:
    755                 xyO.append(G2cmp.GetDetectorXY(dspO,azm,Data))
     755                xyO.append(G2img.GetDetectorXY(dspO,azm,Data))
    756756            xyO = np.array(xyO)
    757757            arcxO,arcyO = xyO.T
     
    828828        rings = np.concatenate((Data['rings']),axis=0)
    829829        for xring,yring,dsp in rings:
    830             x,y = G2cmp.GetTthAzm(xring,yring,Data)
     830            x,y = G2img.GetTthAzm(xring,yring,Data)
    831831            Plot.plot(x,y,'r+')
    832832    if Data['ellipses']:           
    833833        for ellipse in Data['ellipses']:
    834             ring = np.array(G2cmp.makeIdealRing(ellipse[:3])) #skip color
     834            ring = np.array(G2img.makeIdealRing(ellipse[:3])) #skip color
    835835            x,y = np.hsplit(ring,2)
    836             tth,azm = G2cmp.GetTthAzm(x,y,Data)
     836            tth,azm = G2img.GetTthAzm(x,y,Data)
    837837            Plot.plot(tth,azm,'b,')
    838838    if not newPlot:
     
    901901        rings = np.concatenate((Data['rings']),axis=0)
    902902        for xring,yring,dsp in rings:
    903             x,y = G2cmp.GetTthAzm(xring,yring,Data)
     903            x,y = G2img.GetTthAzm(xring,yring,Data)
    904904            Plot.plot(y,x,'r+')           
    905905    if Data['ellipses']:           
    906906        for ellipse in Data['ellipses']:
    907             ring = np.array(G2cmp.makeIdealRing(ellipse[:3])) #skip color
     907            ring = np.array(G2img.makeIdealRing(ellipse[:3])) #skip color
    908908            x,y = np.hsplit(ring,2)
    909             tth,azm = G2cmp.GetTthAzm(x,y,Data)
     909            tth,azm = G2img.GetTthAzm(x,y,Data)
    910910            Plot.plot(azm,tth,'b,')
    911911    if not newPlot:
Note: See TracChangeset for help on using the changeset viewer.