source: trunk/imports/G2sfact.py @ 2038

Last change on this file since 2038 was 2038, checked in by vondreele, 7 years ago

add betaij2Uij to G2lattice
revisions to SS structure factor calcs. Use hklt proj to hkl is several places
fxn works for thiourea derivs OK except X,Y,Zcos modulations; no Uijsin/cos derivatives yet
adj scaling of 4D charge flip maps
convert betaij vals from Jana2K files to Uij
start on SS read phase from cif
added a hklt F import (might vanish)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 25.2 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2015-10-30 21:02:02 +0000 (Fri, 30 Oct 2015) $
4# $Author: vondreele $
5# $Revision: 2038 $
6# $URL: trunk/imports/G2sfact.py $
7# $Id: G2sfact.py 2038 2015-10-30 21:02:02Z vondreele $
8########### SVN repository information ###################
9'''
10*Module G2sfact: simple HKL import*
11-----------------------------------
12Read structure factors from a simple hkl file. Two routines are
13provided to read from files containing F or F\ :sup:`2` values.
14
15'''
16import sys
17import numpy as np
18import copy
19import GSASIIIO as G2IO
20import GSASIIpath
21GSASIIpath.SetVersionNumber("$Revision: 2038 $")
22
23def ColumnValidator(parent, filepointer,nCol=5):
24    'Validate a file to check that it contains columns of numbers'
25    l = filepointer.readline()
26    line = 1
27    while l[0] in ['#','(']:        #get past comments & fortran formats, if any
28        l = filepointer.readline()       
29        line += 1
30    for i in range(10): # scan a few lines
31        S = l.split()
32        if len(S) < nCol:
33            parent.errors = 'line '+str(line)+': invalid input\n'+l
34            return False
35        for v in S[:nCol]:
36            try:
37                float(v)
38            except ValueError:
39                parent.errors = 'line '+str(line)+': string found where a number is expected\n'+l
40                return False           
41        l = filepointer.readline()
42        line += 1
43    return True
44
45
46class HKLF_ReaderClass(G2IO.ImportStructFactor):
47    'Routines to import F, sig(F) reflections from a HKLF file'
48    def __init__(self):
49        super(self.__class__,self).__init__( # fancy way to self-reference
50            extensionlist=('.hkl','.HKL'),
51            strictExtension=False,
52            formatName = 'HKL F',
53            longFormatName = 'Simple [hkl, Fo, sig(Fo)] Structure factor text file'
54            )
55
56    def ContentsValidator(self, filepointer):
57        'Make sure file contains the expected columns on numbers'
58        return ColumnValidator(self, filepointer)
59
60    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
61        'Read the file'
62        try:
63            for line,S in enumerate(filepointer):
64                self.errors = '  Error reading line '+str(line+1)
65                if S[0] == '#': continue       #ignore comments, if any
66                h,k,l,Fo,sigFo = S.split()
67                h,k,l = [int(h),int(k),int(l)]
68                if not any([h,k,l]):
69                    break
70                Fo = float(Fo)
71                sigFo = float(sigFo)
72                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
73                self.RefDict['RefList'].append([h,k,l,1,0,Fo**2,2.*Fo*sigFo,0,Fo**2,0,0,0])
74            self.errors = 'Error after reading reflections (unexpected!)'
75            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
76            self.RefDict['Type'] = 'SXC'
77            self.RefDict['Super'] = 0
78            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
79            return True
80        except Exception as detail:
81            self.errors += '\n  '+str(detail)
82            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
83            import traceback
84            traceback.print_exc(file=sys.stdout)
85            return False
86
87class HKLMF_ReaderClass(G2IO.ImportStructFactor):
88    'Routines to import F, reflections from a REMOS HKLMF file'
89    def __init__(self):
90        super(self.__class__,self).__init__( # fancy way to self-reference
91            extensionlist=('.fo','.FO'),
92            strictExtension=False,
93            formatName = 'HKLM F',
94            longFormatName = 'REMOS [hklm, Fo] Structure factor text file'
95            )
96
97    def ContentsValidator(self, filepointer):
98        'Make sure file contains the expected columns on numbers'
99        return ColumnValidator(self, filepointer)
100
101    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
102        'Read the file'
103        try:
104            for line,S in enumerate(filepointer):
105                self.errors = '  Error reading line '+str(line+1)
106                if S[0] == '#': continue       #ignore comments, if any
107                h,k,l,m,Fo= S.split()
108                h,k,l,m = [int(h),int(k),int(l),int(m)]
109                if h == 999 or not any([h,k,l]):
110                    break
111                Fo = float(Fo)
112                sigFo2 = Fo
113                if Fo < 1.0:
114                    sigFo2 = 1.0
115               # h,k,l,m,tw,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
116                self.RefDict['RefList'].append([h,k,l,m,1,0,Fo**2,sigFo2,0,Fo**2,0,0,0])
117            self.errors = 'Error after reading reflections (unexpected!)'
118            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
119            self.RefDict['Type'] = 'SXC'
120            self.RefDict['Super'] = 1
121            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
122            return True
123        except Exception as detail:
124            self.errors += '\n  '+str(detail)
125            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
126            import traceback
127            traceback.print_exc(file=sys.stdout)
128            return False
129
130class SHELX4_ReaderClass(G2IO.ImportStructFactor):
131    'Routines to import F**2, sig(F**2) reflections from a Shelx HKLF 4 file'
132    def __init__(self):
133        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
134            formatName = 'HKLF 4'
135            longFormatName = 'Shelx HKLF 4 [hkl, Fo2, sig(Fo2)] Structure factor text file'
136        else:
137            formatName = u'Shelx HKLF 4 F\u00b2'
138            longFormatName = u'Shelx HKLF 4 [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'
139        super(self.__class__,self).__init__( # fancy way to self-reference
140            extensionlist=('.hkl','.HKL'),
141            strictExtension=False,
142            formatName=formatName,
143            longFormatName=longFormatName)
144
145    def ContentsValidator(self, filepointer):
146        'Make sure file contains the expected columns on numbers'
147        return ColumnValidator(self, filepointer)
148
149    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
150        'Read the file'
151        try:
152            for line,S in enumerate(filepointer):
153                self.errors = '  Error reading line '+str(line+1)
154                if S[0] == '#': continue       #ignore comments, if any
155                h,k,l,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:20],S[20:28]
156                h,k,l = [int(h),int(k),int(l)]
157                if not any([h,k,l]):
158                    break
159                Fo = float(Fo)
160                sigFo = float(sigFo)
161                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
162                self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0])
163                #self.RefDict['FF'].append({}) # now done in OnImportSfact
164            self.errors = 'Error after reading reflections (unexpected!)'
165            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
166            self.RefDict['Type'] = 'SXC'
167            self.RefDict['Super'] = 0
168            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
169            return True
170        except Exception as detail:
171            self.errors += '\n  '+str(detail)
172            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
173            import traceback
174            traceback.print_exc(file=sys.stdout)
175            return False
176           
177class SHELX5_ReaderClass(G2IO.ImportStructFactor):
178    'Routines to import F**2, sig(F**2) twin/incommensurate reflections from a fixed format SHELX HKLF5 file'
179    def __init__(self):
180        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
181            formatName = 'Shelx HKLF 5 F2 Tw/Incom'
182            longFormatName = 'Shelx HKLF 5 [hklm, Fo2, sig(Fo2), Tind] Twin/incommensurate structure factor text file'
183        else:
184            formatName = u'Shelx HKLF 5 F\u00b2 Tw/Incom'
185            longFormatName = u'Shelx HKLF 5 [hklm, Fo\u00b2, sig(Fo\u00b2), Tind] Twin/incommensurate structure factor text file'       
186        super(self.__class__,self).__init__( # fancy way to self-reference
187            extensionlist=('.hkl','.HKL'),
188            strictExtension=False,
189            formatName=formatName,
190            longFormatName=longFormatName)
191        self.Super = 0
192
193    def ContentsValidator(self, filepointer):
194        '''Discover how many columns before F^2 are in the SHELX HKL5 file
195        - could be 3-6 depending on satellites'''
196        numCols = 0
197        for i,line in enumerate(filepointer):
198            for j,item in enumerate(line.split()):  #find 1st col with '.'; has F^2
199                if '.' in item:
200                    numCols = max(numCols,j)
201                    break
202            if i > 20:
203                break
204        self.Super = numCols-3     #= 0,1,2,or 3
205        if self.Super > 1:
206            raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
207        return True
208
209    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
210        'Read the file'
211        TwDict = {}
212        TwSet = {}
213        TwMax = [-1,[]]
214        first = True
215        try:
216            for line,S in enumerate(filepointer):
217                self.errors = '  Error reading line '+str(line+1)
218                if self.Super == 0:
219                    h,k,l,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:20],S[20:28],S[28:32]
220                    h,k,l = [int(h),int(k),int(l)]
221                elif self.Super == 1:
222                    h,k,l,m1,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:16],S[16:24],S[24:32],S[32:36]
223                    h,k,l,m1 = [int(h),int(k),int(l),int(m1)]
224                Tw = Tw.strip()
225                if Tw in ['','0']:
226                    Tw = '1'
227                if not any([h,k,l]):
228                    break
229                if '-' in Tw:
230                    if Tw == '-1':  #fix reversed twin ids
231                        Tw = '-2'
232                        if first:
233                            self.warnings += '\nPrimary twin id changed to 1'
234                            first = False
235                    TwId = -int(Tw)-1
236                    TwSet[TwId] = np.array([h,k,l])
237                    if TwId not in TwMax[1]:
238                        TwMax[1].append(TwId)
239                else:
240                    if Tw != '1':  #fix reversed twin ids
241                        if first:
242                            self.warnings += '\nPrimary twin id changed to 1\nNB: multiple primary twins not working'
243                            first = False
244                        Tw = '1'
245                    TwId = int(Tw)-1
246                    if TwSet:
247                        TwDict[len(self.RefDict['RefList'])] = TwSet
248                        TwSet = {}   
249                    Fo = float(Fo)
250                    sigFo = float(sigFo)
251                    # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
252                    if self.Super == 0:
253                        self.RefDict['RefList'].append([h,k,l,int(Tw),0,Fo,sigFo,0,Fo,0,0,0])
254                    elif self.Super == 1:
255                        self.RefDict['RefList'].append([h,k,l,m1,int(Tw),0,Fo,sigFo,0,Fo,0,0,0])
256                TwMax[0] = max(TwMax[0],TwId)
257            self.errors = 'Error after reading reflections (unexpected!)'
258            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
259            self.RefDict['Type'] = 'SXC'
260            self.RefDict['Super'] = self.Super
261            self.RefDict['TwDict'] = TwDict
262            self.RefDict['TwMax'] = TwMax
263            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
264            return True
265        except Exception as detail:
266            self.errors += '\n  '+str(detail)
267            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
268            import traceback
269            traceback.print_exc(file=sys.stdout)
270            return False
271
272class M90_ReaderClass(G2IO.ImportStructFactor):
273    'Routines to import F**2, sig(F**2) reflections from a JANA M90 file'
274    def __init__(self):
275        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
276            longFormatName = 'JANA [hkl, Fo2, sig(Fo2)] Structure factor text file'
277        else:
278            longFormatName = u'JANA [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'
279        super(self.__class__,self).__init__( # fancy way to self-reference
280            extensionlist=('.m90','.M90'),
281            strictExtension=False,
282            formatName = u'JANA M90',
283            longFormatName = longFormatName
284            )
285        self.Super = 0
286
287    def ContentsValidator(self, filepointer):
288        'Discover how many columns are in the m90 file - could be 9-12 depending on satellites'
289        numCols = 0
290        for i,line in enumerate(filepointer):
291            if 'Data' in line:
292                startData = i
293                break
294        for i,line in enumerate(filepointer):
295            if i > startData:
296                numCols = max(numCols,len(line.split()))
297            if i > startData+20:
298                break
299        self.Super = numCols-9     #= 0,1,2,or 3
300        if self.Super > 1:
301            raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
302        return True #ColumnValidator(self, filepointer)
303
304    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
305        'Read the file'
306        try:
307            for line,S in enumerate(filepointer):
308                self.errors = '  Error reading line '+str(line+1)
309                if S[0] == '#': continue       #ignore comments, if any
310                try:
311                    if self.Super == 0:
312                        h,k,l,Fo,sigFo = S.split()[:5]
313                        h,k,l = [int(h),int(k),int(l)]
314                    elif self.Super == 1:
315                        h,k,l,m1,Fo,sigFo = S.split()[:6]
316                        h,k,l,m1 = [int(h),int(k),int(l),int(m1)]
317                except ValueError:  #skipping text at front
318                    if not S:
319                        break
320                    text = S.split()
321                    if text[0] == 'lambda':
322                        wave = float(text[1])
323                    continue
324                Fo = float(Fo)
325                sigFo = float(sigFo)
326                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
327                if self.Super == 0:
328                    self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0])
329                elif self.Super == 1:
330                    self.RefDict['RefList'].append([h,k,l,m1,1,0,Fo,sigFo,0,Fo,0,0,0])
331            self.errors = 'Error after reading reflections (unexpected!)'
332            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
333            self.RefDict['Type'] = 'SXC'
334            self.RefDict['Super'] = self.Super
335            self.UpdateParameters(Type='SXC',Wave=wave) # histogram type
336            return True
337        except Exception as detail:
338            self.errors += '\n  '+str(detail)
339            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
340            import traceback
341            traceback.print_exc(file=sys.stdout)
342            return False
343           
344class NT_HKLF2_ReaderClass(G2IO.ImportStructFactor):
345    'Routines to import neutron TOF F**2, sig(F**2) reflections from a HKLF file'
346    def __init__(self):
347        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
348            formatName = 'Neutron TOF HKL F2'
349            longFormatName = 'Neutron TOF [hkl, Fo2, sig(Fo2),...] Structure factor text file'
350        else:
351            formatName = u'Neutron TOF HKL F\u00b2'
352            longFormatName = u'Neutron TOF [hkl, Fo\u00b2, sig(Fo\u00b2),...] Structure factor text file'
353        super(self.__class__,self).__init__( # fancy way to self-reference
354            extensionlist=('.hkl','.HKL'),
355            strictExtension=False,
356            formatName=formatName,
357            longFormatName=longFormatName)
358
359    def ContentsValidator(self, filepointer):
360        'Make sure file contains the expected columns on numbers & count number of data blocks - "Banks"'
361        oldNo = -1
362        for line,S in enumerate(filepointer):
363            if not S:   #empty line terminates read
364                break
365            if S[0] == '#': continue       #ignore comments, if any
366            if S.split()[:3] == ['0','0','0']:
367                break
368            bankNo = S.split()[5]
369            if bankNo != oldNo:
370                self.Banks.append({'RefDict':{'RefList':[],}})
371                oldNo = bankNo
372        filepointer.seek(0)
373        return ColumnValidator(self, filepointer,nCol=8)
374
375    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
376        'Read the file'
377        filepointer.seek(0)
378        try:
379            for line,S in enumerate(filepointer):
380                self.errors = '  Error reading line '+str(line+1)
381                if S[0] == '#': continue       #ignore comments, if any
382                data = S.split()
383                h,k,l,Fo,sigFo,bN,wave,tbar = data[:8]  #bN = 1..., 6 dir cos next                   
384                h,k,l = [int(h),int(k),int(l)]
385                if not any([h,k,l]):
386                    break
387                Fo = float(Fo)
388                sigFo = float(sigFo)
389                wave = float(wave)
390                tbar = float(tbar)
391                if len(self.Banks):
392                    self.Banks[int(bN)-1]['RefDict']['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
393                else:
394                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
395                    self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
396            if len(self.Banks):
397                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
398                for Bank in self.Banks:
399                    Bank['RefDict']['RefList'] = np.array(Bank['RefDict']['RefList'])
400                    Bank['RefDict']['Type'] = 'SNT'                   
401                    Bank['RefDict']['Super'] = 0
402            else:
403                self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
404                self.RefDict['Type'] = 'SNT'
405                self.RefDict['Super'] = 0
406                self.errors = 'Error after reading reflections (unexpected!)'
407                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
408            return True
409        except Exception as detail:
410            self.errors += '\n  '+str(detail)
411            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
412            import traceback
413            traceback.print_exc(file=sys.stdout)
414            return False
415
416class NT_JANA2K_ReaderClass(G2IO.ImportStructFactor):
417    'Routines to import neutron TOF F**2, sig(F**2) reflections from a JANA2000 file'
418    def __init__(self):
419        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
420            formatName = 'Neutron TOF JANA2000 F2'
421            longFormatName = 'Neutron TOF [hkl, Fo2, sig(Fo2),...] Structure factor text file'
422        else:
423            formatName = u'Neutron TOF JANA2000 F\u00b2'
424            longFormatName = u'Neutron TOF [hkl, Fo\u00b2, sig(Fo\u00b2),...] Structure factor text file'
425        super(self.__class__,self).__init__( # fancy way to self-reference
426            extensionlist=('.int','.INT'),
427            strictExtension=False,
428            formatName=formatName,
429            longFormatName=longFormatName)
430
431    def ContentsValidator(self, filepointer):
432        'Make sure file contains the expected columns on numbers & count number of data blocks - "Banks"'
433        oldNo = -1
434        for line,S in enumerate(filepointer):
435            if not S:   #empty line terminates read
436                break
437            if S[0] in ['#','(']: continue       #ignore comments & fortran format line
438            bankNo = S.split()[5]
439            if bankNo != oldNo:
440                self.Banks.append({'RefDict':{'RefList':[],}})
441                oldNo = bankNo
442        filepointer.seek(0)
443        return ColumnValidator(self, filepointer,nCol=10)
444
445    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
446        'Read the file'
447        filepointer.seek(0)
448        try:
449            for line,S in enumerate(filepointer):
450                self.errors = '  Error reading line '+str(line+1)
451                if S[0] in ['#','(']: continue       #ignore comments & fortran format line
452                data = S.split()
453                h,k,l,Fo,sigFo,bN,wave,x,x,tbar = data[:10]  #bN = 1..., 6 dir cos next                   
454                h,k,l = [int(h),int(k),int(l)]
455                if not any([h,k,l]):
456                    break
457                Fo = float(Fo)
458                sigFo = float(sigFo)
459                wave = float(wave)
460                tbar = float(tbar)
461                if len(self.Banks):
462                    self.Banks[int(bN)-1]['RefDict']['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
463                else:
464                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
465                    self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
466            if len(self.Banks):
467                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
468                for Bank in self.Banks:
469                    Bank['RefDict']['RefList'] = np.array(Bank['RefDict']['RefList'])
470                    Bank['RefDict']['Type'] = 'SNT'                   
471                    Bank['RefDict']['Super'] = 0        #for now                   
472            else:
473                self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
474                self.RefDict['Type'] = 'SNT'
475                self.RefDict['Super'] = 0   #for now
476                self.errors = 'Error after reading reflections (unexpected!)'
477                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
478            return True
479        except Exception as detail:
480            self.errors += '\n  '+str(detail)
481            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
482            import traceback
483            traceback.print_exc(file=sys.stdout)
484            return False
485
486class ISIS_SXD_INT_ReaderClass(G2IO.ImportStructFactor):
487    'Routines to import neutron TOF F**2, sig(F**2) reflections from a ISIS int file'
488    def __init__(self):
489        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
490            formatName = u'Neutron SXD TOF HKL F2'
491            longFormatName = u'Neutron SXD TOF [hkl, Fo2, sig(Fo2),...] Structure factor text file'
492        else:
493            formatName = u'Neutron SXD TOF HKL F\u00b2'
494            longFormatName = u'Neutron SXD TOF [hkl, Fo\u00b2, sig(Fo\u00b2),...] Structure factor text file'
495        super(self.__class__,self).__init__( # fancy way to self-reference
496            extensionlist=('.int','.INT'),
497            strictExtension=False,
498            formatName=formatName,
499            longFormatName=longFormatName)
500
501    def ContentsValidator(self, filepointer):
502        'Make sure file contains the expected columns on numbers & count number of data blocks - "Banks"'
503        oldNo = -1
504        for line,S in enumerate(filepointer):
505            if not S:   #empty line terminates read
506                break
507            if S[0] == '#': continue       #ignore comments, if any
508            if S[0] == '(': continue        #ignore format line
509            bankNo = S.split()[5]
510            if bankNo != oldNo:
511                self.Banks.append({'RefDict':{'RefList':[],}})
512                oldNo = bankNo
513        filepointer.seek(0)
514        return ColumnValidator(self, filepointer,nCol=8)
515
516    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
517        'Read the file'
518        filepointer.seek(0)
519        try:
520            for line,S in enumerate(filepointer):
521                self.errors = '  Error reading line '+str(line+1)
522                if S[0] == '#': continue       #ignore comments, if any
523                if S[0] == '(': continue        #ignore the format line
524                data = S.split()
525                h,k,l,Fo,sigFo,bN,wave,x,x,tbar = data[:10]                   
526                h,k,l = [int(h),int(k),int(l)]
527                if not any([h,k,l]):
528                    break
529                Fo = float(Fo)
530                sigFo = float(sigFo)
531                wave = float(wave)
532                tbar = float(tbar)
533                if len(self.Banks):
534                    self.Banks[int(bN)-1]['RefDict']['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
535                else:
536                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
537                    self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,0,wave,tbar])
538            if len(self.Banks):
539                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
540                for Bank in self.Banks:
541                    Bank['RefDict']['RefList'] = np.array(Bank['RefDict']['RefList'])
542                    Bank['RefDict']['Type'] = 'SNT'                   
543                    Bank['RefDict']['Super'] = 0
544            else:
545                self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
546                self.RefDict['Type'] = 'SNT'
547                self.RefDict['Super'] = 0
548                self.errors = 'Error after reading reflections (unexpected!)'
549                self.UpdateParameters(Type='SNT',Wave=None) # histogram type
550            return True
551        except Exception as detail:
552            self.errors += '\n  '+str(detail)
553            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
554            import traceback
555            traceback.print_exc(file=sys.stdout)
556            return False
557
Note: See TracBrowser for help on using the repository browser.