source: trunk/imports/G2phase.py @ 2486

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

fix mag form factor lookup - some aren't chemical valences (e.g. Fe+4)
fix mag form factor periodic table - nonmagnetic atoms now not shown
fix powder reflection mark & diff curve placement issues
fix issues with mag structure drawings - fill unit cell, etc.
fix structure transform to make magnetic cells (still needs making of constraints)
fix problem of mustrain & hstrain coeff changes with change in space group
add print to file of covariance matrix - user request
fix magnetic moment site symmetry restrictions
work on mag structure factor calcs.
change EXP file importer to ignore magnetic symmetry from GSAS

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