1 | # -*- coding: utf-8 -*- |
---|
2 | ########### SVN repository information ################### |
---|
3 | # $Date: 2014-12-27 11:14:59 -0600 (Sat, 27 Dec 2014) $ |
---|
4 | # $Author: $ |
---|
5 | # $Revision: $ |
---|
6 | # $URL: $ |
---|
7 | # $Id: $ |
---|
8 | ########### SVN repository information ################### |
---|
9 | ''' |
---|
10 | *Module G2img_G2: Python pickled image* |
---|
11 | --------------------------------------- |
---|
12 | |
---|
13 | Routine to read an image that has been pickled in Python. Images |
---|
14 | in this format are created by the "Sum image data" command. |
---|
15 | |
---|
16 | ''' |
---|
17 | |
---|
18 | import sys |
---|
19 | import os |
---|
20 | import GSASIIIO as G2IO |
---|
21 | import GSASIIpath |
---|
22 | GSASIIpath.SetVersionNumber("$Revision: $") |
---|
23 | class G2_ReaderClass(G2IO.ImportImage): |
---|
24 | def __init__(self): |
---|
25 | super(self.__class__,self).__init__( # fancy way to self-reference |
---|
26 | extensionlist=('.G2img',), |
---|
27 | strictExtension=True, |
---|
28 | formatName = 'Summed GSAS-II image', |
---|
29 | longFormatName = 'Pickled image from GSAS-II "Sum image data" command' |
---|
30 | ) |
---|
31 | |
---|
32 | def ContentsValidator(self, filepointer): |
---|
33 | '''no test at this time |
---|
34 | ''' |
---|
35 | return True |
---|
36 | |
---|
37 | def Reader(self,filename,filepointer, ParentFrame=None, **unused): |
---|
38 | '''Read using scipy PNG reader |
---|
39 | ''' |
---|
40 | import scipy.misc |
---|
41 | Fp = open(filename,'rb') |
---|
42 | self.Comments,self.Data,self.Npix,self.image = cPickle.load(Fp) |
---|
43 | Fp.close() |
---|
44 | self.LoadImage(ParentFrame,filename) |
---|
45 | return True |
---|
46 | # N.B. This replaces G2IO.GetG2Image |
---|