Changeset 2341


Ignore:
Timestamp:
Jun 23, 2016 9:25:06 PM (7 years ago)
Author:
toby
Message:

improve powder imports: suppress printing of binary data; improve validation of old GSAS binary files

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2304 r2341  
    555555            else:
    556556                if singlereader:
     557                    print('The '+ rd.formatName+
     558                            ' reader was not able to read file '+filename+msg)
     559                    try:
     560                        print('\n\nError message(s):\n\t'+errorReport)
     561                    except:
     562                        pass
    557563                    self.ErrorDialog('Read Error','The '+ rd.formatName+
    558                                      ' reader was not able to read file '+filename+msg+
    559                                      '\n\nError message(s):\n'+errorReport
    560                                      )
     564                                     ' reader was not able to read file '+filename+msg)
    561565                else:
    562                     self.ErrorDialog('Read Error','No reader was able to read file '+filename+msg+
    563                                      '\n\nError messages:\n'+errorReport
    564                                      )
     566                    print('No reader was able to read file '+filename+msg)
     567                    try:
     568                        print('\n\nError message(s):\n\t'+errorReport)
     569                    except:
     570                        pass
     571                    self.ErrorDialog('Read Error','No reader was able to read file '+filename+msg)
    565572            if fp: fp.close()
    566573        return rd_list
     
    14591466                    dlg.Destroy()
    14601467            HistName = G2obj.MakeUniqueLabel(HistName,PWDRlist)
    1461             print 'Read powder data '+str(HistName)+ \
    1462                 ' from file '+str(rd.readfilename) + \
    1463                 ' with parameters from '+str(rd.instmsg)
     1468            print('Read powder data '+str(HistName)+
     1469                ' from file '+str(rd.readfilename) +
     1470                ' (format: '+ rd.formatName +
     1471                '). Inst parameters from '+str(rd.instmsg))
    14641472            # data are read, now store them in the tree
    14651473            Id = self.PatternTree.AppendItem(parent=self.root,text=HistName)
     
    15471555        phaseNameList = usedHistograms.keys() # phase names in use
    15481556        if not phaseNameList: return # no phases yet, nothing to do
    1549         header = 'Select phase(s) to add the new\npowder dataset(s) to:'
     1557        header = 'Select phase(s) to link\nto new data:'
    15501558        for Name in newHistList:
    15511559            header += '\n  '+str(Name)
  • trunk/GSASIIIO.py

    r2298 r2341  
    14281428            else: # found something invalid
    14291429                self.errors = 'line '+str(i+1)+' contains unexpected data:\n'
    1430                 self.errors += '  '+str(l)
    1431                 self.errors += '  Note: a CIF should only have blank lines or comments before'
    1432                 self.errors += '        a data_ statement begins a block.'
     1430                if all([ord(c) < 128 and ord(c) != 0 for c in str(l)]): # show only if ASCII
     1431                    self.errors += '  '+str(l)
     1432                else:
     1433                    self.errors += '  (binary)'
     1434                self.errors += '\n  Note: a CIF should only have blank lines or comments before'
     1435                self.errors += '\n        a data_ statement begins a block.'
    14331436                return False
    14341437
  • trunk/imports/G2pwd_BrukerRAW.py

    r2238 r2341  
    4444            self.formatName = 'Bruker RAW ver. 3'
    4545        else:
    46             self.errors = 'Unexpected information in header: '+str(head)
    47             self.errors += '  '+str(head)
     46            self.errors = 'Unexpected information in header: '
     47            if all([ord(c) < 128 and ord(c) != 0 for c in str(head)]): # show only if ASCII
     48                self.errors += '  '+str(head)
     49            else:
     50                self.errors += '  (binary)'
    4851            return False
    4952        return True
  • trunk/imports/G2pwd_FP.py

    r2161 r2341  
    6060            except ValueError:
    6161                self.errors = 'Unexpected information in line: '+str(i+1)
    62                 self.errors += '  '+str(S)
     62                if all([ord(c) < 128 and ord(c) != 0 for c in str(S)]): # show only if ASCII
     63                    self.errors += '  '+str(S)
     64                else:
     65                    self.errors += '  (binary)'
    6366                return False
    6467        return True # no errors encountered
  • trunk/imports/G2pwd_Pnn.py

    r2285 r2341  
    1616
    1717import sys
    18 import os.path as ospath
     18import os.path
    1919import numpy as np
    2020import array as ar
     
    2626    def __init__(self):
    2727        super(self.__class__,self).__init__( # fancy way to self-reference
    28             extensionlist=('.P*',),
     28            extensionlist=('.P01','.P02','.P03','.P04','.P05','.P06',
     29                           '.P07','.P08','.P09','.P*',),
    2930            strictExtension=False,
    30             formatName = 'GSAS Pnn',
    31             longFormatName = 'GSAS Pnn powder data file'
     31            formatName = 'GSAS .Pnn',
     32            longFormatName = 'GSAS .Pnn powder data file'
    3233            )
    3334
     
    3738        gotCcomment = False
    3839        self.GSAS = False
    39         return True # no errors encountered
     40        # file extension must be .Pxx or .pxx
     41        ext = os.path.splitext(filepointer.name)[1]
     42        if ext[1].upper() != 'P' or len(ext) != 4:
     43            return False
     44        if ext[2].isdigit() and ext[3].isdigit():
     45            return True # no errors encountered
     46        return False
     47       
    4048
    4149    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
     
    6472        self.powderentry[0] = filename
    6573        self.powderentry[2] = 1 # Pnn file only has one bank
    66         self.idstring = ospath.basename(filename)
     74        self.idstring = os.path.basename(filename)
    6775        return True
    6876     
  • trunk/imports/G2pwd_fxye.py

    r2152 r2341  
    5252            else:
    5353                self.errors = 'Unexpected information in line: '+str(i+1)
    54                 self.errors += '  '+str(line)
     54                if all([ord(c) < 128 and ord(c) != 0 for c in str(line)]): # show only if ASCII
     55                    self.errors += '  '+str(line)
     56                else:
     57                    self.errors += '  (binary)'
    5558                return False
    5659        return False # no bank records
  • trunk/imports/G2pwd_xye.py

    r1620 r2341  
    5656            else:
    5757                self.errors = 'Unexpected information in line: '+str(i+1)
    58                 self.errors += '  '+str(S)
     58                if all([ord(c) < 128 and ord(c) != 0 for c in str(S)]): # show only if ASCII
     59                    self.errors += '  '+str(S)
     60                else:
     61                    self.errors += '  (binary)'
    5962                return False
    6063        return True # no errors encountered
Note: See TracChangeset for help on using the changeset viewer.