Changeset 2287 for trunk/imports/G2phase_INS.py
- Timestamp:
- May 23, 2016 11:53:59 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/imports/G2phase_INS.py
r2286 r2287 30 30 def __init__(self): 31 31 super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__ 32 extensionlist=('.ins','.INS' ),32 extensionlist=('.ins','.INS','.res','.RES'), 33 33 strictExtension=True, 34 formatName = 'SHELX ins ',35 longFormatName = 'SHELX input (*.ins ) file import'34 formatName = 'SHELX ins,res', 35 longFormatName = 'SHELX input (*.ins, *.res) file import' 36 36 ) 37 37 … … 61 61 '''Read a phase from a INS file. 62 62 ''' 63 Shelx = ['TITL','CELL','ZERR','LATT','SYMM','SFAC','DISP','UNIT','LAUE','EADP', 64 'MORE','TIME','END ','HKLF','OMIT','SHEL','BASF','TWIN','EXTI','SWAT', 65 'HOPE','MERG','SPEC','RESI','RTAB','MPLA','HFIX','MOVE','ANIS','AFIX', 66 'FRAG','FEND','EXYZ','EDAP','EQIV','CONN','PART','BIND','FREE','DFIX','DANG', 67 'BUMP','SAME','SADI','CHIV','FLAT','DELU','SIMU','DEFS','ISOR','NCSY', 68 'SUMP','L.S.','CGLS','BLOC','DAMP','STIR','WGHT','FVAR','BOND','CONF','MPLA', 69 'HTAB','LIST','ACTA','SIZE','TEMP','WPDB','FMAP','GRID','PLAN','MOLE'] 63 70 EightPiSq = 8.*math.pi**2 64 71 self.errors = 'Error opening file' … … 81 88 Atom = [] 82 89 Aindx = [ch in numbs for ch in S[:4]] #False for all letters 83 if 'TITL' in S[:4] :90 if 'TITL' in S[:4].upper(): 84 91 Title = S[4:72].strip() 85 elif 'CELL' in S[:4]: 86 abc = S[12:40].split() 87 angles = S[40:64].split() 92 elif not S.strip(): 93 pass 94 elif 'CELL' in S[:4].upper(): 95 cellRec = S.split() 96 abc = cellRec[2:5] 97 angles = cellRec[5:8] 88 98 cell=[float(abc[0]),float(abc[1]),float(abc[2]), 89 99 float(angles[0]),float(angles[1]),float(angles[2])] … … 94 104 self.warnings += '\nThe space group is not given in an ins file and has been set to "P 1".' 95 105 self.warnings += "\nChange this in phase's General tab; NB: it might be in the Phase name." 96 elif S[:4] in 'SFAC':106 elif S[:4].upper() in 'SFAC': 97 107 aTypes = S[4:].split() 98 108 if 'H' in aTypes: … … 101 111 elif S[0] == 'Q': 102 112 pass 103 elif np.any(Aindx) or S[:4].strip() in aTypes: #this will find an atom record! 104 try: 105 iNum = Aindx.index(True) 106 except ValueError: 107 iNum = 4 108 Atype = S[:iNum].strip() 109 Aname = S[:4] 110 x,y,z = S[9:45].split() 113 elif '\x1a' in S[:4]: 114 pass 115 elif S[:3].upper() == 'REM': 116 pass 117 elif S[:4].upper() not in Shelx: #this will find an atom record! 118 AtRec = S.split() 119 Atype = aTypes[int(AtRec[1])-1] 120 Aname = AtRec[0] 121 Afrac = abs(float(AtRec[5]))%10. 122 x,y,z = AtRec[2:5] 111 123 XYZ = np.array([float(x),float(y),float(z)]) 112 124 XYZ = np.where(np.abs(XYZ)<0.00001,0,XYZ) … … 114 126 if '=' not in S: 115 127 IA = 'I' 116 Uiso = float( S[57:68])128 Uiso = float(AtRec[6]) 117 129 if Uiso < 0.: 118 130 Uiso = 0.025 … … 121 133 IA = 'A' 122 134 Uiso = 0. 123 Ustr = S[57:78].split()135 Ustr = AtRec[6:8] 124 136 S = file.readline() 125 137 if '!' in S: 126 138 S = S.split('!')[0] 139 AtRec = S.split() 127 140 line += 1 128 Ustr += S[6:51].split()141 Ustr += AtRec 129 142 Uij = [float(Ustr[i]) for i in range(6)] 130 Atom = [Aname,Atype,'',XYZ[0],XYZ[1],XYZ[2],1.0,SytSym,Mult,IA,Uiso] 143 Uij = Uij[0:3]+[Uij[5],Uij[4],Uij[3]] 144 Atom = [Aname,Atype,'',XYZ[0],XYZ[1],XYZ[2],Afrac,SytSym,Mult,IA,Uiso] 131 145 Atom += Uij 132 146 Atom.append(ran.randint(0,sys.maxint))
Note: See TracChangeset
for help on using the changeset viewer.