Changeset 85 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Jun 11, 2010 1:37:21 PM (12 years ago)
Author:
vondreel
Message:

threshold masks operational
add index peak list load/reload menu & remove delete key method
plotting of threshold masks
remove "U" in image open command; implement reading of MAR CCD tif images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r75 r85  
    544544    import struct as st
    545545    import array as ar
    546     if not imageOnly:
    547         print 'Read APS PE-detector tiff file: ',filename
    548     File = open(filename,'Ur')
     546    File = open(filename,'rb')
    549547    dataType = 5
    550548    try:
     
    561559    tag = File.read(3)
    562560    if tag != 'II*':
    563         lines = ['not a APS PE-detector tiff file',]
     561        lines = ['not a detector tiff file',]
    564562        return lines,0,0
    565     size = st.unpack('<i',File.read(4))[0]
     563    size,Ityp = st.unpack('<ii',File.read(8))
     564    if Ityp == 0:
     565        tifType = 'Pilatus'
     566        pixy = (172,172)
     567        pos = 4096
     568        if not imageOnly:
     569            print 'Read Pilatus tiff file: ',filename
     570    elif Ityp == 1:
     571        tifType = 'PE'
     572        pixy = (200,200)
     573        pos = 8
     574        if not imageOnly:
     575            print 'Read APS PE-detector tiff file: ',filename
     576    elif Ityp == 3328:
     577        tifType = 'MAR'
     578        pixy = (79,79)
     579        pos = 4096
     580        if not imageOnly:
     581            print 'Read MAR CCD tiff file: ',filename
     582    else:
     583        lines = 'unknown tif type'
     584        return lines,0,0
    566585    image = np.zeros(shape=(size,size),dtype=np.int32)
    567586    row = 0
    568     pos = 8
    569587    while row < size:
    570588        File.seek(pos)
    571         if dataType == 5:
    572             line = ar.array('f',File.read(4*size))
    573         else:
    574             line = ar.array('l',File.read(4*size))
     589        if 'PE' in tifType:
     590            if dataType == 5:
     591                line = ar.array('f',File.read(4*size))
     592            else:
     593                line = ar.array('l',File.read(4*size))
     594            pos += 4*size
     595        elif 'MAR' in tifType:
     596            line = ar.array('H',File.read(2*size))
     597            pos += 2*size
    575598        image[row] = np.asarray(line)
    576599        row += 1
    577         pos += 4*size
    578     data = {'pixelSize':(200,200),'wavelength':0.10,'distance':100.0,'center':[204.8,204.8]}
     600    data = {'pixelSize':pixy,'wavelength':0.10,'distance':100.0,'center':[204.8,204.8]}
    579601    File.close()   
    580602    if imageOnly:
Note: See TracChangeset for help on using the changeset viewer.