Changeset 239 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Jan 13, 2011 1:34:07 PM (11 years ago)
Author:
vondreele
Message:

add 'any image file' to image file menu
add calibration skip & dmin to image data dictionary
fix to ellipse fitting
fix Pilatus reading - OK for 100K, not sure for 2M
now a image sizexy - 2 items for x & y sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r230 r239  
    491491        image[row] = np.asarray(line)
    492492        row += 1
    493     data = {'pixelSize':(200,200),'wavelength':0.15,'distance':250.0,'center':[204.8,204.8]
     493    data = {'pixelSize':(200,200),'wavelength':0.15,'distance':250.0,'center':[204.8,204.8],'size':[size,size]
    494494    File.close()   
    495495    if imageOnly:
     
    527527                center[1] = float(line.split('=')[1])
    528528            head.append(line)
    529     data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center}
     529    data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center,'size':[size,size]}
    530530    image = []
    531531    row = 0
     
    583583            size = int(items[1])
    584584    pos = 4096
     585    data['size'] = [size,size]
    585586    File.seek(pos)
    586587    line = File.read(8)
     
    629630        finalSize = origSize
    630631    if Ityp == 0:
    631         print finalSize
    632         if finalSize == 1207975936:
    633             finalSize = origSize = 1536
     632        File.seek(62)
     633        S = File.read(32)
     634        if 'PILATUS' in S:
     635            dataType = 0
     636            tifType = 'Pilatus'
     637            if '2M' in S:
     638                sizexy = [1475,1679]
     639            elif '100K' in S:
     640                sizexy = [487,195]
     641            pixy = (172,172)
     642            pos = 4096
     643            if not imageOnly:
     644                print 'Read Pilatus tiff file: ',filename
     645        else:
     646            sizexy = [1536,1536]
    634647            sizeScale = 1
    635648            tifType = 'Gold'
     
    638651            if not imageOnly:
    639652                print 'Read Gold tiff file:',filename
    640         else:
    641             tifType = 'Pilatus'
    642             pixy = (172*sizeScale,172*sizeScale)
    643             pos = 4096
    644             if not imageOnly:
    645                 print 'Read Pilatus tiff file: ',filename
    646653    elif Ityp == 1:
    647654        tifType = 'PE'
     655        sizexy = [finalSize,finalSize]
    648656        pixy = (200*sizeScale,200*sizeScale)
    649657        pos = 8
     
    652660    elif Ityp == 3328:
    653661        tifType = 'MAR'
     662        sizexy = [finalSize,finalSize]
    654663        pixy = (79*sizeScale,79*sizeScale)
    655664        pos = 4096
     
    659668        lines = 'unknown tif type'
    660669        return lines,0,0
    661     image = np.zeros(shape=(finalSize,finalSize),dtype=np.int32)
     670    image = np.zeros(shape=(sizexy[1],sizexy[0]),dtype=np.int32)
    662671    row = 0
    663     while row < finalSize:
     672    while row < sizexy[1]:
    664673        File.seek(pos)
    665         if 'PE' in tifType:
     674        if 'PE' in tifType or 'Pilatus' in tifType:
    666675            if dataType == 5:
    667                 line = ar.array('f',File.read(4*finalSize))
     676                line = ar.array('f',File.read(4*sizexy[0]))
    668677            else:
    669                 line = ar.array('l',File.read(4*finalSize))
    670             pos += 4*finalSize
     678                line = ar.array('L',File.read(4*sizexy[0]))
     679            pos += 4*sizexy[0]
    671680        elif 'MAR' in tifType or 'Gold' in tifType:
    672             line = ar.array('H',File.read(2*finalSize))
    673             pos += 2*finalSize
     681            line = ar.array('H',File.read(2*sizexy[0]))
     682            pos += 2*sizexy[0]
    674683        image[row] = np.asarray(line)
    675684        row += 1
    676     center = [pixy[0]*finalSize/2000,pixy[1]*finalSize/2000]
    677     data = {'pixelSize':pixy,'wavelength':0.10,'distance':100.0,'center':center}
     685    center = [pixy[0]*sizexy[0]/2000,pixy[1]*sizexy[1]/2000]
     686    data = {'pixelSize':pixy,'wavelength':0.10,'distance':100.0,'center':center,'size':sizexy}
    678687    File.close()   
    679688    if imageOnly:
    680689        return image
    681690    else:
    682         return head,data,finalSize,image
     691        return head,data,sizexy[0],image
    683692   
    684693def ProjFileOpen(self):
Note: See TracChangeset for help on using the changeset viewer.