Changeset 3098


Ignore:
Timestamp:
Sep 25, 2017 2:11:37 PM (6 years ago)
Author:
toby
Message:

fix powder data import errors with G2scriptable

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r3091 r3098  
    184184                                             of 'axial' or 'equatorial'. If boolean
    185185                                             given sets both axial and equatorial.
    186 Pref.Ori.                                    Boolean, whether to refine
    187 Show                                         Boolean, whether to refine
     186Pref.Ori.                                    Boolean, True to refine
     187Show                                         Boolean, True to refine
    188188Size                                         Not implemented
    189 Use                                          Boolean, whether to refine
    190 Scale                                        Boolean, whether to refine
     189Use                                          Boolean, True to refine
     190Scale                                        Phase fraction; Boolean, True to refine
    191191===================== =====================  ====================
    192192
     
    631631                block += 1
    632632                rd.objname = os.path.basename(filename)
    633                 flag = rd.Reader(filename, fp, buffer=rdbuffer, blocknum=block)
     633                try:
     634                    flag = rd.Reader(filename, fp, buffer=rdbuffer, blocknum=block)
     635                except:
     636                    flag = False
    634637                if flag:
    635638                    # Omitting image loading special cases
     
    638641                    repeat = rd.repeat
    639642                else:
    640                     raise G2ImportException("{}.Reader() returned:".format(rd),
    641                                             flag)
    642 
     643                    if GSASIIpath.GetConfigValue('debug'): print("{} Reader failed to read {}".format(rd.formatName,filename))
    643644            if rd_list:
    644645                if rd.warnings:
    645646                    print("Read warning by", rd.formatName, "reader:",
    646647                          rd.warnings, file=sys.stderr)
     648                else:
     649                    print("{} read by Reader {}\n".format(filename,rd.formatName))                   
    647650                return rd_list
    648651    raise G2ImportException("No reader could read file: " + filename)
     
    924927
    925928        Automatically checks for an instrument parameter file, or one can be
    926         provided.
     929        provided. Note that in unix fashion, "~" can be used to indicate the
     930        home directory (e.g. ~/G2data/data.fxye).
    927931
    928932        :param str datafile: The powder data file to read, a filename.
     
    973977        phasereaders = import_generic(phasefile, PhaseReaders)
    974978        phasereader = phasereaders[0]
    975 
     979       
    976980        phasename = phasename or phasereader.Phase['General']['Name']
    977981        phaseNameList = [p.name for p in self.phases()]
  • trunk/imports/G2pwd_BrukerRAW.py

    r2835 r3098  
    1515'''
    1616
    17 import sys
     17#import sys
    1818import os.path as ospath
    1919import struct as st
     
    6262        'Read a Bruker RAW file'
    6363        self.comments = []
    64         self.repeat = True
    6564        self.powderentry[0] = filename
    6665        File = open(filename,'rb')
     
    102101                if blockNum == nBlock:
    103102                    self.repeat = False                                   
     103                else:
     104                    self.repeat = True
    104105            File.close()
    105106        elif 'ver. 3' in self.formatName:
     
    154155                    File.seek(pos)
    155156                if blockNum == nBlock:
    156                     self.repeat = False                                   
     157                    self.repeat = False
     158                else:
     159                    self.repeat = True
    157160            File.close()
    158161           
     
    189192            self.powderdata = [x,y,w,np.zeros(nSteps),np.zeros(nSteps),np.zeros(nSteps)]
    190193            File.close()
     194        else:
     195            return False
    191196           
    192197        return True
  • trunk/imports/G2pwd_CIF.py

    r2817 r3098  
    9494            selections = rdbuffer.get('selections')
    9595        if cf is None:
    96             print "Starting parse of CIF file"
     96            if GSASIIpath.GetConfigValue('debug'): print("Starting parse of {} as CIF".format(filename))
    9797            cf = G2obj.ReadCIF(filename)
    98             print "CIF file parsed"
     98            if GSASIIpath.GetConfigValue('debug'): print "CIF file parsed"
    9999        # scan all blocks for sets of data
    100100        if choicelist is None:
  • trunk/imports/G2pwd_FP.py

    r2835 r3098  
    126126            except ValueError:
    127127                msg = 'Error parsing number in line '+str(i+1)
    128                 print msg
    129                 print S
     128                if GSASIIpath.GetConfigValue('debug'):
     129                    print msg
     130                    print S.strip()
    130131                break
    131132            except:
    132133                msg = 'Error in line '+str(i+1)
    133                 print msg
    134                 print S
     134                if GSASIIpath.GetConfigValue('debug'):
     135                    print msg
     136                    print S.strip()
    135137                break
    136138        N = len(x)
  • trunk/imports/G2pwd_csv.py

    r2835 r3098  
    8282                msg = 'Error in line '+str(i+1)
    8383            if err and i > 0:
    84                 print msg
    85                 print S
     84                if GSASIIpath.GetConfigValue('debug'):
     85                    print msg
     86                    print S.strip()
    8687                break
    8788        N = len(x)
  • trunk/imports/G2pwd_xye.py

    r2835 r3098  
    133133            except ValueError:
    134134                msg = 'Error parsing number in line '+str(i+1)
    135                 print msg
    136                 print S
     135                if GSASIIpath.GetConfigValue('debug'):
     136                    print msg
     137                    print S.strip()
    137138                break
    138139            except:
    139140                msg = 'Error in line '+str(i+1)
    140                 print msg
    141                 print S
     141                if GSASIIpath.GetConfigValue('debug'):
     142                    print msg
     143                    print S.strip()
    142144                break
    143145        N = len(x)
Note: See TracChangeset for help on using the changeset viewer.