source: trunk/imports/G2phase.py @ 2475

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

fix spin transform errors - now match old GSAS
fix spin flip import error from EXP file
fix bug on new phase after display on draw atoms (etc.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 25.1 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2016-09-21 15:01:41 +0000 (Wed, 21 Sep 2016) $
4# $Author: vondreele $
5# $Revision: 2475 $
6# $URL: trunk/imports/G2phase.py $
7# $Id: G2phase.py 2475 2016-09-21 15:01:41Z vondreele $
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: 2475 $")
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)[:2]
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            MagDmin = 1.0
243        elif NPhas[result] == '4':
244            Ptype = 'macromolecular'
245        elif NPhas[result] == '10':
246            Ptype = 'Pawley'
247        else:
248            raise self.ImportException("Phase type not recognized")           
249        for key in keyList:
250            if 'PNAM' in key:
251               PhaseName = EXPphase[key].strip()
252            elif 'ABC   ' in key:
253                abc = [float(EXPphase[key][:10]),float(EXPphase[key][10:20]),float(EXPphase[key][20:30])]                       
254            elif 'ANGLES' in key:
255                angles = [float(EXPphase[key][:10]),float(EXPphase[key][10:20]),float(EXPphase[key][20:30])]                                               
256            elif 'SG SYM' in key:
257                SpGrp = EXPphase[key][:15].strip()
258                E,SGData = G2spc.SpcGroup(SpGrp)
259                if E:
260                    SGData = G2IO.SGData # P 1 -- unlikely to need this!
261                    self.warnings += '\nThe GSAS space group was not interpreted(!) and has been set to "P 1".'
262                    self.warnings += "Change this in phase's General tab."                       
263            elif 'SPNFLP' in key:
264                SpnFlp = np.array([int(float(s)) for s in EXPphase[key].split()])
265                SpnFlp = np.where(SpnFlp==0,1,SpnFlp)
266                if SGData['SpGrp'][0] in ['A','B','C','I','R','F']:
267                    SpnFlp += [1,1,1,1]
268            elif 'MXDSTR' in key:
269                MagDmin = float(EXPphase[key][:10])               
270            elif 'OD    ' in key:
271                SHdata = EXPphase[key].split() # may not have all 9 values
272                SHvals = 9*[0]
273                for i in range(9):
274                    try:
275                        float(SHdata[i])
276                        SHvals[i] = SHdata[i]
277                    except:
278                        pass
279                textureData['Order'] = int(SHvals[0])
280                textureData['Model'] = shModels[int(SHvals[2])]
281                textureData['Sample omega'] = [False,float(SHvals[6])]
282                textureData['Sample chi'] = [False,float(SHvals[7])]
283                textureData['Sample phi'] = [False,float(SHvals[8])]
284                shNcof = int(SHvals[1])
285        Atoms = []
286        if Ptype in ['nuclear','magnetic',]:
287            for key in keyList:
288                if 'AT' in key:
289                    if key[11:] == 'A':
290                        S = EXPphase[key]
291                    elif key[11:] == 'B':
292                        S += EXPphase[key]
293                        Atom = [S[50:58].strip(),S[:10].strip().capitalize(),'',
294                            float(S[10:20]),float(S[20:30]),float(S[30:40]),
295                            float(S[40:50]),'',int(S[60:62]),S[130:131]]
296                        if Atom[9] == 'I':
297                            Atom += [float(S[68:78]),0.,0.,0.,0.,0.,0.]
298                        elif Atom[9] == 'A':
299                            Atom += [0.0,float(S[68:78]),float(S[78:88]),
300                                float(S[88:98]),float(S[98:108]),
301                                float(S[108:118]),float(S[118:128])]
302                        XYZ = Atom[3:6]
303                        Atom[7],Atom[8] = G2spc.SytSym(XYZ,SGData)[:2]
304                        if Ptype == 'magnetic':
305                            Atom = Atom[:7]+[0.,0.,0.]+Atom[7:]
306                        Atom.append(ran.randint(0,sys.maxint))
307                        Atoms.append(Atom)
308                    elif key[11:] == 'M' and key[6:8] == 'AT':
309                        S = EXPphase[key]
310                        Atoms[-1][7:10] = [float(S[:10]),float(S[10:20]),float(S[20:30])]
311        elif Ptype == 'macromolecular':
312            for key in keyList:
313                if 'AT' in key[6:8]:
314                    S = EXPphase[key]
315                    Atom = [S[56:60],S[50:54].strip().upper(),S[54:56],
316                        S[46:51].strip(),S[:8].strip().capitalize(),'',
317                        float(S[16:24]),float(S[24:32]),float(S[32:40]),
318                        float(S[8:16]),'1',1,'I',float(S[40:46]),0,0,0,0,0,0]
319                    XYZ = Atom[6:9]
320                    Atom[10],Atom[11] = G2spc.SytSym(XYZ,SGData)[:2]
321                    Atom.append(ran.randint(0,sys.maxint))
322                    Atoms.append(Atom)
323        Volume = G2lat.calc_V(G2lat.cell2A(abc+angles))
324        if shNcof:
325            shCoef = {}
326            nRec = [i+1 for i in range((shNcof-1)/6+1)]
327            for irec in nRec:
328                ODkey = keyList[0][:6]+'OD'+'%3dA'%(irec)
329                indx = EXPphase[ODkey].split()
330                ODkey = ODkey[:-1]+'B'
331                vals = EXPphase[ODkey].split()
332                for i,val in enumerate(vals):
333                    key = 'C(%s,%s,%s)'%(indx[3*i],indx[3*i+1],indx[3*i+2])
334                    shCoef[key] = float(val)
335            textureData['SH Coeff'] = [False,shCoef]
336        if not SGData:
337            raise self.ImportException("No space group found in phase")
338        if not abc:
339            raise self.ImportException("No cell lengths found in phase")
340        if not angles:
341            raise self.ImportException("No cell angles found in phase")
342        if not Atoms:
343            raise self.ImportException("No atoms found in phase")
344        Phase = G2IO.SetNewPhase(Name=PhaseName,SGData=SGData,cell=abc+angles+[Volume,])
345        general = Phase['General']
346        general['Type'] = Ptype
347        if general['Type'] =='macromolecular':
348            general['AtomPtrs'] = [6,4,10,12]
349        elif general['Type'] =='magnetic':
350            general['AtomPtrs'] = [3,1,10,12]
351            general['SGData']['SGSpin'] = SpnFlp
352            general['MagDmin'] = MagDmin   
353        else:   #nuclear
354            general['AtomPtrs'] = [3,1,7,9]   
355        general['SH Texture'] = textureData
356        Phase['Atoms'] = Atoms
357        return Phase
358
359class JANA_ReaderClass(G2IO.ImportPhase):
360    'Routine to import Phase information from a JANA2006 file'
361    def __init__(self):
362        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
363            extensionlist=('.m50','.M50'),
364            strictExtension=True,
365            formatName = 'JANA m50',
366            longFormatName = 'JANA2006 phase import'
367            )
368    def ContentsValidator(self, filepointer):
369        '''Taking a stab a validating a .m50 file
370        (look for cell & at least one atom)
371        '''
372        for i,l in enumerate(filepointer):
373            if l.startswith('cell'):
374                break
375        else:
376            self.errors = 'no cell record found'
377            return False
378        for i,l in enumerate(filepointer):
379            if l.startswith('spgroup'):
380                return True
381        self.errors = 'no spgroup record found after cell record'
382        return False
383       
384    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
385        'Read a m50 file using :meth:`ReadJANAPhase`'
386        try:
387            self.Phase = self.ReadJANAPhase(filename, ParentFrame)
388            return True
389        except Exception as detail:
390            self.errors += '\n  '+str(detail)
391            print 'JANA read error:',detail # for testing
392            traceback.print_exc(file=sys.stdout)
393            return False
394       
395    def ReadJANAPhase(self,filename,parent=None):
396        '''Read a phase from a JANA2006 m50 & m40 files.
397        '''
398        self.errors = 'Error opening file'
399        file = open(filename, 'Ur') #contains only cell & spcgroup
400        Phase = {}
401        Title = os.path.basename(filename)
402        Compnd = ''
403        Type = 'nuclear'
404        Atoms = []
405        Atypes = []
406        SuperVec = [[0,0,.1],False,4]
407        S = file.readline()
408        line = 1
409        SGData = None
410        SuperSg = ''
411        cell = None
412        nqi = 0
413        version = '2000'
414        while S:
415            self.errors = 'Error reading at line '+str(line)
416            if 'title' in S and S != 'title\n':
417                Title = S.split()[1]
418            elif 'Jana2006' in S:
419                self.warnings += '\nJana2006 file detected'
420                version = '2006'
421            elif 'cell' in S[:4]:
422                cell = S[5:].split()
423                cell=[float(cell[0]),float(cell[1]),float(cell[2]),
424                    float(cell[3]),float(cell[4]),float(cell[5])]
425                Volume = G2lat.calc_V(G2lat.cell2A(cell))
426                G,g = G2lat.cell2Gmat(cell)
427                ast = np.sqrt(np.diag(G))
428                Mast = np.multiply.outer(ast,ast)   
429               
430            elif 'spgroup' in S:
431                if 'X' in S:
432                    raise self.ImportException("Ad hoc Supersymmetry centering "+S+" not allowed in GSAS-II")           
433                SpGrp = S.split()[1]
434                SuperSg = ''
435                if '(' in SpGrp:    #supercell symmetry - split in 2
436                    SuperStr = SpGrp.split('(')
437                    SpGrp = SuperStr[0]
438                    SuperSg = '('+SuperStr[1]
439                SpGrpNorm = G2spc.StandardizeSpcName(SpGrp)
440                E,SGData = G2spc.SpcGroup(SpGrpNorm)
441                # space group processing failed, try to look up name in table
442                while E:
443                    print G2spc.SGErrors(E)
444                    dlg = wx.TextEntryDialog(parent,
445                        SpGrp[:-1]+' is invalid \nN.B.: make sure spaces separate axial fields in symbol',
446                        'ERROR in space group symbol','',style=wx.OK)
447                    if dlg.ShowModal() == wx.ID_OK:
448                        SpGrp = dlg.GetValue()
449                        E,SGData = G2spc.SpcGroup(SpGrp)
450                    else:
451                        SGData = G2IO.SGData # P 1
452                        self.warnings += '\nThe space group was not interpreted and has been set to "P 1".'
453                        self.warnings += "Change this in phase's General tab."           
454                    dlg.Destroy()
455                SGlines = G2spc.SGPrint(SGData)
456            elif 'qi' in S[:2]:
457                if nqi:
458                    raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
459                vec = S.split()[1:]
460                SuperVec = [[float(vec[i]) for i in range(3)],False,4]
461                nqi += 1
462            elif 'atom' in S[:4]:
463                Atypes.append(S.split()[1])
464            S = file.readline()
465            line += 1
466        file.close()
467        #read atoms from m40 file
468        if not SGData:
469            self.warnings += '\nThe space group was not read before atoms and has been set to "P 1". '
470            self.warnings += "Change this in phase's General tab."
471            SGData = G2IO.SGData # P 1
472        waveTypes = ['Fourier','Sawtooth','ZigZag',]
473        filename2 = os.path.splitext(filename)[0]+'.m40'
474        file2 = open(filename2,'Ur')
475        S = file2.readline()
476        line = 1
477        self.errors = 'Error reading at line '+str(line)
478        nAtoms = int(S.split()[0])
479        for i in range(4):
480            S = file2.readline()           
481        for i in range(nAtoms):
482            S1 = file2.readline()
483            S1N = S1.split()[-3:]   # no. occ, no. pos waves, no. ADP waves
484            S1N = [int(i) for i in S1N]
485            S1T = list(S1[60:63])
486            waveType = waveTypes[int(S1T[1])]
487            Spos = []
488            Sadp = []
489            Sfrac = []
490            Smag = []
491            XYZ = [float(S1[27:36]),float(S1[36:45]),float(S1[45:54])]
492            SytSym,Mult = G2spc.SytSym(XYZ,SGData)[:2]
493            aType = Atypes[int(S1[9:11])-1]
494            Name = S1[:8].strip()
495            if S1[11:15].strip() == '1':
496                S2 = file2.readline()
497                Uiso = S2[:9]
498                if version == '2000':
499                    Uiso = R2pisq*float(Uiso)/4.      #Biso -> Uiso
500                Uij = [0,0,0,0,0,0]
501                IA = 'I'
502            elif S1[11:15].strip() == '2':
503                S2 = file2.readline()
504                IA = 'A'
505                Uiso = 0.
506                Uij = [float(S2[:9]),float(S2[9:18]),float(S2[18:27]),
507                    float(S2[27:36]),float(S2[36:45]),float(S2[45:54])] #Uij in Jana2006!
508                if version == '2000':
509                    Uij = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(Uij)/Mast) #these things are betaij in Jana2000! need to convert to Uij
510            for i in range(S1N[0]):
511                if not i:
512                    FS = file2.readline()
513                    Sfrac.append(FS[:9])    #'O' or 'delta' = 'length' for crenel
514                    if int(S1T[0]):  #"", "Legendre" or "Xharm" in 18:27 for "crenel"!
515                        waveType = 'Crenel/Fourier' #all waves 'Fourier' no other choice
516                Sfrac.append(file2.readline()[:18]) #if not crenel = Osin & Ocos
517                # else Osin & Ocos except last one is X40 = 'Center'
518            for i in range(S1N[1]): 
519                Spos.append(file2.readline()[:54])
520            for i in range(S1N[2]):
521                Sadp.append(file2.readline()[:54]+file2.readline())
522            if sum(S1N):    #if any waves: skip mystery line?
523                file2.readline()
524            for i,it in enumerate(Sfrac):
525                print i,it
526                if not i:
527                    if 'Crenel' in waveType:
528                        vals = [float(it),float(Sfrac[-1][:9])]
529                    else:
530                        vals = [float(it),]
531                else:
532                    vals = [float(it[:9]),float(it[9:18])]
533                if 'Crenel' in waveType and i == len(Sfrac)-1:
534                    del Sfrac[-1]
535                    break               
536                Sfrac[i] = [vals,False]
537                print Sfrac[i]
538            for i,it in enumerate(Spos):
539                if waveType in ['Sawtooth',] and not i:
540                    vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36])]
541                else:
542                    vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36]),float(it[36:45]),float(it[45:54])]
543                Spos[i] = [vals,False]
544            for i,it in enumerate(Sadp):
545                vals = [float(it[:9]),float(it[9:18]),float(it[18:27]),float(it[27:36]),float(it[36:45]),float(it[45:54]),
546                    float(it[54:63]),float(it[63:72]),float(it[72:81]),float(it[81:90]),float(it[90:99]),float(it[99:108])]
547                #these are betaij modulations in Jana2000! need to convert to Uij modulations
548                if version == '2000':               
549                    vals[:6] = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(vals[:6])/Mast)    #convert sin bij to Uij
550                    vals[6:] = R2pisq*G2lat.UijtoU6(G2lat.U6toUij(vals[6:])/Mast)    #convert cos bij to Uij
551                Sadp[i] = [vals,False]
552            Atom = [Name,aType,'',XYZ[0],XYZ[1],XYZ[2],1.0,SytSym,Mult,IA,Uiso]
553            Atom += Uij
554            Atom.append(ran.randint(0,sys.maxint))
555            Atom.append([])
556            Atom.append([])
557            Atom.append({'SS1':{'waveType':waveType,'Sfrac':Sfrac,'Spos':Spos,'Sadp':Sadp,'Smag':Smag}})    #SS2 is for (3+2), etc.
558            Atoms.append(Atom)
559        file2.close()
560        self.errors = 'Error after read complete'
561        if not SGData:
562            raise self.ImportException("No space group (spcgroup entry) found")
563        if not cell:
564            raise self.ImportException("No cell found")
565        Phase = G2IO.SetNewPhase(Name=Title,SGData=SGData,cell=cell+[Volume,])
566        Phase['General']['Type'] = Type
567        Phase['General']['Modulated'] = True
568        Phase['General']['Super'] = nqi
569        Phase['General']['SuperVec'] = SuperVec
570        Phase['General']['SuperSg'] = SuperSg
571        if SuperSg:
572            Phase['General']['SSGData'] = G2spc.SSpcGroup(SGData,SuperSg)[1]
573        Phase['General']['AtomPtrs'] = [3,1,7,9]
574        Phase['Atoms'] = Atoms
575        return Phase
Note: See TracBrowser for help on using the repository browser.