Changeset 1013
- Timestamp:
- Aug 1, 2013 1:06:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2cif.py
r1012 r1013 9 9 # $Id: G2cif.py 1006 2013-07-23 01:57:37Z toby $ 10 10 ########### SVN repository information ################### 11 ''' Development code to export a GSAS-II project as a CIF11 '''Code to export a GSAS-II project as a CIF 12 12 The heavy lifting is done in method export 13 13 ''' … … 29 29 reload(G2mth) 30 30 import GSASIIlattice as G2lat 31 import GSASIIspc as G2sp g32 #reload(G2sp g)31 import GSASIIspc as G2spc 32 #reload(G2spc) 33 33 34 34 DEBUG = True #True to skip printing of reflection/powder profile lists … … 233 233 s += s1 234 234 return s 235 def FormatBackground(bkg ):235 def FormatBackground(bkg,hId): 236 236 '''Display the Background information as a descriptive text string. 237 237 … … 241 241 :returns: the text description (str) 242 242 ''' 243 hfx = ':'+str(hId)+':' 243 244 fxn, bkgdict = bkg 244 245 terms = fxn[2] 245 246 txt = 'Background function: "'+fxn[0]+'" function with '+str(terms)+' terms:\n' 246 247 l = " " 247 for v in fxn[3:]: 248 for i,v in enumerate(fxn[3:]): 249 name = '%sBack:%d'%(hfx,i) 250 sig = self.sigDict.get(name,-0.009) 248 251 if len(l) > 60: 249 252 txt += l + '\n' 250 253 l = ' ' 251 l += G2mth.ValEsd(v, -.009)+', '254 l += G2mth.ValEsd(v,sig)+', ' 252 255 txt += l 253 256 return txt 254 257 255 def FormatInstProfile(instparmdict ):258 def FormatInstProfile(instparmdict,hId): 256 259 '''Format the instrumental profile parameters with a 257 260 string description. Will only be called on PWDR histograms … … 259 262 s = '' 260 263 inst = instparmdict[0] 264 hfx = ':'+str(hId)+':' 261 265 if 'C' in inst['Type'][0]: 262 s = 'Finger-Cox-Jephcoat function parameters U, V, W, X, Y, SH/L:\n ' 266 s = 'Finger-Cox-Jephcoat function parameters U, V, W, X, Y, SH/L:\n' 267 s += ' peak variance(Gauss) = Utan(Th)^2+Vtan(Th)+W:\n' 268 s += ' peak HW(Lorentz) = X/cos(Th)+Ytan(Th); SH/L = S/L+H/L\n' 269 s += ' U, V, W in (centideg)^2, X & Y in centideg\n ' 263 270 for item in ['U','V','W','X','Y','SH/L']: 264 s += G2mth.ValEsd(inst[item][1],-.009)+', ' 271 name = hfx+item 272 sig = self.sigDict.get(name,-0.009) 273 s += G2mth.ValEsd(inst[item][1],sig)+', ' 265 274 elif 'T' in inst['Type'][0]: #to be tested after TOF Rietveld done 266 275 s = 'Von Dreele-Jorgenson-Windsor function parameters\n'+ \ 267 276 ' alpha, beta-0, beta-1, beta-q, sig-0, sig-1, sig-q, X, Y:\n ' 268 277 for item in ['alpha','bet-0','bet-1','bet-q','sig-0','sig-1','sig-q','X','Y']: 269 s += G2mth.ValEsd(inst[item][1],-.009)+', ' 278 name = hfx+item 279 sig = self.sigDict.get(name,-0.009) 280 s += G2mth.ValEsd(inst[item][1],sig)+', ' 270 281 return s 271 282 … … 273 284 '''Format the phase-related profile parameters (size/strain) 274 285 with a string description. 275 return an empty string or None there are no286 return an empty string or None if there are no 276 287 powder histograms for this phase. 277 288 ''' 278 289 s = '' 279 phasedict = self.Phases[phasenam] # pointer to current phase info 290 phasedict = self.Phases[phasenam] # pointer to current phase info 291 SGData = phasedict['General'] ['SGData'] 280 292 for histogram in sorted(phasedict['Histograms']): 281 293 if histogram.startswith("HKLF"): continue # powder only … … 283 295 if not Histogram: continue 284 296 hapData = phasedict['Histograms'][histogram] 285 return 'TODO: Phase profile goes here' 297 pId = phasedict['pId'] 298 hId = Histogram['hId'] 299 phfx = '%d:%d:'%(pId,hId) 300 size = hapData['Size'] 301 mustrain = hapData['Mustrain'] 302 hstrain = hapData['HStrain'] 303 s = ' Crystallite size model "%s" for %s (microns)\n'%(size[0],phasenam) 304 names = ['Size;i','Size;mx'] 305 if 'uniax' in size[0]: 306 names = ['Size;i','Size;a','Size;mx'] 307 s += ' anisotropic axis is %s\n '%(str(size[3])) 308 s += ' parameters: equatorial size, axial size, G/L mix\n ' 309 for i,item in enumerate(names): 310 name = phfx+item 311 sig = self.sigDict.get(name,-0.009) 312 s += G2mth.ValEsd(size[1][i],sig)+', ' 313 elif 'ellip' in size[0]: 314 s += ' parameters: S11, S22, S33, S12, S13, S23, G/L mix\n ' 315 for i in range(6): 316 name = phfx+'Size:'+str(i) 317 sig = self.sigDict.get(name,-0.009) 318 s += G2mth.ValEsd(size[4][i],sig)+', ' 319 sig = self.sigDict.get(phfx+'Size;mx',-0.009) 320 s += G2mth.ValEsd(size[1][2],sig)+', ' 321 else: #isotropic 322 s += ' parameters: Size, G/L mix\n ' 323 i = 0 324 for item in names: 325 name = phfx+item 326 sig = self.sigDict.get(name,-0.009) 327 s += G2mth.ValEsd(size[1][i],sig)+', ' 328 i = 2 #skip the aniso value 329 s += '\n Mustrain model "%s" for %s (10^6)\n'%(mustrain[0],phasenam) 330 names = ['Mustrain;i','Mustrain;mx'] 331 if 'uniax' in mustrain[0]: 332 names = ['Mustrain;i','Mustrain;a','Mustrain;mx'] 333 s += ' anisotropic axis is %s\n '%(str(size[3])) 334 s += ' parameters: equatorial mustrain, axial mustrain, G/L mix\n ' 335 for i,item in enumerate(names): 336 name = phfx+item 337 sig = self.sigDict.get(name,-0.009) 338 s += G2mth.ValEsd(mustrain[1][i],sig)+', ' 339 elif 'general' in mustrain[0]: 340 names = ' parameters: ' 341 for i,name in enumerate(G2spc.MustrainNames(SGData)): 342 names += name+', ' 343 if i == 9: 344 names += '\n ' 345 names += 'G/L mix\n ' 346 s += names 347 txt = '' 348 for i in range(len(mustrain[4])): 349 name = phfx+'Mustrain:'+str(i) 350 sig = self.sigDict.get(name,-0.009) 351 if len(txt) > 60: 352 s += txt+'\n ' 353 txt = '' 354 txt += G2mth.ValEsd(mustrain[4][i],sig)+', ' 355 s += txt 356 sig = self.sigDict.get(phfx+'Mustrain;mx',-0.009) 357 s += G2mth.ValEsd(mustrain[1][2],sig)+', ' 358 359 else: #isotropic 360 s += ' parameters: Mustrain, G/L mix\n ' 361 i = 0 362 for item in names: 363 name = phfx+item 364 sig = self.sigDict.get(name,-0.009) 365 s += G2mth.ValEsd(mustrain[1][i],sig)+', ' 366 i = 2 #skip the aniso value 367 s += '\n Macrostrain for %s\n'%(phasenam) 368 txt = ' parameters: ' 369 names = G2spc.HStrainNames(SGData) 370 for name in names: 371 txt += name+', ' 372 s += txt+'\n ' 373 for i in range(len(names)): 374 name = phfx+name[i] 375 sig = self.sigDict.get(name,-0.009) 376 s += G2mth.ValEsd(hstrain[0][i],sig)+', ' 377 return s 286 378 287 379 def FmtAtomType(sym): … … 581 673 582 674 # generate symmetry operations including centering and center of symmetry 583 SymOpList,offsetList,symOpList,G2oprList = G2sp g.AllOps(675 SymOpList,offsetList,symOpList,G2oprList = G2spc.AllOps( 584 676 phasedict['General']['SGData']) 585 677 WriteCIFitem('loop_ _space_group_symop_id _space_group_symop_operation_xyz') … … 721 813 #WriteCIFitem(' _atom_type_scat_source') 722 814 723 WriteCIFitem('_pd_proc_ls_background_function',FormatBackground(histblk['Background'] ))815 WriteCIFitem('_pd_proc_ls_background_function',FormatBackground(histblk['Background'],histblk['hId'])) 724 816 725 817 #WriteCIFitem('_exptl_absorpt_process_details','?') … … 733 825 if not oneblock: # instrumental profile terms go here 734 826 WriteCIFitem('_pd_proc_ls_profile_function', 735 FormatInstProfile(histblk["Instrument Parameters"] ))827 FormatInstProfile(histblk["Instrument Parameters"],histblk['hId'])) 736 828 737 829 #refprx = '_refln.' # mm … … 1095 1187 # report profile, since one-block: include both histogram and phase info 1096 1188 WriteCIFitem('_pd_proc_ls_profile_function', 1097 FormatInstProfile(histblk["Instrument Parameters"]) 1098 + '\n' + 1099 FormatPhaseProfile(phasenam)) 1189 FormatInstProfile(histblk["Instrument Parameters"],histblk['hId']) 1190 +'\n'+FormatPhaseProfile(phasenam)) 1100 1191 WritePowderTemplate() 1101 1192 WritePowderData(hist) … … 1194 1285 # report instrumental profile terms 1195 1286 WriteCIFitem('_pd_proc_ls_profile_function', 1196 FormatInstProfile(histblk["Instrument Parameters"] ))1287 FormatInstProfile(histblk["Instrument Parameters"],histblk['hId'])) 1197 1288 WriteCIFitem('# Information for histogram '+str(i)+': '+hist) 1198 1289 WriteCIFitem('_pd_block_id',datablockidDict[hist])
Note: See TracChangeset
for help on using the changeset viewer.