source: trunk/exports/G2export_example.py @ 1090

Last change on this file since 1090 was 1084, checked in by toby, 8 years ago

installer uses xterm on GNOME shortcut

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3########### SVN repository information ###################
4# $Date: $
5# $Author: $
6# $Revision: -1 $
7# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/exports/G2export_CIF.py $
8# $Id: G2export_CIF.py -1   $
9########### SVN repository information ###################
10'''Code to demonstrate how export routines are created
11'''
12import os.path
13import GSASIIpath
14GSASIIpath.SetVersionNumber("$Revision: -1 $")
15import GSASIIIO as G2IO
16#import GSASIIgrid as G2gd
17import GSASIIstrIO as G2stIO
18#import GSASIImath as G2mth
19import GSASIIlattice as G2lat
20import GSASIIspc as G2spc
21#import GSASIIphsGUI as G2pg
22#import GSASIIstrMain as G2stMn
23
24class ExportPhaseShelx(G2IO.ExportBaseclass):
25    '''Used to create a SHELX .ins file for a phase
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 = 'SHELX',
33            extension='.ins',
34            longFormatName = 'Export phase as SHELX .ins file'
35            )
36        self.exporttype = ['phase']
37        self.multiple = True
38
39    def Exporter(self,event=None):
40        '''Export as a SHELX .ins file
41        '''
42        # the export process starts here
43        # load all of the tree into a set of dicts
44        self.loadTree()
45        # create a dict with refined values and their uncertainties
46        self.loadParmDict()
47        if self.SetupExport(event,                         # set export parameters
48                            AskFile=True
49                            ): return 
50        for phasenam in self.phasenam:
51            phasedict = self.Phases[phasenam] # pointer to current phase info           
52            i = self.Phases[phasenam]['pId']
53            if len(self.phasenam) > 1: # if more than one filename is included, add a phase #
54                nam,ext = os.path.splitext(self.filename)
55                fil = nam+"_"+str(i)+ext
56            else:
57                fil = self.filename
58            fp = self.OpenFile(fil)
59            self.Write("TITL from "+str(self.G2frame.GSASprojectfile)+" phase "+str(phasenam))
60            # get cell parameters
61            pfx = str(phasedict['pId'])+'::'
62            A,sigA = G2stIO.cellFill(pfx,phasedict['General']['SGData'],self.parmDict,self.sigDict)
63            #cellSig = G2stIO.getCellEsd(pfx,
64            #                           phasedict['General']['SGData'],A,
65            #                           self.OverallParms['Covariance'])  # returns 7 vals, includes sigVol
66            #cellList = G2lat.A2cell(A) + (G2lat.calc_V(A),)
67            # write out cell parameters with dummy (0.5A) wavelength
68            self.Write("CELL 0.5 {:.5f} {:.5f} {:.5f} {:.3f} {:.3f} {:.3f}".format(*G2lat.A2cell(A)))
69           
70
71            self.CloseFile()
72            print('Phase '+str(phasenam)+' written to file '+str(fil))
Note: See TracBrowser for help on using the repository browser.