Changeset 35


Ignore:
Timestamp:
Mar 2, 2010 5:56:13 PM (12 years ago)
Author:
vondreel
Message:

resolve conflicts & include test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIcomp.py

    r33 r35  
    77import numpy.linalg as nl
    88import os.path as ospath
    9 import GSASIIgrid as G2gd
    109# determine a binary path pased on the host OS and the python version, path is relative to
    1110# location of this file
     
    13001299    zdis = radii[1]*ttth*cosb/sinb
    13011300    return zdis,cosB
     1301   
     1302def GetEllipse(dsp,wave,dist,cent,tilt,phi):
     1303    radii = [0,0]
     1304    tth = 2.0*asind(wave/(2.*dsp))
     1305    ttth = tand(tth)
     1306    stth = sind(tth)
     1307    ctth = cosd(tth)
     1308    cosb = sind(tilt)
     1309    sinb = math.sqrt(1.-cosb**2)
     1310    sinp = sind(phi)
     1311    cosp = cosd(phi)
     1312    radius = dist*tand(tth)
     1313    radii[1] = dist*stth*ctth*sinb/(sinb**2-stth**2)
     1314    radii[0] = math.sqrt(radii[1]*radius*sinb)
     1315    zdis = radii[1]*ttth*cosb/sinb
     1316    elcent = [cent[0]-zdis*sinp,cent[1]+zdis*cosp]
     1317    return elcent,phi,radii
    13021318       
    13031319def ImageCalibrate(self,data):
     
    13401356        print 'no calibration material selected'
    13411357        return True
     1358       
    13421359    Bravais,cell = calFile.Calibrants[data['calibrant']]
    13431360    A = cell2A(cell)
     
    13831400        Ring = makeRing(ellipse,pixLimit,cutoff,scalex,scaley,self.imScale,self.ImageZ)
    13841401        if Ring:
    1385             numZ = len(ring)
     1402            numZ = len(Ring)
    13861403            data['rings'].append(Ring)
    13871404            elcent,phi,radii = ellipse = FitEllipse(Ring)
     
    14121429                if dist2 > dist1:
    14131430                    data['center'] = cent1[-1]
    1414                     Zsign *= -1.               
     1431                    Zsign *= -1.
     1432#                    Tilt *= Zsign               
    14151433                else:
    14161434                    data['center'] = cent2[-1]
     
    14231441                tiltSum += numZ*Tilt
    14241442            cent = data['center']
    1425             print 'for ring # %i dist %.3f rotate %.2f tilt %.2f Xcent %.3f Ycent %.3f' \
    1426                 %(i,dist,phi,Tilt,cent[0],cent[1])
     1443            print 'for ring # %2i dist %.3f rotate %6.2f tilt %6.2f Xcent %.3f Ycent %.3f Npts %d' \
     1444                %(i,dist,phi,Tilt,cent[0],cent[1],numZ)
    14271445            data['ellipses'].append(copy.deepcopy(ellipse))
    14281446            self.PlotImage()
     
    14381456        data['rotation'] = phiSum/Zsum
    14391457        print data['center'],data['tilt'],data['distance'],data['rotation']
     1458        cent = data['center']
     1459        tilt = data['tilt']
     1460        dist = data['distance']
     1461        wave = data['wavelength']
     1462        phi = data['rotation']
     1463        N = len(data['ellipses'])
     1464        for H in HKL[:N]:
     1465            ellipse = GetEllipse(H[3],wave,dist,cent,tilt,phi)
     1466            data['ellipses'].append(copy.deepcopy(ellipse))
    14401467    else:
    14411468        print 'Only one ring fitted. Check your wavelength.'
     
    14441471       
    14451472    return True
     1473   
     1474   
     1475def test():
     1476    cell = [5,5,5,90,90,90]
     1477    A = cell2A(cell)
     1478    assert ( calc_V(A) == 125. )
     1479   
     1480    print 'test passed'
     1481
     1482print __name__
     1483if __name__ == '__main__':
     1484    test()
     1485   
    14461486       
    1447        
Note: See TracChangeset for help on using the changeset viewer.