Changeset 3252
- Timestamp:
- Jan 30, 2018 12:21:10 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/imports/G2phase.py ¶
r3245 r3252 186 186 return False 187 187 188 def Reader(self,filename, ParentFrame=None,**unused):188 def Reader(self,filename,ParentFrame=None,usedRanIdList=[],**unused): 189 189 'Read a phase from a GSAS .EXP file using :meth:`ReadEXPPhase`' 190 self.Phase = G2obj.SetNewPhase(Name='new phase') # create a new empty phase dict 191 while self.Phase['ranId'] in usedRanIdList: 192 self.Phase['ranId'] = ran.randint(0,sys.maxsize) 193 # make sure the ranId is really unique! 194 self.MPhase = G2obj.SetNewPhase(Name='new phase') # create a new empty phase dict 195 while self.MPhase['ranId'] in usedRanIdList: 196 self.MPhase['ranId'] = ran.randint(0,sys.maxsize) 190 197 fp = open(filename,'r') 191 self. Phase = self.ReadEXPPhase(ParentFrame, fp)198 self.ReadEXPPhase(ParentFrame, fp) 192 199 fp.close() 193 200 return True … … 233 240 keyList.sort() 234 241 SGData = {} 242 MPtype = '' 235 243 if NPhas[result] == '1': 236 244 Ptype = 'nuclear' 237 elif NPhas[result] in ['2','3']: 245 elif NPhas[result] =='2': 246 Ptype = 'nuclear' 247 MPtype = 'magnetic' 248 MagDmin = 1.0 249 elif NPhas[result] =='3': 238 250 Ptype = 'magnetic' 239 251 MagDmin = 1.0 … … 243 255 Ptype = 'Pawley' 244 256 else: 245 raise self.ImportException("Phase type not recognized") 257 raise self.ImportException("Phase type not recognized") 258 246 259 for key in keyList: 247 260 if 'PNAM' in key: … … 280 293 textureData['Sample phi'] = [False,float(SHvals[8])] 281 294 shNcof = int(SHvals[1]) 295 Volume = G2lat.calc_V(G2lat.cell2A(abc+angles)) 296 282 297 Atoms = [] 283 Amat,Bmat = G2lat.cell2AB(abc+angles) 284 if Ptype in ['nuclear','magnetic',]: 298 MAtoms = [] 299 Bmat = G2lat.cell2AB(abc+angles)[1] 300 if Ptype == 'macromolecular': 301 for key in keyList: 302 if 'AT' in key[6:8]: 303 S = EXPphase[key] 304 Atom = [S[56:60].strip(),S[50:54].strip().upper(),S[54:56], 305 S[46:51].strip(),S[:8].strip().capitalize(),'', 306 float(S[16:24]),float(S[24:32]),float(S[32:40]), 307 float(S[8:16]),'1',1,'I',float(S[40:46]),0,0,0,0,0,0] 308 XYZ = Atom[6:9] 309 Atom[10],Atom[11] = G2spc.SytSym(XYZ,SGData)[:2] 310 Atom.append(ran.randint(0,sys.maxsize)) 311 Atoms.append(Atom) 312 else: 285 313 for key in keyList: 286 314 if 'AT' in key: … … 308 336 Atoms.append(Atom) 309 337 elif key[11:] == 'M' and key[6:8] == 'AT': 310 Ptype = 'magnetic'311 338 S = EXPphase[key] 312 339 mom = np.array([float(S[:10]),float(S[10:20]),float(S[20:30])]) 313 340 mag = np.sqrt(np.sum(mom**2)) 314 341 mom = np.inner(Bmat,mom)*mag 315 Atoms[-1] = Atom[:7]+list(mom)+Atom[7:] 316 elif Ptype == 'macromolecular': 317 for key in keyList: 318 if 'AT' in key[6:8]: 319 S = EXPphase[key] 320 Atom = [S[56:60].strip(),S[50:54].strip().upper(),S[54:56], 321 S[46:51].strip(),S[:8].strip().capitalize(),'', 322 float(S[16:24]),float(S[24:32]),float(S[32:40]), 323 float(S[8:16]),'1',1,'I',float(S[40:46]),0,0,0,0,0,0] 324 XYZ = Atom[6:9] 325 Atom[10],Atom[11] = G2spc.SytSym(XYZ,SGData)[:2] 326 Atom.append(ran.randint(0,sys.maxsize)) 327 Atoms.append(Atom) 328 Volume = G2lat.calc_V(G2lat.cell2A(abc+angles)) 342 MAtoms.append(Atom) 343 MAtoms[-1] = Atom[:7]+list(mom)+Atom[7:] 344 329 345 if shNcof: 330 346 shCoef = {} … … 339 355 shCoef[key] = float(val) 340 356 textureData['SH Coeff'] = [False,shCoef] 357 341 358 if not SGData: 342 359 raise self.ImportException("No space group found in phase") … … 347 364 if not Atoms: 348 365 raise self.ImportException("No atoms found in phase") 349 Phase = G2obj.SetNewPhase(Name=PhaseName,SGData=SGData,cell=abc+angles+[Volume,]) 350 general = Phase['General'] 351 general['Type'] = Ptype 352 if general['Type'] =='macromolecular': 353 general['AtomPtrs'] = [6,4,10,12] 354 elif general['Type'] =='magnetic': 355 general['AtomPtrs'] = [3,1,10,12] 356 general['SGData']['SGSpin'] = SpnFlp 357 general['MagDmin'] = MagDmin 366 367 self.Phase['General'].update({'Type':Ptype,'Name':PhaseName,'Cell':[False,]+abc+angles+[Volume,],'SGData':SGData}) 368 if MPtype == 'magnetic': 369 self.MPhase['General'].update({'Type':'magnetic','Name':PhaseName+' mag','Cell':[False,]+abc+angles+[Volume,],'SGData':SGData}) 370 else: 371 self.MPhase = None 372 373 if Ptype =='macromolecular': 374 self.Phase['General']['AtomPtrs'] = [6,4,10,12] 375 self.Phase['Atoms'] = Atoms 376 elif Ptype == 'magnetic': 377 self.Phase['General']['AtomPtrs'] = [3,1,10,12] 378 self.Phase['General']['SGData']['SGSpin'] = SpnFlp 379 self.Phase['General']['MagDmin'] = MagDmin 380 self.Phase['Atoms'] = MAtoms 358 381 else: #nuclear 359 general['AtomPtrs'] = [3,1,7,9] 360 general['SH Texture'] = textureData 361 Phase['Atoms'] = Atoms 362 return Phase 382 self.Phase['General']['AtomPtrs'] = [3,1,7,9] 383 self.Phase['General']['SH Texture'] = textureData 384 self.Phase['Atoms'] = Atoms 385 if MPtype =='magnetic': 386 self.MPhase['General']['AtomPtrs'] = [3,1,10,12] 387 self.MPhase['General']['SGData']['SGSpin'] = SpnFlp 388 self.MPhase['General']['MagDmin'] = MagDmin 389 self.MPhase['Atoms'] = MAtoms 363 390 364 391 class JANA_ReaderClass(G2obj.ImportPhase):
Note: See TracChangeset
for help on using the changeset viewer.