source: trunk/imports/G2img_SumG2.py @ 2309

Last change on this file since 2309 was 2309, checked in by vondreele, 7 years ago

rename G2img formatName to "GSAS-II image" & add CBF importer

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.5 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2016-06-05 17:58:58 +0000 (Sun, 05 Jun 2016) $
4# $Author: vondreele $
5# $Revision: 2309 $
6# $URL: trunk/imports/G2img_SumG2.py $
7# $Id: G2img_SumG2.py 2309 2016-06-05 17:58:58Z vondreele $
8########### SVN repository information ###################
9'''
10*Module G2img_SumG2: Python pickled image*
11------------------------------------------
12
13'''
14
15import sys
16import os
17import cPickle
18import GSASIIIO as G2IO
19import GSASIIpath
20GSASIIpath.SetVersionNumber("$Revision: 2309 $")
21class G2_ReaderClass(G2IO.ImportImage):
22    '''Routine to read an image that has been pickled in Python. Images
23    in this format are created by the "Sum image data" command. At least for
24    now, only one image is permitted per file.
25    '''
26    def __init__(self):
27        super(self.__class__,self).__init__( # fancy way to self-reference
28            extensionlist=('.G2img',),
29            strictExtension=True,
30            formatName = 'GSAS-II image',
31            longFormatName = 'cPickled image from GSAS-II'
32            )
33
34    def ContentsValidator(self, filepointer):
35        '''test by trying to unpickle (should be quick)
36        '''
37        try:
38            cPickle.load(filepointer)
39        except:
40            return False
41        return True
42       
43    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
44        '''Read using cPickle
45        '''
46        import scipy.misc
47        Fp = open(filename,'rb')
48        self.Comments,self.Data,self.Npix,self.Image = cPickle.load(Fp)
49        Fp.close()
50        self.LoadImage(ParentFrame,filename)
51        return True
Note: See TracBrowser for help on using the repository browser.