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.Data1Dinstance, but this can be changed by supplying the required class as the last argument (anything that is derived fromsherpa.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_dataroutine 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.Data1Dinstance from the data in the arraysxandy(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.Data2Dinstance with the independent axesx0andx1, and dependent axisy:>>> 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)