read_arrays

sherpa.astro.io.read_arrays(*args) Data[source] [edit on github]

Create a dataset from multiple arrays.

The return value defaults to a sherpa.data.Data1D instance, but this can be changed by supplying the required class as the last argument (anything that is derived from sherpa.data.Data).

Parameters:

*args – There must be at least one argument. The number of arguments depends on the data type being read in. The supported argument types depends on the I/O backend in use (as supported by the get_column_data routine provided by the backend).

Returns:

data

Return type:

a sherpa.data.Data derived object

Examples

The following examples do not contain argument types specific to a particular I/O backend.

Create a sherpa.data.Data1D instance from the data in the arrays x and y (taken to be the independent and dependent axes respectively):

>>> import numpy as np
>>> from sherpa.astro.io import read_arrays
>>> x = np.arange(10)
>>> y = np.random.normal(size=10)
>>> d = read_arrays(x, y)

As in the previous example, but explicitly declaring the data type:

>>> from sherpa import data
>>> d = read_arrays(x, y, data.Data1D)

Create a sherpa.data.Data2D instance with the independent axes x0 and x1, and dependent axis y:

>>> x1, x0 = np.mgrid[20:30, 5:20]
>>> y = np.sqrt((x0 - 10)**2 + (x1 - 31)**2)
>>> d = read_arrays(x0.flatten(), x1.flatten(), y.flatten(), data.Data2D)