source: trunk/imports/G2phase.py @ 2465

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

change spin flip from red/black to -1/1

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 24.7 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2016-08-04 01:14:47 +0000 (Thu, 04 Aug 2016) $
4# $Author: toby $
5# $Revision: 2406 $
6# $URL: trunk/imports/G2phase.py $
7# $Id: G2phase.py 2406 2016-08-04 01:14:47Z toby $
8########### SVN repository information ###################
9#
10'''
11*Module G2phase: PDB, .EXP & JANA m40,m50*
12-------------------------------------------
13
14A set of short routines to read in phases using routines that were
15previously implemented in GSAS-II: PDB, GSAS .EXP and JANA m40-m50 file formats
16
17'''
18
19import sys
20import os.path
21import math
22import random as ran
23import traceback
24import numpy as np
25import wx
26import GSASIIIO as G2IO
27import GSASIIspc as G2spc
28import GSASIIlattice as G2lat
29import GSASIIpath
30GSASIIpath.SetVersionNumber("$Revision: 2406 $")
31R2pisq = 1./(2.*np.pi**2)
32
33class PDB_ReaderClass(G2IO.ImportPhase):
34    'Routine to import Phase information from a PDB file'
35    def __init__(self):
36        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
37            extensionlist=('.pdb','.ent','.PDB','.ENT'),
38            strictExtension=True,
39            formatName = 'PDB',
40            longFormatName = 'Original Protein Data Bank (.pdb file) import'
41            )
42    def ContentsValidator(self, filepointer):
43        '''Taking a stab a validating a PDB file
44        (look for cell & at least one atom)
45        '''
46        for i,l in enumerate(filepointer):
47            if l.startswith('CRYST1'):
48                break
49        else:
50            self.errors = 'no CRYST1 record found'
51            return False
52        for i,l in enumerate(filepointer):
53            if l.startswith('ATOM'):
54                return True
55        self.errors = 'no ATOM records found after CRYST1 record'
56        return False
57
58    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
59        'Read a PDF file using :meth:`ReadPDBPhase`'
60        try:
61            self.Phase = self.ReadPDBPhase(filename, ParentFrame)
62            return True
63        except Exception as detail:
64            self.errors += '\n  '+str(detail)
65            print 'PDB read error:',detail # for testing
66            traceback.print_exc(file=sys.stdout)
67            return False
68       
69    def ReadPDBPhase(self,filename,parent=None):
70        '''Read a phase from a PDB file.
71        '''
72        EightPiSq = 8.*math.pi**2
73        self.errors = 'Error opening file'
74        file = open(filename, 'Ur')
75        Phase = {}
76        Title = ''
77        Compnd = ''
78        Atoms = []
79        A = np.zeros(shape=(3,3))
80        S = file.readline()
81        line = 1
82        SGData = None
83        cell = None
84        while S:
85            self.errors = 'Error reading at line '+str(line)
86            Atom = []
87            if 'TITLE' in S[:5]:
88                Title = S[10:72].strip()
89            elif 'COMPND    ' in S[:10]:
90                Compnd = S[10:72].strip()
91            elif 'CRYST' in S[:5]:
92                abc = S[7:34].split()
93                angles = S[34:55].split()
94                cell=[float(abc[0]),float(abc[1]),float(abc[2]),
95                    float(angles[0]),float(angles[1]),float(angles[2])]
96                Volume = G2lat.calc_V(G2lat.cell2A(cell))
97                AA,AB = G2lat.cell2AB(cell)
98                SpGrp = S[55:65]
99                E,SGData = G2spc.SpcGroup(SpGrp)
100                # space group processing failed, try to look up name in table
101                if E:
102                    SpGrpNorm = G2spc.StandardizeSpcName(SpGrp)
103                    if SpGrpNorm:
104                        E,SGData = G2spc.SpcGroup(SpGrpNorm)
105                while E:
106                    print G2spc.SGErrors(E)
107                    dlg = wx.TextEntryDialog(parent,
108                        SpGrp[:-1]+' is invalid \nN.B.: make sure spaces separate axial fields in symbol',
109                        'ERROR in space group symbol','',style=wx.OK)
110                    if dlg.ShowModal() == wx.ID_OK:
111                        SpGrp = dlg.GetValue()
112                        E,SGData = G2spc.SpcGroup(SpGrp)
113                    else:
114                        SGData = G2IO.SGData # P 1
115                        self.warnings += '\nThe space group was not interpreted and has been set to "P 1".'
116                        self.warnings += "Change this in phase's General tab."           
117                    dlg.Destroy()
118                SGlines = G2spc.SGPrint(SGData)
119                for l in SGlines: print l
120            elif 'SCALE' in S[:5]:
121                V = S[10:41].split()
122                A[int(S[5])-1] = [float(V[0]),float(V[1]),float(V[2])]
123            elif 'ATOM' in S[:4] or 'HETATM' in S[:6]:
124                if not SGData:
125                    self.warnings += '\nThe space group was not read before atoms and has been set to "P 1". '
126                    self.warnings += "Change this in phase's General tab."
127                    SGData = G2IO.SGData # P 1
128                XYZ = [float(S[31:39]),float(S[39:47]),float(S[47:55])]
129                XYZ = np.inner(AB,XYZ)
130                XYZ = np.where(abs(XYZ)<0.00001,0,XYZ)
131                SytSym,Mult = G2spc.SytSym(XYZ,SGData)
132                Uiso = float(S[61:67])/EightPiSq
133                Type = S[12:14].lower()
134                if Type[0] in '123456789':
135                    Type = Type[1:]
136                Atom = [S[22:27].strip(),S[17:20].upper(),S[20:22],
137                    S[12:17].strip(),Type.strip().capitalize(),'',XYZ[0],XYZ[1],XYZ[2],
138                    float(S[55:61]),SytSym,Mult,'I',Uiso,0,0,0,0,0,0]
139                S = file.readline()
140                line += 1
141                if 'ANISOU' in S[:6]:
142                    Uij = S[30:72].split()
143                    Uij = [float(Uij[0])/10000.,float(Uij[1])/10000.,float(Uij[2])/10000.,
144                        float(Uij[3])/10000.,float(Uij[4])/10000.,float(Uij[5])/10000.]
145                    Atom = Atom[:14]+Uij
146                    Atom[12] = 'A'
147                Atom.append(ran.randint(0,sys.maxint))
148                Atoms.append(Atom)
149            S = file.readline()
150            line += 1
151        file.close()
152        self.errors = 'Error after read complete'
153        if Title:
154            PhaseName = Title
155        elif Compnd:
156            PhaseName = Compnd
157        else:
158            PhaseName = 'None'
159        if not SGData:
160            raise self.ImportException("No space group (CRYST entry) found")
161        if not cell:
162            raise self.ImportException("No cell (CRYST entry) found")
163        Phase = G2IO.SetNewPhase(Name=PhaseName,SGData=SGData,cell=cell+[Volume,])
164        Phase['General']['Type'] = 'macromolecular'
165        Phase['General']['AtomPtrs'] = [6,4,10,12]
166        Phase['Atoms'] = Atoms
167        return Phase
168
169class EXP_ReaderClass(G2IO.ImportPhase):
170    'Routine to import Phase information from GSAS .EXP files'
171    def __init__(self):
172        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
173            extensionlist=('.EXP','.exp'),
174            strictExtension=True,
175            formatName = 'GSAS .EXP',
176            longFormatName = 'GSAS Experiment (.EXP file) import'
177            )
178       
179    def ContentsValidator(self, filepointer):
180        'Look for a VERSION tag in 1st line' 
181        if filepointer.read(13) == '     VERSION ':
182            return True
183        self.errors = 'File does not begin with VERSION tag'
184        return False
185
186    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
187        'Read a phase from a GSAS .EXP file using :meth:`ReadEXPPhase`'
188        try:
189            self.Phase = self.ReadEXPPhase(ParentFrame, filepointer)
190            return True
191        except Exception as detail:
192            self.errors += '\n  '+str(detail)
193            print 'GSAS .EXP read error:',detail # for testing
194            traceback.print_exc(file=sys.stdout)
195            return False
196
197    def ReadEXPPhase(self, G2frame,filepointer):
198        '''Read a phase from a GSAS .EXP file.
199        '''
200        shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
201        textureData = {'Order':0,'Model':'cylindrical','Sample omega':[False,0.0],
202            'Sample chi':[False,0.0],'Sample phi':[False,0.0],'SH Coeff':[False,{}],
203            'SHShow':False,'PFhkl':[0,0,1],'PFxyz':[0,0,1],'PlotType':'Pole figure'}
204        shNcof = 0
205        S = 1
206        NPhas = []
207        Expr = [{},{},{},{},{},{},{},{},{}] # GSAS can have at most 9 phases
208        for line,S in enumerate(filepointer):
209            self.errors = 'Error reading at line '+str(line+1)
210            if 'EXPR NPHAS' in S[:12]:
211                Num = S[12:-1].count('0')
212                NPhas = S[12:-1].split()
213            if 'CRS' in S[:3]:
214                N = int(S[3:4])-1
215                Expr[N][S[:12]] = S[12:-1]
216        PNames = []
217        if not NPhas:
218            raise self.ImportException("No EXPR NPHAS record found")
219        self.errors = 'Error interpreting file'
220        for n,N in enumerate(NPhas):
221            if N != '0':
222                result = n
223                key = 'CRS'+str(n+1)+'    PNAM'
224                PNames.append(Expr[n][key])
225        if len(PNames) == 0:
226            raise self.ImportException("No phases found")           
227        elif len(PNames) > 1:
228            dlg = wx.SingleChoiceDialog(G2frame, 'Which phase to read?', 'Read phase data', PNames, wx.CHOICEDLG_STYLE)
229            try:
230                if dlg.ShowModal() == wx.ID_OK:
231                    result = dlg.GetSelection() # I think this breaks is there are skipped phases. Cant this happen?
232            finally:
233                dlg.Destroy()       
234        EXPphase = Expr[result]
235        keyList = EXPphase.keys()
236        keyList.sort()
237        SGData = {}
238        if NPhas[result] == '1':
239            Ptype = 'nuclear'
240        elif NPhas[result] in ['2','3']:
241            Ptype = 'magnetic'
242        elif NPhas[result] == '4':
243            Ptype = 'macromolecular'
244        elif NPhas[result] == '10':
245            Ptype = 'Pawley'
246        else:
247            raise self.ImportException("Phase type not recognized")           
248        for key in keyList:
249            if 'PNAM' in key:
250               PhaseName = EXPphase[key].strip()
251            elif 'ABC   ' in key:
252                abc = [float(EXPphase[key][:10]),float(EXPphase[key][10:20]),float(EXPphase[key][20:30])]                       
253            elif 'ANGLES' in key:
254                angles = [float(EXPphase[key][:10]),float(EXPphase[key][10:20]),float(EXPphase[key][20:30])]                                               
255            elif 'SG SYM' in key:
256                SpGrp = EXPphase[key][:15].strip()
257                E,SGData = G2spc.SpcGroup(SpGrp)
258                if E:
259                    SGData = G2IO.SGData # P 1 -- unlikely to need this!
260                    self.warnings += '\nThe GSAS space group was not interpreted(!) and has been set to "P 1".'
261                    self.warnings += "Change this in phase's General tab."                       
262            elif 'SPNFLP' in key:
263                SpnFlp = [int(s) for s in EXPphase[key].split()]               
264            elif 'OD    ' in key:
265                SHdata = EXPphase[key].split() # may not have all 9 values
266                SHvals = 9*[0]
267                for i in range(9):
268                    try:
269                        float(SHdata[i])
270                        SHvals[i] = SHdata[i]
271                    except:
272                        pass
273                textureData['Order'] = int(SHvals[0])
274                textureData['Model'] = shModels[int(SHvals[2])]
275                textureData['Sample omega'] = [False,float(SHvals[6])]
276                textureData['Sample chi'] = [False,float(SHvals[7])]
277                textureData['Sample phi'] = [False,float(SHvals[8])]
278                shNcof = int(SHvals[1])
279        Atoms = []
280        if Ptype in ['nuclear','magnetic',]:
281            for key in keyList:
282                if 'AT' in key:
283                    if key[11:] == 'A':
284                        S = EXPphase[key]
285                    elif key[11:] == 'B':
286                        S += EXPphase[key]
287                        Atom = [S[50:58].strip(),S[:10].strip().capitalize(),'',
288                            float(S[10:20]),float(S[20:30]),float(S[30:40]),
289                            float(S[40:50]),'',int(S[60:62]),S[130:131]]
290                        if Atom[9] == 'I':
291                            Atom += [float(S[68:78]),0.,0.,0.,0.,0.,0.]
292                        elif Atom[9] == 'A':
293                            Atom += [0.0,float(S[68:78]),float(S[78:88]),
294                                float(S[88:98]),float(S[98:108]),
295                                float(S[108:118]),float(S[118:128])]
296                        XYZ = Atom[3:6]
297                        Atom[7],Atom[8] = G2spc.SytSym(XYZ,SGData)
298                        Atom.append(ran.randint(0,sys.maxint))
299                        Atoms.append(Atom)
300                    elif key[11:] == 'M' and key[6:8] == 'AT':
301                        S = EXPphase[key]
302                        Mag = [float(S[:10]),float(S[10:20]),float(S[20:30])]
303                        Atoms[-1] = Atoms[-1][:7]+Mag+Atoms[-1][7:]
304        elif Ptype == 'macromolecular':
305            for key in keyList:
306                if 'AT' in key[6:8]:
307                    S = EXPphase[key]
308                    Atom = [S[56:60],S[50:54].strip().upper(),S[54:56],
309                        S[46:51].strip(),S[:8].strip().capitalize(),'',
310                        float(S[16:24]),float(S[24:32]),float(S[32:40]),
311                        float(S[8:16]),'1',1,'I',float(S[40:46]),0,0,0,0,0,0]
312                    XYZ = Atom[6:9]
313                    Atom[10],Atom[11] = G2spc.SytSym(XYZ,SGData)
314                    Atom.append(ran.randint(0,sys.maxint))
315                    Atoms.append(Atom)
316        Volume = G2lat.calc_V(G2lat.cell2A(abc+angles))
317        if shNcof:
318            shCoef = {}
319            nRec = [i+1 for i in range((shNcof-1)/6+1)]
320            for irec in nRec:
321                ODkey = keyList[0][:6]+'OD'+'%3dA'%(irec)
322                indx = EXPphase[ODkey].split()
323                ODkey = ODkey[:-1]+'B'
324                vals = EXPphase[ODkey].split()
325                for i,val in enumerate(vals):
326                    key = 'C(%s,%s,%s)'%(indx[3*i],indx[3*i+1],indx[3*i+2])
327                    shCoef[key] = float(val)
328            textureData['SH Coeff'] = [False,shCoef]
329        if not SGData:
330            raise self.ImportException("No space group found in phase")
331        if not abc:
332            raise self.ImportException("No cell lengths found in phase")
333        if not angles:
334            raise self.ImportException("No cell angles found in phase")
335        if not Atoms:
336            raise self.ImportException("No atoms found in phase")
337        Phase = G2IO.SetNewPhase(Name=PhaseName,SGData=SGData,cell=abc+angles+[Volume,])
338        general = Phase['General']
339        general['Type'] = Ptype
340        if general['Type'] =='macromolecular':
341            general['AtomPtrs'] = [6,4,10,12]
342        elif general['Type'] =='magnetic':
343            general['AtomPtrs'] = [3,1,10,12]
344            general['SGData']['SGSpin'] = SpnFlp   
345        else:   #nuclear
346            general['AtomPtrs'] = [3,1,7,9]   
347        general['SH Texture'] = textureData
348        Phase['Atoms'] = Atoms
349        return Phase
350
351class JANA_ReaderClass(G2IO.ImportPhase):
352    'Routine to import Phase information from a JANA2006 file'
353    def __init__(self):
354        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
355            extensionlist=('.m50','.M50'),
356            strictExtension=True,
357            formatName = 'JANA m50',
358            longFormatName = 'JANA2006 phase import'
359            )
360    def ContentsValidator(self, filepointer):
361        '''Taking a stab a validating a .m50 file
362        (look for cell & at least one atom)
363        '''
364        for i,l in enumerate(filepointer):
365            if l.startswith('cell'):
366                break
367        else:
368            self.errors = 'no cell record found'
369            return False
370        for i,l in enumerate(filepointer):
371            if l.startswith('spgroup'):
372                return True
373        self.errors = 'no spgroup record found after cell record'
374        return False
375       
376    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
377        'Read a m50 file using :meth:`ReadJANAPhase`'
378        try:
379            self.Phase = self.ReadJANAPhase(filename, ParentFrame)
380            return True
381        except Exception as detail:
382            self.errors += '\n  '+str(detail)
383            print 'JANA read error:',detail # for testing
384            traceback.print_exc(file=sys.stdout)
385            return False
386       
387    def ReadJANAPhase(self,filename,parent=None):
388        '''Read a phase from a JANA2006 m50 & m40 files.
389        '''
390        self.errors = 'Error opening file'
391        file = open(filename, 'Ur') #contains only cell & spcgroup
392        Phase = {}
393        Title = os.path.basename(filename)
394        Compnd = ''
395        Type = 'nuclear'
396        Atoms = []
397        Atypes = []
398        SuperVec = [[0,0,.1],False,4]
399        S = file.readline()
400        line = 1
401        SGData = None
402        SuperSg = ''
403        cell = None
404        nqi = 0
405        version = '2000'
406        while S:
407            self.errors = 'Error reading at line '+str(line)
408            if 'title' in S and S != 'title\n':
409                Title = S.split()[1]
410            elif 'Jana2006' in S:
411                self.warnings += '\nJana2006 file detected'
412                version = '2006'
413            elif 'cell' in S[:4]:
414                cell = S[5:].split()
415                cell=[float(cell[0]),float(cell[1]),float(cell[2]),
416                    float(cell[3]),float(cell[4]),float(cell[5])]
417                Volume = G2lat.calc_V(G2lat.cell2A(cell))
418                G,g = G2lat.cell2Gmat(cell)
419                ast = np.sqrt(np.diag(G))
420                Mast = np.multiply.outer(ast,ast)   
421               
422            elif 'spgroup' in S:
423                if 'X' in S:
424                    raise self.ImportException("Ad hoc Supersymmetry centering "+S+" not allowed in GSAS-II")           
425                SpGrp = S.split()[1]
426                SuperSg = ''
427                if '(' in SpGrp:    #supercell symmetry - split in 2
428                    SuperStr = SpGrp.split('(')
429                    SpGrp = SuperStr[0]
430                    SuperSg = '('+SuperStr[1]
431                SpGrpNorm = G2spc.StandardizeSpcName(SpGrp)
432                E,SGData = G2spc.SpcGroup(SpGrpNorm)
433                # space group processing failed, try to look up name in table
434                while E:
435                    print G2spc.SGErrors(E)
436                    dlg = wx.TextEntryDialog(parent,
437                        SpGrp[:-1]+' is invalid \nN.B.: make sure spaces separate axial fields in symbol',
438                        'ERROR in space group symbol','',style=wx.OK)
439                    if dlg.ShowModal() == wx.ID_OK:
440                        SpGrp = dlg.GetValue()
441                        E,SGData = G2spc.SpcGroup(SpGrp)
442                    else:
443                        SGData = G2IO.SGData # P 1
444                        self.warnings += '\nThe space group was not interpreted and has been set to "P 1".'
445                        self.warnings += "Change this in phase's General tab."           
446                    dlg.Destroy()
447                SGlines = G2spc.SGPrint(SGData)
448            elif 'qi' in S[:2]:
449                if nqi:
450                    raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
451                vec = S.split()[1:]
452                SuperVec = [[float(vec[i]) for i in range(3)],False,4]
453                nqi += 1
454            elif 'atom' in S[:4]:
455                Atypes.append(S.split()[1])
456            S = file.readline()
457            line += 1
458        file.close()
459        #read atoms from m40 file
460        if not SGData:
461            self.warnings += '\nThe space group was not read before atoms and has been set to "P 1". '
462            self.warnings += "Change this in phase's General tab."
463            SGData = G2IO.SGData # P 1
464        waveTypes = ['Fourier','Sawtooth','ZigZag',]
465        filename2 = os.path.splitext(filename)[0]+'.m40'
466        file2 = open(filename2,'Ur')
467        S = file2.readline()
468        line = 1
469        self.errors = 'Error reading at line '+str(line)
470        nAtoms = int(S.split()[0])
471        for i in range(4):
472            S = file2.readline()           
473        for i in range(nAtoms):
474            S1 = file2.readline()
475            S1N = S1.split()[-3:]   # no. occ, no. pos waves, no. ADP waves
476            S1N = [int(i) for i in S1N]
477            S1T = list(S1[60:63])
478            waveType = waveTypes[int(S1T[1])]
479            Spos = []
480            Sadp = []
481            Sfrac = []
482            Smag = []
483            XYZ = [float(S1[27:36]),float(S1[36:45]),float(S1[45:54])]
484            SytSym,Mult = G2spc.SytSym(XYZ,SGData)
485            aType = Atypes[int(S1[9:11])-1]
486            Name = S1[:8].strip()
487            if S1[11:15].strip() == '1':
488                S2 = file2.readline()
489                Uiso = S2[:9]
490                if version == '2000':
491                    Uiso = R2pisq*float(Uiso)/4.      #Biso -> Uiso
492                Uij = [0,0,0,0,0,0]
493                IA = 'I'
494            elif S1[11:15].strip() == '2':
495                S2 = file2.readline()
496                IA = 'A'
497                Uiso = 0.
498                Uij = [float(S2[:9]),float(S2[9:18]),float(S2[18:27]),
499                    float(S2[27:36]),float(S2[36:45]),float(S2[45:54])] #Uij in Jana2006!
500                if version == '2000':
501                    Uij = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(Uij)/Mast) #these things are betaij in Jana2000! need to convert to Uij
502            for i in range(S1N[0]):
503                if not i:
504                    FS = file2.readline()
505                    Sfrac.append(FS[:9])    #'O' or 'delta' = 'length' for crenel
506                    if int(S1T[0]):  #"", "Legendre" or "Xharm" in 18:27 for "crenel"!
507                        waveType = 'Crenel/Fourier' #all waves 'Fourier' no other choice
508                Sfrac.append(file2.readline()[:18]) #if not crenel = Osin & Ocos
509                # else Osin & Ocos except last one is X40 = 'Center'
510            for i in range(S1N[1]): 
511                Spos.append(file2.readline()[:54])
512            for i in range(S1N[2]):
513                Sadp.append(file2.readline()[:54]+file2.readline())
514            if sum(S1N):    #if any waves: skip mystery line?
515                file2.readline()
516            for i,it in enumerate(Sfrac):
517                print i,it
518                if not i:
519                    if 'Crenel' in waveType:
520                        vals = [float(it),float(Sfrac[-1][:9])]
521                    else:
522                        vals = [float(it),]
523                else:
524                    vals = [float(it[:9]),float(it[9:18])]
525                if 'Crenel' in waveType and i == len(Sfrac)-1:
526                    del Sfrac[-1]
527                    break               
528                Sfrac[i] = [vals,False]
529                print Sfrac[i]
530            for i,it in enumerate(Spos):
531                if waveType in ['Sawtooth',] and not i:
532                    vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36])]
533                else:
534                    vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36]),float(it[36:45]),float(it[45:54])]
535                Spos[i] = [vals,False]
536            for i,it in enumerate(Sadp):
537                vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36]),float(it[36:45]),float(it[45:54]),
538                    float(it[54:63]),float(it[63:72]),float(it[72:81]),float(it[81:90]),float(it[90:99]),float(it[99:108])]
539                #these are betaij modulations in Jana2000! need to convert to Uij modulations
540                if version == '2000':               
541                    vals[:6] = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(vals[:6])/Mast)    #convert sin bij to Uij
542                    vals[6:] = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(vals[6:])/Mast)    #convert cos bij to Uij
543                Sadp[i] = [vals,False]
544            Atom = [Name,aType,'',XYZ[0],XYZ[1],XYZ[2],1.0,SytSym,Mult,IA,Uiso]
545            Atom += Uij
546            Atom.append(ran.randint(0,sys.maxint))
547            Atom.append([])
548            Atom.append([])
549            Atom.append({'SS1':{'waveType':waveType,'Sfrac':Sfrac,'Spos':Spos,'Sadp':Sadp,'Smag':Smag}})    #SS2 is for (3+2), etc.
550            Atoms.append(Atom)
551        file2.close()
552        self.errors = 'Error after read complete'
553        if not SGData:
554            raise self.ImportException("No space group (spcgroup entry) found")
555        if not cell:
556            raise self.ImportException("No cell found")
557        Phase = G2IO.SetNewPhase(Name=Title,SGData=SGData,cell=cell+[Volume,])
558        Phase['General']['Type'] = Type
559        Phase['General']['Modulated'] = True
560        Phase['General']['Super'] = nqi
561        Phase['General']['SuperVec'] = SuperVec
562        Phase['General']['SuperSg'] = SuperSg
563        if SuperSg:
564            Phase['General']['SSGData'] = G2spc.SSpcGroup(SGData,SuperSg)[1]
565        Phase['General']['AtomPtrs'] = [3,1,7,9]
566        Phase['Atoms'] = Atoms
567        return Phase
Note: See TracBrowser for help on using the repository browser.