Ignore:
Timestamp:
May 27, 2016 11:25:21 AM (6 years ago)
Author:
vondreele
Message:

implement creation of summed file from multi-frame ge image files; creates a G2img file which is put on tree in place of multi frame file. Subsequent accesses get teg G2img file.
Insert skipPageChange = True to prevent plot tab change causing tree change from Strain plots & Image plots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2img_GE.py

    r2296 r2297  
    6060        if imagenum is None: imagenum = 1
    6161        self.Comments,self.Data,self.Npix,self.Image,more = \
    62             GetGEsumData(filename,imagenum=imagenum)
     62            GetGEsumData(self,filename,imagenum=imagenum)
    6363        if self.Npix == 0 or not self.Comments:
    6464            return False
     
    8282            extensionlist=('.ge1','.ge2','.ge3','.ge4'),
    8383            strictExtension=True,
    84             formatName = 'GE multi-image summed',
     84            formatName = 'sum GE multi-image',
    8585            longFormatName = 'sum of GE multi-image file'
    8686            )
     
    104104        if imagenum is None: imagenum = 1
    105105        self.Comments,self.Data,self.Npix,self.Image,more = \
    106             GetGEsumData(filename,imagenum=imagenum,sum=True)
     106            GetGEsumData(self,filename,imagenum=imagenum,sum=True)
    107107        if self.Npix == 0 or not self.Comments:
    108108            return False
     
    112112        return True
    113113
    114 def GetGEsumData(filename,imagenum=1,sum=False):
     114def GetGEsumData(self,filename,imagenum=1,sum=False):
    115115    '''Read G.E. detector images from various files as produced at 1-ID and
    116116    with Detector Pool detector. Also sums multiple image files if desired
     
    118118    import struct as st
    119119    import array as ar
     120    import cPickle
    120121    more = False
    121122    File = open(filename,'rb')
     
    154155        head += ['file: '+filename+' image #'+str(imagenum),]
    155156        if sum:    #will ignore imagenum
     157            print 'Frames to read %d'%(nframes),
    156158            while nframes > 1: #OK, this will sum the frames.
    157                 image += np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
     159                try:
     160                    image += np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
     161                except ValueError:
     162                    break
    158163                nframes -= 1
     164                print '%d'%(nframes),
     165            print ''   
    159166            more = False
     167            filename = os.path.splitext(filename)[0]+'.G2img'
     168            File = open(filename,'wb')
     169            Data = {'pixelSize':[200,200],'wavelength':0.15,'distance':250.0,'center':[204.8,204.8],'size':sizexy}
     170            image = np.reshape(image,(sizexy[1],sizexy[0]))
     171            cPickle.dump([head,Data,Npix,image],File,1)
     172            File.close()
     173            self.sumfile = filename
     174            self.formatName = 'Summed GSAS-II image'
     175            sum = False
    160176    image = np.reshape(image,(sizexy[1],sizexy[0]))
    161177    data = {'pixelSize':[200,200],'wavelength':0.15,'distance':250.0,'center':[204.8,204.8],'size':sizexy}
Note: See TracChangeset for help on using the changeset viewer.