Changeset 2227


Ignore:
Timestamp:
Apr 26, 2016 8:36:05 AM (6 years ago)
Author:
vondreele
Message:

avoid divide by zero effect if a zero image
refactor LoadImage2Tree
add new importer for summing GE images

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r2223 r2227  
    277277    ImageTag (where there is more than one image in the file), if defined.
    278278    '''
    279     ImgNames = []
    280     if G2frame.PatternTree.GetCount(): # get a list of existing Image entries
    281         item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)
    282         while item:
    283             name = G2frame.PatternTree.GetItemText(item)
    284             if name.startswith('IMG'): ImgNames.append(name)       
    285             item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
     279    ImgNames = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
    286280    TreeLbl = 'IMG '+os.path.basename(imagefile)
    287281    ImageTag = Data.get('ImageTag')
  • trunk/GSASIIimgGUI.py

    r2226 r2227  
    448448        maxSizer.AddGrowableCol(1,1)
    449449        maxSizer.SetFlexibleDirection(wx.HORIZONTAL)
    450         sqrtDeltZero = math.sqrt(data['range'][0][1]-max(0.0,data['range'][0][0]))
    451         DeltOne = data['range'][1][1]-max(0.0,data['range'][0][0])
     450        sqrtDeltZero = max(1.0,math.sqrt(data['range'][0][1]-max(0.0,data['range'][0][0])))
     451        DeltOne = max(1.0,data['range'][1][1]-max(0.0,data['range'][0][0]))
    452452        sqrtDeltOne = math.sqrt(DeltOne)
    453453        maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Max intensity'),0,WACV)
  • trunk/imports/G2img_GE.py

    r2133 r2227  
    2222import GSASIIpath
    2323GSASIIpath.SetVersionNumber("$Revision$")
    24 class GEsum_ReaderClass(G2IO.ImportImage):
     24class GE_ReaderClass(G2IO.ImportImage):
    2525    '''Routine to read a GE image, typically from APS Sector 1.
    2626       
     
    4747    def Reader(self,filename,filepointer, ParentFrame=None, **kwarg):
    4848        '''Read using GE file reader, :func:`GetGEsumData`
     49        should this read all blocks & sum them if desired?
    4950        '''
    5051        #rdbuffer = kwarg.get('buffer')
    5152        imagenum = kwarg.get('blocknum')
     53        #sum = kwarg.get('sum')
    5254        if imagenum is None: imagenum = 1
    5355        self.Comments,self.Data,self.Npix,self.Image,more = GetGEsumData(filename,imagenum=imagenum)
     
    5961        return True
    6062
    61 def GetGEsumData(filename,imagenum=1):
     63class GE_sumReaderClass(G2IO.ImportImage):
     64    '''Routine to read multiple GE images & sum them, typically from APS Sector 1.
     65       
     66        The image files may be of form .geX (where X is ' ', 1, 2, 3 or 4),
     67        which is a raw image from the detector. These files may contain more
     68        than one image and have a rudimentary header.
     69        Files with extension .sum or .cor are 4 byte integers/pixel, one image/file.
     70        Files with extension .avg are 2 byte integers/pixel, one image/file.
     71    '''
     72
     73    def __init__(self):
     74        super(self.__class__,self).__init__( # fancy way to self-reference
     75            extensionlist=('.ge1','.ge2','.ge3','.ge4'),
     76            strictExtension=True,
     77            formatName = 'GE multi-image summed',
     78            longFormatName = 'sum of GE multi-image file'
     79            )
     80
     81    def ContentsValidator(self, filepointer):
     82        '''no test at this time
     83        '''
     84        return True
     85       
     86    def Reader(self,filename,filepointer, ParentFrame=None, **kwarg):
     87        '''Read using GE file reader, :func:`GetGEsumData`
     88        should this read all blocks & sum them if desired?
     89        '''
     90        #rdbuffer = kwarg.get('buffer')
     91        imagenum = kwarg.get('blocknum')
     92        if imagenum is None: imagenum = 1
     93        self.Comments,self.Data,self.Npix,self.Image,more = GetGEsumData(filename,imagenum=imagenum,sum=True)
     94        if self.Npix == 0 or not self.Comments:
     95            return False
     96        self.LoadImage(ParentFrame,filename,imagenum)
     97        self.repeatcount = imagenum
     98        self.repeat = more
     99        return True
     100
     101def GetGEsumData(filename,imagenum=1,sum=False):  #
    62102    '''Read G.E. detector images from various files as produced at 1-ID and
    63     with Detector Pool detector.
     103    with Detector Pool detector. Also sums multiple image files if desired
    64104    '''
    65105    import struct as st
     
    100140            return 0,0,0,0,False           
    101141        head += ['file: '+filename+' image #'+str(imagenum),]
    102         #while nframes > 1:
    103         #    print 'adding'
    104         #    image += np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
    105         #    nframes -= 1
     142        if sum:    #will ignore imagenum
     143            while nframes > 1: #OK, this will sum the frames.
     144        #      print 'adding'
     145                image += np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
     146                nframes -= 1
     147            more = False
    106148    image = np.reshape(image,(sizexy[1],sizexy[0]))
    107149    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.