orphan:

Module ascarray

This module is the base containing the function on which tabarray has been built.

Function ascarray

kapteyn.ascarray.ascarray(filename[, comchar='#!', sepchar=', \t', lines=None, bad=None, segsep=None])

Read an ASCII table file and return its data as a NumPy array.

Parameters:
  • source – a string with the name of a text file containing the table.
  • comchar – string with characters which are used to designate comments in the input file. The occurrence of any of these characters on a line causes the rest of the line to be ignored. Empty lines and lines containing only a comment are also ignored. Default: ‘#!’.
  • sepchar – a string containing the column separation characters to be used. Columns are separated by any combination of these characters. Default: ‘, \t’.
  • lines – a two-element tuple or list specifying a range of lines to be read. Line numbers are counted from one and the range is inclusive. So (1,10) specifies the first 10 lines of a file. Comment lines are included in the count. If any element of the tuple or list is zero, this limit is ignored. So (1,0) specifies the whole file, just like the default None. Default: all lines.
  • bad – a number to be substituted for any field which cannot be decoded as a number. The default None causes a ValueError exception to be raised in such cases.
  • segsep – a string containing the segment separation characters. If any of these characters is present in a comment line, this comment block is taken as the end of the current segment. The default None indicates that every comment block will separate segments.
Returns:

a tuple containing 1) a NumPy array containing the selected data from the table file, and 2) a list of slice objects, one for every segment.

Raises:

IOError, when the file cannot be opened.

IndexError, when a line with an inconsistent number of fields is encountered in the input file.

ValueError: when a field cannot be decoded as a number and no alternative value was specified.