source: trunk/G2importsfact.py @ 589

Last change on this file since 589 was 584, checked in by vondreele, 13 years ago

add coding line everywhere
more options in sample parm copy

File size: 2.3 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
4# $Author: vondreele & toby $
5# $Revision: 482 $
6# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase.py $
7# $Id: G2importphase.py 482 2012-02-13 17:33:35Z vondreele $
8########### SVN repository information ###################
9# short routines to read in structure factors from simple file formats
10#
11import sys
12import numpy as np
13import GSASIIIO as G2IO
14
15class HKLF_ReaderClass(G2IO.ImportStructFactor):
16    'Routines to import reflections from a HKLF file'
17    def __init__(self):
18        super(self.__class__,self).__init__( # fancy way to self-reference
19            extensionlist=('.hkl','.HKL'),
20            strictExtension=False,
21            formatName = 'HKL',
22            longFormatName = 'Simple (hkl Fo sig(Fo)) Structure factor file'
23            )
24    # Validate the contents
25    def ContentsValidator(self, filepointer):
26        S = filepointer.readline() 
27        while '#' in S[0]:        #get past comments, if any
28            S = filepointer.readline()       
29        for i in range(3): # scan a few lines
30            S = S.split()
31            if len(S) != 5: return False
32            for v in S:
33                try:
34                    float(v)
35                except ValueError:
36                    return False           
37            S = filepointer.readline()
38        return True
39
40    def Reader(self,filename,filepointer, ParentFrame=None):
41        try:
42            for S in filepointer:
43                if S[0] == '#': continue       #ignore comments, if any
44                h,k,l,Fo,sigFo = S.split()
45                HKL = np.array([int(h),int(k),int(l)])
46                Fo = float(Fo)
47                sigFo = float(sigFo)
48                self.RefList.append([HKL,Fo**2,2.*Fo*sigFo,0,0,0,0])  # HKL. Fo**2, sig(Fo**2), Fc, Fcp, Fcpp & phase
49                #print HKL,Fo**2,2.*Fo*sigFo
50            self.UpdateControls(Type='Fosq',FcalcPresent=False) # set Fobs type & if Fcalc values are loaded
51            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
52            return True
53        except Exception as detail:
54            print self.formatName+' read error:'+str(detail) # for testing
55            import traceback
56            traceback.print_exc(file=sys.stdout)
57            return False
Note: See TracBrowser for help on using the repository browser.