Changeset 4657 for trunk


Ignore:
Timestamp:
Nov 11, 2020 2:43:03 PM (13 months ago)
Author:
toby
Message:

fix CIF bug with excluded points

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_CIF.py

    r4474 r4657  
    356356
    357357
    358 # Refactored over here to allow access by GSASIIscriptable.py
    359358def FmtAtomType(sym):
    360359    'Reformat a GSAS-II atom type symbol to match CIF rules'
     
    368367
    369368
    370 # Refactored over here to allow access by GSASIIscriptable.py
    371369def PutInCol(val, wid):
    372370    val = str(val).replace(' ', '')
    373371    if not val: val = '?'
    374372    fmt = '{:' + str(wid) + '} '
    375     return fmt.format(val)
     373    try:
     374        return fmt.format(val)
     375    except TypeError:
     376        return fmt.format('.')
    376377
    377378
     
    11771178        def Yfmt(ndec,val):
    11781179            '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 '.'
    11831186        def WriteReflStat(refcount,hklmin,hklmax,dmin,dmax,nRefSets=1):
    11841187            'Write reflection statistics'
     
    14061409            WriteCIFitem(self.fp, '\n# POWDER DATA TABLE')
    14071410            # 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.:
    14101413                fixedstep = False
    14111414            else:
     
    14161419                WriteCIFitem(self.fp, '_pd_meas_2theta_range_min', G2mth.ValEsd(histblk['Data'][0][0],-0.00009))
    14171420                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))
    14191422                # zero correct, if defined
    14201423                zerolst = histblk['Instrument Parameters'][0].get('Zero')
     
    21012104        # give the user a window to edit CIF contents
    21022105        if not self.author:
     2106            self.author = self.OverallParms['Controls']["Author"]
     2107            self.shortauthorname = self.author.replace(',','').replace(' ','')[:20]
     2108        if not self.author:
    21032109            if not EditAuthor(): return
    21042110        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.