- Timestamp:
- Nov 11, 2020 2:43:03 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2export_CIF.py
r4474 r4657 356 356 357 357 358 # Refactored over here to allow access by GSASIIscriptable.py359 358 def FmtAtomType(sym): 360 359 'Reformat a GSAS-II atom type symbol to match CIF rules' … … 368 367 369 368 370 # Refactored over here to allow access by GSASIIscriptable.py371 369 def PutInCol(val, wid): 372 370 val = str(val).replace(' ', '') 373 371 if not val: val = '?' 374 372 fmt = '{:' + str(wid) + '} ' 375 return fmt.format(val) 373 try: 374 return fmt.format(val) 375 except TypeError: 376 return fmt.format('.') 376 377 377 378 … … 1177 1178 def Yfmt(ndec,val): 1178 1179 'Format intensity values' 1179 out = ("{:."+str(ndec)+"f}").format(val) 1180 out = out.rstrip('0') # strip zeros to right of decimal 1181 return out.rstrip('.') # and decimal place when not needed 1182 1180 try: 1181 out = ("{:."+str(ndec)+"f}").format(val) 1182 out = out.rstrip('0') # strip zeros to right of decimal 1183 return out.rstrip('.') # and decimal place when not needed 1184 except TypeError: 1185 return '.' 1183 1186 def WriteReflStat(refcount,hklmin,hklmax,dmin,dmax,nRefSets=1): 1184 1187 'Write reflection statistics' … … 1406 1409 WriteCIFitem(self.fp, '\n# POWDER DATA TABLE') 1407 1410 # is data fixed step? If the step varies by <0.01% treat as fixed step 1408 steps = histblk['Data'][0][1:] - histblk['Data'][0][:-1]1409 if abs(max(steps)-min(steps)) > abs(max(steps))/10000.:1411 steps = abs(histblk['Data'][0][1:] - histblk['Data'][0][:-1]) 1412 if (max(steps)-min(steps)) > np.mean(steps)/10000.: 1410 1413 fixedstep = False 1411 1414 else: … … 1416 1419 WriteCIFitem(self.fp, '_pd_meas_2theta_range_min', G2mth.ValEsd(histblk['Data'][0][0],-0.00009)) 1417 1420 WriteCIFitem(self.fp, '_pd_meas_2theta_range_max', G2mth.ValEsd(histblk['Data'][0][-1],-0.00009)) 1418 WriteCIFitem(self.fp, '_pd_meas_2theta_range_inc', G2mth.ValEsd( steps.sum()/len(steps),-0.00009))1421 WriteCIFitem(self.fp, '_pd_meas_2theta_range_inc', G2mth.ValEsd(np.mean(steps),-0.00009)) 1419 1422 # zero correct, if defined 1420 1423 zerolst = histblk['Instrument Parameters'][0].get('Zero') … … 2101 2104 # give the user a window to edit CIF contents 2102 2105 if not self.author: 2106 self.author = self.OverallParms['Controls']["Author"] 2107 self.shortauthorname = self.author.replace(',','').replace(' ','')[:20] 2108 if not self.author: 2103 2109 if not EditAuthor(): return 2104 2110 self.ValidateAscii([('Author name',self.author),]) # check for ASCII strings where needed, warn on problems
Note: See TracChangeset
for help on using the changeset viewer.