source: trunk/exports/G2export_image.py @ 1191

Last change on this file since 1191 was 1191, checked in by vondreele, 9 years ago

CSV exporter for strain results

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 1.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3########### SVN repository information ###################
4# $Date: 2014-01-10 20:46:36 +0000 (Fri, 10 Jan 2014) $
5# $Author: vondreele $
6# $Revision: 1191 $
7# $URL: trunk/exports/G2export_image.py $
8# $Id: G2export_image.py 1191 2014-01-10 20:46:36Z vondreele $
9########### SVN repository information ###################
10'''
11*Module G2export_image: 2D Image data export*
12------------------------------------------------------
13
14Demonstrates how an image is retrieved and written. Uses
15a SciPy routine to write a PNG format file.
16'''
17import os.path
18import scipy.misc
19import GSASIIpath
20GSASIIpath.SetVersionNumber("$Revision: 1191 $")
21import GSASIIIO as G2IO
22import GSASIImath as G2mth
23
24class ExportImagePNG(G2IO.ExportBaseclass):
25    '''Used to create a PNG file for a GSAS-II image
26
27    :param wx.Frame G2frame: reference to main GSAS-II frame
28    '''
29    def __init__(self,G2frame):
30        super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__
31            G2frame=G2frame,
32            formatName = 'PNG image file',
33            extension='.png',
34            longFormatName = 'Export image in PNG format'
35            )
36        self.exporttype = ['image']
37        #self.multiple = True
38    def Exporter(self,event=None):
39        '''Export an image
40        '''
41        # the export process starts here
42        self.InitExport(event)
43        # load all of the tree into a set of dicts
44        self.loadTree()
45        if self.ExportSelect(False): return
46        # process the selected image(s) (at present only one image)
47        for i in sorted(self.histnam): 
48            imgFile = self.Histograms[i].get('Data',(None,None))
49            Comments,Data,Npix,Image = G2IO.GetImageData(self.G2frame,imgFile)
50            scipy.misc.imsave(self.filename,Image)
51            print('Image '+str(imgFile)+' written to file '+str(self.filename))                   
Note: See TracBrowser for help on using the repository browser.