load_data
- sherpa.ui.load_data(id, filename=None, ncols=2, colkeys=None, dstype=<class 'sherpa.data.Data1D'>, sep=' ', comment='#', require_floats=True) None
Load a data set from an ASCII file.
- Parameters:
filename (str) – The name of the ASCII file to read in.
ncols (int, optional) – The number of columns to read in (the first
ncolscolumns in the file).colkeys (array of str, optional) – An array of the column name to read in. The default is
None.dstype (data class to use, optional) – What type of data is to be used. Supported values include
Data1D(the default),Data1DInt,Data2D, andData2DInt.sep (str, optional) – The separator character. The default is
' '.comment (str, optional) – The comment character. The default is
'#'.require_floats (bool, optional) – If
True(the default), non-numeric data values will raise aValueError.
- Raises:
ValueError – If a column value can not be converted into a numeric value and the
require_floatsparameter is True.
See also
get_dataReturn the data set by identifier.
load_arraysCreate a data set from array values.
unpack_arraysCreate a sherpa data object from arrays of data.
unpack_dataCreate a sherpa data object from a file.
Notes
The function does not follow the normal Python standards for parameter use, since it is designed for easy interactive use. When called with a single un-named argument, it is taken to be the
filenameparameter. If given two un-named arguments, then they are interpreted as theidandfilenameparameters, respectively. The remaining parameters are expected to be given as named arguments.See
unpack_datafor a description of the supported file format.Examples
>>> load_data('tbl.dat')
>>> load_data('hist.dat', dstype=Data1DInt)
>>> cols = ['rmid', 'sur_bri', 'sur_bri_err'] >>> load_data(2, 'profile.dat', colkeys=cols)