source: trunk/G2importphase_GPX.py @ 574

Last change on this file since 574 was 574, checked in by vondreele, 10 years ago

fixed import of .gpx phases

File size: 1.9 KB
Line 
1########### SVN repository information ###################
2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
3# $Author: vondreele & toby $
4# $Revision: 482 $
5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase_GPX.py $
6# $Id: G2importphase_GPX.py 482 2012-02-13 17:33:35Z vondreele $
7########### SVN repository information ###################
8# Routines to import Phase information from GSAS-II .gpx files
9import cPickle
10import GSASIIIO as G2IO
11import GSASIIstruct as G2str
12
13class PhaseReaderClass(G2IO.ImportPhase):
14    def __init__(self):
15        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
16            extensionlist=('.gpx',),
17            strictExtension=True,
18            formatName = 'GSAS-II gpx',
19            longFormatName = 'GSAS-II project (.gpx file) import'
20            )
21    def ContentsValidator(self, filepointer):
22        filepointer.seek(0) # rewind the file pointer
23        # if the 1st section can't be read as a cPickle file, it can't be!
24        try: 
25            cPickle.load(filepointer)
26        except:
27            return False
28        return True
29    def Reader(self,filename,filepointer, ParentFrame=None):
30        try:
31            phasenames = G2str.GetPhaseNames(filename)
32            print phasenames
33        except:
34            return False
35        if not phasenames:
36            return False            # no blocks with coordinates
37        elif len(phasenames) == 1: # no choices
38            selblk = 0
39        else:                       # choose from options               
40            selblk = self.PhaseSelector(
41                phasenames,
42                ParentFrame=ParentFrame,
43                title= 'Select a phase from the list below',
44                )
45            if selblk is None: return False # User pressed cancel
46        try:
47            self.Phase = G2str.GetAllPhaseData(filename,phasenames[selblk])
48            return True
49        except:
50            return False
51
Note: See TracBrowser for help on using the repository browser.