Last modified: December 2022

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/unpack_arrays.html
AHELP for CIAO 4.15 Sherpa

unpack_arrays

Context: data

Synopsis

Create a sherpa data object from arrays of data.

Syntax

unpack_arrays(*args)

args - array_like

Description

The object returned by `unpack_arrays` can be used in a `set_data` call.


Examples

Example 1

Create a 1D (unbinned) data set from the values in the x and y arrays. Use the returned object to create a data set labelled "oned":

>>> x = [1, 3, 7, 12]
>>> y = [2.3, 3.2, -5.4, 12.1]
>>> dat = unpack_arrays(x, y)
>>> set_data("oned", dat)

Example 2

Include statistical errors on the data:

>>> edat = unpack_arrays(x, y, dy)

Example 3

Create a "binned" 1D data set, giving the low, and high edges of the independent axis (xlo and xhi respectively) and the dependent values for this grid (y):

>>> hdat = unpack_arrays(xlo, xhi, y, Data1DInt)

Example 4

Create a 3 column by 4 row image:

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

PARAMETERS

The parameters for this function are:

Parameter Definition
args Arrays of data. The order, and number, is determined by the `dstype` parameter, and listed in the `load_arrays` routine.
dstype The data set type. The default is `Data1D` and values include: `Data1D` , `Data1DInt` , `Data2D` , `Data2DInt` , `DataPHA` , and `DataIMG` . The class is expected to be derived from `sherpa.data.BaseData` .

Return value

The return value from this function is:

The data set object matching the requested `dstype` parameter.


Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

data
dataspace1d, dataspace2d, datastack, fake, load_arf, load_arrays, load_ascii, load_bkg, load_bkg_arf, load_bkg_rmf, load_data, load_grouping, load_image, load_multi_arfs, load_multi_rmfs, load_pha, load_quality, load_rmf, load_staterror, load_syserror, load_table, pack_image, pack_pha, pack_table, unpack_arf, unpack_ascii, unpack_bkg, unpack_data, unpack_image, unpack_pha, unpack_rmf, unpack_table
filtering
load_filter
info
get_default_id, list_bkg_ids, list_data_ids
modeling
add_model, add_user_pars, load_table_model, load_template_interpolator, load_template_model, load_user_model, save_model, save_source
saving
save_arrays, save_data, save_delchi, save_error, save_filter, save_grouping, save_image, save_pha, save_quality, save_resid, save_staterror, save_syserror, save_table
statistics
load_user_stat