source: trunk/imports/G2img_CheMin.py @ 2817

Last change on this file since 2817 was 2817, checked in by vondreele, 5 years ago

major revision - move all importers to GSASIIobj & make them independent of wx so they can be used in a scripting environment.
Still to move are PhaseSelector?, and 3 BlockSelector? dialogs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.8 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2017-05-02 15:03:41 +0000 (Tue, 02 May 2017) $
4# $Author: vondreele $
5# $Revision: 2817 $
6# $URL: trunk/imports/G2img_CheMin.py $
7# $Id: G2img_CheMin.py 2817 2017-05-02 15:03:41Z vondreele $
8########### SVN repository information ###################
9'''
10*Module G2img_png: png image file*
11---------------------------------------
12
13Routine to read an image in .png (Portable Network Graphics) format.
14For now, the only known use of this is with converted Mars Rover (CheMin)
15tif files, so default parameters are for that.
16
17'''
18
19import GSASIIobj as G2obj
20import GSASIIpath
21GSASIIpath.SetVersionNumber("$Revision: 2817 $")
22class png_ReaderClass(G2obj.ImportImage):
23    '''Reads standard PNG images; parameters are set to those of the
24    Mars Rover (CheMin) diffractometer.
25    '''
26    def __init__(self):
27        super(self.__class__,self).__init__( # fancy way to self-reference
28            extensionlist=('.png',),
29            strictExtension=True,
30            formatName = 'PNG image',
31            longFormatName = 'PNG image from CheMin'
32            )
33
34    def ContentsValidator(self, filepointer):
35        '''no test at this time
36        '''
37        return True
38       
39    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
40        '''Reads using standard scipy PNG reader
41        '''
42        import scipy.misc
43        self.Image = scipy.misc.imread(filename,flatten=True).T
44        self.Npix = self.Image.size
45        if self.Npix == 0:
46            return False
47        if ParentFrame:
48            self.SciPy = True
49            self.Comments = ['no metadata']
50            pixy = list(self.Image.shape)
51            sizexy = [40,40]
52            self.Data = {'wavelength': 1.78892, 'pixelSize': sizexy, 'distance': 18.0,'size':pixy}
53            self.Data['center'] = [pixy[0]*sizexy[0]/1000.,pixy[1]*sizexy[1]/2000.]
54        self.LoadImage(ParentFrame,filename)
55        return True
Note: See TracBrowser for help on using the repository browser.