load_data¶
-
sherpa.ui.
load_data
(id, filename=None, ncols=2, colkeys=None, dstype=<class 'sherpa.data.Data1D'>, sep=' ', comment='#', require_floats=True)¶ Load a data set from an ASCII file.
Parameters: - id (int or str) – The identifier for the data set to use.
- filename (str) – The name of the ASCII file to read in.
- ncols (int, optional) – The number of columns to read in (the first
ncols
columns 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, and Data2DInt.
- 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 a ValueError.
Raises: ValueError
– If a column value can not be converted into a numeric value and therequire_floats
parameter is True.See also
get_data()
- Return the data set by identifier.
load_arrays()
- Create a data set from array values.
unpack_arrays()
- Create a sherpa data object from arrays of data.
unpack_data()
- Create 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 filename parameter. If given two un-named arguments, then they are interpreted as the id and filename parameters, respectively. The remaining parameters are expected to be given as named arguments.
See unpack_data for 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)