sherpa.astro.ui.load_data(id, filename=None, *args, **kwargs)

Load a data set from a file.

This loads a data set from the file, trying in order load_pha, load_image, load_table, then load_ascii.

  • id (int or str, optional) – The identifier for the data set to use. If not given then the default identifier is used, as returned by get_default_id.
  • filename – A file name or a data structure representing the data to use, as used by the I/O backend in use by Sherpa: e.g. a PHACrateDataset, TABLECrate, or IMAGECrate for crates, as used by CIAO, or a list of AstroPy HDU objects.
  • args – The arguments supported by load_pha, load_image, load_table, and load_ascii.
  • kwargs – The keyword arguments supported by load_pha, load_image, load_table, and load_ascii.

The type of the returned object is controlled by the dstype parameter.

Return type:


See also

Create a data set from array values.
Load an ASCII file as a data set.
Load an image as a data set.
Load a PHA data set.
Load a FITS binary file as a data set.
Set a data set.
Create a sherpa data object from a file.


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.


>>> load_data('tbl.dat')
>>> load_data('hist.dat', dstype=Data1DInt)
>>> load_data('img', 'img.fits')
>>> load_data('bg', 'img_bg.fits')
>>> cols = ['rmid', 'sur_bri', 'sur_bri_err']
>>> load_data(2, 'profile.fits', colkeys=cols)