Changeset 1949 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Aug 3, 2015 10:21:47 AM (6 years ago)
Author:
vondreele
Message:

add image read for Rigaku R-Axis IV files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r1925 r1949  
    178178    if not os.path.exists(imagefile):
    179179        dlg = wx.FileDialog(G2frame, 'Previous image file not found; open here', '.', '',\
    180         'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor)\
    181         |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor|\
     180        'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl)\
     181        |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor;*.stl|\
    182182        European detector file (*.edf)|*.edf|\
    183183        Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\
     
    185185        GE Image (*.ge*;*.avg;*.sum;*.cor)|*.ge*;*.avg;*.sum;*.cor|\
    186186        ADSC Image (*.img)|*.img|\
     187        Rigaku-Axis4 (*.stl)|*.stl|\
    187188        All files (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR)
    188189        try:
     
    311312        if not imageOnly:
    312313            EditImageParms(G2frame,Data,Comments,Image,imagefile)
     314    elif ext == '.stl':
     315        Comments,Data,Npix,Image = GetRigaku(imagefile)
     316#        if not imageOnly:
     317#            EditImageParms(G2frame,Data,Comments,Image,imagefile)
    313318    else:
    314319        print 'Extension for file '+imagefile+' not recognized'
     
    369374        elif 'Size' in line:
    370375            imSize = int(fields[2])
    371         elif 'DataType' in lines:
    372             dType = fields[2]
     376#        elif 'DataType' in lines:
     377#            dType = fields[2]
    373378        elif 'pixel_size_x' in line:
    374379            pixSize[0] = float(fields[2])
     
    402407    else:
    403408        return head,data,Npix,image
     409       
     410def GetRigaku(filename,imageOnly=False):
     411    'Read Rigaku R-Axis IV image file'
     412    import struct as st
     413    import array as ar
     414    if not imageOnly:
     415        print 'Read Rigaku R-Axis IV file: ',filename   
     416    File = open(filename,'rb')
     417    fileSize = os.stat(filename).st_size
     418    Npix = (fileSize-6000)/2
     419    Head = File.read(6000)
     420    head = ['Rigaku R-Axis IV detector data',]
     421    image = np.array(ar.array('H',File.read(fileSize-6000)),dtype=np.int32)
     422    print fileSize,image.shape
     423    print head
     424    if Npix == 9000000:
     425        sizexy = [3000,3000]
     426        pixSize = [100.,100.]       
     427    elif Npix == 2250000:
     428        sizexy = [1500,1500]
     429        pixSize = [200.,200.]
     430    else:
     431        sizexy = [6000,6000]
     432        pixSize = [50.,50.]
     433    image = np.reshape(image,(sizexy[1],sizexy[0]))       
     434    data = {'pixelSize':pixSize,'wavelength':1.5428,'distance':250.0,'center':[150.,150.],'size':sizexy} 
     435    File.close()   
     436    if imageOnly:
     437        return image
     438    else:
     439        return head,data,Npix,image
     440   
    404441       
    405442def GetGEsumData(filename,imageOnly=False):
Note: See TracChangeset for help on using the changeset viewer.