parameters: (self, datafilename)
return_statement: return (tablews, dataws)
docstring: Parse a Fullprof (multiple) column file
docstring_summary: Parse a Fullprof (multiple) column file
docstring_tokens: Parse a Fullprof ( multiple ) column file
function: def _loadFullprofDataFile(self, datafilename):
          """ Parse a Fullprof (multiple) column file
          """
          # Import file
          datafile = open(datafilename, "r")
          rawlines = datafile.readlines()
          datafile.close()
  
          # Parse head
          iline = 0
          parseheader = True
          #title = ""
          while iline < len(rawlines) and parseheader is True:
              line = rawlines[iline].strip()
              if len(line) > 0:
                  if line.count("BANK") != 0:
                      # line information
                      terms = line.split()
                      if terms[0] != 'BANK':
                          raise NotImplementedError("First word must be 'BANK', but not %s" % (terms[0]))
                      #bankid = int(terms[1])
                      numdata = int(terms[2])
                      numlines = int(terms[3])
  
                      parseheader = False
                  # ENDIF
              # ENDIF
              iline += 1
          # ENDWHILE (iline)
  
          # Data vectors
          vecx = []
          vecy = []
          vece = []
  
          for i in range(iline, len(rawlines)):
              line = rawlines[i].strip()
              if len(line) == 0:
                  continue
  
              terms = line.split()
              numitems = len(terms)
              if numitems % 3 != 0:
                  print("%d-th line '%s' is not a data line" % (i, line))
                  continue
  
              numpts = numitems/3
              for j in range(numpts):
                  x = float(terms[j*3])
                  y = float(terms[j*3+1])
                  e = float(terms[j*3+2])
  
                  vecx.append(x)
                  vecy.append(y)
                  vece.append(e)
              # ENDFOR
          # ENDFOR (i)
  
          # Check
          self.log().notice("Expected to read %d data points; Exactly read %d data points. " % (numdata*numlines, len(vecx)))
  
          # Create output workspaces
          tablews = WorkspaceFactory.createTable()
  
          # Create the data workspace
          datasize = len(vecx)
          dataws = WorkspaceFactory.create("Workspace2D", 1, datasize, datasize)
          for i in range(datasize):
              dataws.dataX(0)[i] = vecx[i]
              dataws.dataY(0)[i] = vecy[i]
              dataws.dataE(0)[i] = vece[i]
  
          return (tablews, dataws)
function_tokens: def _loadFullprofDataFile ( self , datafilename ) : # Import file datafile = open ( datafilename , "r" ) rawlines = datafile . readlines ( ) datafile . close ( ) # Parse head iline = 0 parseheader = True #title = "" while iline < len ( rawlines ) and parseheader is True : line = rawlines [ iline ] . strip ( ) if len ( line ) > 0 : if line . count ( "BANK" ) != 0 : # line information terms = line . split ( ) if terms [ 0 ] != 'BANK' : raise NotImplementedError ( "First word must be 'BANK', but not %s" % ( terms [ 0 ] ) ) #bankid = int(terms[1]) numdata = int ( terms [ 2 ] ) numlines = int ( terms [ 3 ] ) parseheader = False # ENDIF # ENDIF iline += 1 # ENDWHILE (iline) # Data vectors vecx = [ ] vecy = [ ] vece = [ ] for i in range ( iline , len ( rawlines ) ) : line = rawlines [ i ] . strip ( ) if len ( line ) == 0 : continue terms = line . split ( ) numitems = len ( terms ) if numitems % 3 != 0 : print ( "%d-th line '%s' is not a data line" % ( i , line ) ) continue numpts = numitems / 3 for j in range ( numpts ) : x = float ( terms [ j * 3 ] ) y = float ( terms [ j * 3 + 1 ] ) e = float ( terms [ j * 3 + 2 ] ) vecx . append ( x ) vecy . append ( y ) vece . append ( e ) # ENDFOR # ENDFOR (i) # Check self . log ( ) . notice ( "Expected to read %d data points; Exactly read %d data points. " % ( numdata * numlines , len ( vecx ) ) ) # Create output workspaces tablews = WorkspaceFactory . createTable ( ) # Create the data workspace datasize = len ( vecx ) dataws = WorkspaceFactory . create ( "Workspace2D" , 1 , datasize , datasize ) for i in range ( datasize ) : dataws . dataX ( 0 ) [ i ] = vecx [ i ] dataws . dataY ( 0 ) [ i ] = vecy [ i ] dataws . dataE ( 0 ) [ i ] = vece [ i ] return ( tablews , dataws )