sherpa.astro.ui.load_arrays(id, *args)

Create a data set from array values.

  • id (int or str) – The identifier for the data set to use.
  • *args – Two or more arrays, followed by the type of data set to create.


Sherpa currently does not support numpy masked arrays. Use the set_filter function and note that it follows a different convention by default (a positive value or True for a “bad” channel, 0 or False for a good channel).

See also

Copy a data set to a new identifier.
Delete a data set by identifier.
Return the data set by identifier.
Create a data set from a file.
Set a data set.
Create a sherpa data object from arrays of data.


The data type identifier, which defaults to Data1D, determines the number, and order, of the required inputs.

Identifier Required Fields Optional Fields
Data1D x, y statistical error, systematic error
Data1DInt xlo, xhi, y statistical error, systematic error
Data2D x0, x1, y shape, statistical error, systematic error
Data2DInt x0lo, x1lo, x0hi, x1hi, y shape, statistical error, systematic error
DataPHA channel, counts statistical error, systematic error, bin_lo, bin_hi, grouping, quality
DataIMG x0, x1, y shape, statistical error, systematic error

The shape argument should be a tuple giving the size of the data (ny,nx), and for the DataIMG case the arrays are 1D, not 2D.


Create a 1D data set with three points:

>>> load_arrays(1, [10, 12, 15], [4.2, 12.1, 8.4])

Create a 1D data set, with the identifier ‘prof’, from the arrays x (independent axis), y (dependent axis), and dy (statistical error on the dependent axis):

>>> load_arrays('prof', x, y, dy)

Explicitly define the type of the data set:

>>> load_arrays('prof', x, y, dy, Data1D)

Data set 1 is a histogram, where the bins cover the range 1-3, 3-5, and 5-7 with values 4, 5, and 9 respectively.

>>> load_arrays(1, [1, 3, 5], [3, 5, 7], [4, 5, 9], Data1DInt)

Create an image data set:

>>> ivals = np.arange(12)
>>> y, x = np.mgrid[0:3, 0:4]
>>> x = x.flatten()
>>> y = y.flatten()
>>> load_arrays('img', x, y, ivals, (3, 4), DataIMG)