Data
- class sherpa.data.Data(name: str, indep: Sequence[Sequence[float] | ndarray] | Sequence[None], y: Sequence[float] | ndarray | None, staterror: Sequence[float] | ndarray | None = None, syserror: Sequence[float] | ndarray | None = None)[source] [edit on github]
Bases:
NoNewAttributesAfterInit,BaseDataGeneric, N-Dimensional data sets.
A data class is the collection of a data space and a number of data arrays for the dependent variable and associated errors.
- Parameters:
- name
str name of this dataset
- indep: tuple of array_like
the tuple of independent arrays.
- yarray_like
The values of the dependent observable. If this is a numpy masked array, the mask will used to initialize a mask.
- staterrorarray_like
the statistical error associated with the data
- syserrorarray_like
the systematic error associated with the data
- name
- Attributes:
depLeft for compatibility with older versions
indepThe grid of the data space associated with this data set.
maskMask array for dependent variable
- ndim
sizeThe number of elements in the data set.
staterrorThe statistical error on the dependent axis, if set.
syserrorThe systematic error on the dependent axis, if set.
yThe dependent axis.
Methods
eval_model(modelfunc)Evaluate the model on the independent axis.
eval_model_to_fit(modelfunc)Evaluate the model on the independent axis after filtering.
get_dep([filter])Return the dependent axis of a data set.
get_dims()Return the dimensions of this data space as a tuple of tuples.
get_error([filter, staterrfunc])Return the total error on the dependent variable.
get_indep([filter])Return the independent axes of a data set.
get_staterror([filter, staterrfunc])Return the statistical error on the dependent axis of a data set.
get_syserror([filter])Return the systematic error on the dependent axis of a data set.
get_y(-> ~numpy.ndarray)Return dependent axis in N-D view of dependent variable
get_yerr([filter, staterrfunc])Return errors in dependent axis in N-D view of dependent variable.
get_ylabel([yfunc])Return label for dependent axis in N-D view of dependent variable.
set_dep(val)Set the dependent variable values.
set_ylabel(label)Set the label for the dependent axis.
apply_filter
ignore
notice
set_indep
to_fit
to_guess
Notes
This class can be extended by classes defining data sets of specific dimensionality. Extending classes should override the
_init_data_spacemethod.This class provides most of the infrastructure for extending classes for free.
Data classes contain a
maskattribute, which can be used ignore certain values in the array when fitting or plotting that data. The convention in Sherpa is thatTruemarks a values as valid andFalseas invalid (note that this is opposite to the numpy convention). When aDatainstance is initialized with a dependent array that has amaskattribute (e.g. numpy masked array), it will attempt to convert that mask to the Sherpa convention and raise a warning otherwise. In any case, the user can setdata.maskafter initialization if that conversion does not yield the expected result.Attributes Summary
Left for compatibility with older versions
The grid of the data space associated with this data set.
Mask array for dependent variable
The dimensionality of the dataset, if defined, or None.
The number of elements in the data set.
The statistical error on the dependent axis, if set.
The systematic error on the dependent axis, if set.
The dependent axis.
Methods Summary
apply_filter(-> None)eval_model(modelfunc)Evaluate the model on the independent axis.
eval_model_to_fit(modelfunc)Evaluate the model on the independent axis after filtering.
get_dep([filter])Return the dependent axis of a data set.
get_dims()Return the dimensions of this data space as a tuple of tuples.
get_error([filter, staterrfunc])Return the total error on the dependent variable.
get_indep([filter])Return the independent axes of a data set.
get_staterror([filter, staterrfunc])Return the statistical error on the dependent axis of a data set.
get_syserror([filter])Return the systematic error on the dependent axis of a data set.
get_y(-> ~numpy.ndarray)Return dependent axis in N-D view of dependent variable
get_yerr([filter, staterrfunc])Return errors in dependent axis in N-D view of dependent variable.
get_ylabel([yfunc])Return label for dependent axis in N-D view of dependent variable.
ignore(*args, **kwargs)notice(mins, maxes[, ignore, integrated])set_dep(val)Set the dependent variable values.
set_indep(val)set_ylabel(label)Set the label for the dependent axis.
to_fit([staterrfunc])to_guess()Attributes Documentation
- dep
Left for compatibility with older versions
- indep
The grid of the data space associated with this data set.
When set, the field must be set to a tuple, even for a one-dimensional data set. The “related” fields such as the dependent axis and the error fields are set to None if their size does not match.
Changed in version 4.14.1: The filter created by
noticeandignoreis now cleared when the independent axis is changed.- Returns:
tupleofarray_like orNone
- mask
Mask array for dependent variable
- Returns:
- maskbool or
numpy.ndarray
- maskbool or
- size
The number of elements in the data set.
- staterror
The statistical error on the dependent axis, if set.
This must match the size of the independent axis.
- syserror
The systematic error on the dependent axis, if set.
This must match the size of the independent axis.
- y
The dependent axis.
If set, it must match the size of the independent axes.
Methods Documentation
- apply_filter(data: None) None[source] [edit on github]
- apply_filter(data: Sequence[float] | ndarray) ndarray
- eval_model(modelfunc: Callable[[...], Sequence[float] | ndarray]) Sequence[float] | ndarray[source] [edit on github]
Evaluate the model on the independent axis.
- eval_model_to_fit(modelfunc: Callable[[...], Sequence[float] | ndarray]) Sequence[float] | ndarray[source] [edit on github]
Evaluate the model on the independent axis after filtering.
- get_dep(filter: bool = False) ndarray | None[source] [edit on github]
Return the dependent axis of a data set.
- Parameters:
- Returns:
- axis:
array The dependent axis values for the data set. This gives the value of each point in the data set.
- axis:
See also
get_indepReturn the independent axis of a data set.
get_errorReturn the errors on the dependent axis of a data set.
get_staterrorReturn the statistical errors on the dependent axis of a data set.
get_syserrorReturn the systematic errors on the dependent axis of a data set.
- get_dims() tuple[int, ...][source] [edit on github]
Return the dimensions of this data space as a tuple of tuples. The first element in the tuple is a tuple with the dimensions of the data space, while the second element provides the size of the dependent array.
- Returns:
- get_error(filter=False, staterrfunc=None)[source] [edit on github]
Return the total error on the dependent variable.
- Parameters:
- Returns:
See also
get_depReturn the independent axis of a data set.
get_staterrorReturn the statistical errors on the dependent axis of a data set.
get_syserrorReturn the systematic errors on the dependent axis of a data set.
- get_indep(filter: bool = False) tuple[ndarray, ...] | tuple[None, ...][source] [edit on github]
Return the independent axes of a data set.
- Parameters:
- Returns:
- axis:
tupleofarrays The independent axis values for the data set. This gives the coordinates of each point in the data set.
- axis:
See also
get_depReturn the dependent axis of a data set.
- get_staterror(filter: bool = False, staterrfunc: Callable[[Sequence[float] | ndarray], Sequence[float] | ndarray] | None = None) Sequence[float] | ndarray | None[source] [edit on github]
Return the statistical error on the dependent axis of a data set.
- Parameters:
- Returns:
See also
get_errorReturn the errors on the dependent axis of a data set.
get_indepReturn the independent axis of a data set.
get_syserrorReturn the systematic errors on the dependent axis of a data set.
- get_syserror(filter: bool = False) ndarray | None[source] [edit on github]
Return the systematic error on the dependent axis of a data set.
- Parameters:
- Returns:
See also
get_errorReturn the errors on the dependent axis of a data set.
get_indepReturn the independent axis of a data set.
get_staterrorReturn the statistical errors on the dependent axis of a data set.
- get_y(filter: bool, yfunc: None, use_evaluation_space: bool = False) ndarray[source] [edit on github]
- get_y(filter: bool, yfunc: Callable[[...], Sequence[float] | ndarray], use_evaluation_space: bool = False) tuple[ndarray, Sequence[float] | ndarray]
Return dependent axis in N-D view of dependent variable
- get_yerr(filter=False, staterrfunc=None)[source] [edit on github]
Return errors in dependent axis in N-D view of dependent variable.
- Parameters:
- filter
- staterrfunc
- Returns:
- get_ylabel(yfunc=None) str[source] [edit on github]
Return label for dependent axis in N-D view of dependent variable.
- Parameters:
- yfunc
Unused.
- Returns:
- label:
str The label.
- label:
See also
- ignore(*args, **kwargs) None[source] [edit on github]
- set_dep(val: Sequence[float] | ndarray | float) None[source] [edit on github]
Set the dependent variable values.
- Parameters:
- valsequence or
number If a number then it is used for each element.
- valsequence or
- set_indep(val: tuple[Sequence[float] | ndarray, ...] | tuple[None, ...]) None[source] [edit on github]
- set_ylabel(label: str) None[source] [edit on github]
Set the label for the dependent axis.
Added in version 4.17.0.
- Parameters:
- label: str
The new label.
See also