DataARF
- class sherpa.astro.data.DataARF(name, energ_lo, energ_hi, specresp, bin_lo=None, bin_hi=None, exposure=None, header=None, ethresh=None)[source] [edit on github]
Bases:
DataOgipResponse
ARF data set.
The ARF format is described in OGIP documents [CAL_92_002] and [CAL_92_002a].
- Parameters
name (str) – The name of the data set; often set to the name of the file containing the data.
energ_lo (numpy.ndarray) – The values of the ENERG_LO, ENERG_HI, and SPECRESP columns for the ARF. The ENERG_HI values must be greater than the ENERG_LO values for each bin, and the energy arrays must be in increasing or decreasing order.
energ_hi (numpy.ndarray) – The values of the ENERG_LO, ENERG_HI, and SPECRESP columns for the ARF. The ENERG_HI values must be greater than the ENERG_LO values for each bin, and the energy arrays must be in increasing or decreasing order.
specresp (numpy.ndarray) – The values of the ENERG_LO, ENERG_HI, and SPECRESP columns for the ARF. The ENERG_HI values must be greater than the ENERG_LO values for each bin, and the energy arrays must be in increasing or decreasing order.
bin_lo (array or None, optional) –
bin_hi (array or None, optional) –
exposure (number or None, optional) – The exposure time for the ARF, in seconds.
header (dict or None, optional) –
ethresh (number or None, optional) – If set it must be greater than 0 and is the replacement value to use if the lowest-energy value is 0.0.
- Raises
sherpa.utils.err.DataErr – This is raised if the energy arrays do not follow some of the OGIP standards.
Notes
There is limited checking that the ARF matches the OGIP standard, but as there are cases of released data products that do not follow the standard, these checks can not cover all cases.
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.
Used for compatibility, in particular for __str__ and __repr__
Property kept for compatibility
Property kept for compatibility
The dependent axis.
Methods Summary
apply_arf
(src, *args, **kwargs)Fold the source array src through the ARF and return the result
apply_filter
(data)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
([filter])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_evaluation_indep
([filter, model, ...])get_filter
([format, delim])Return the data filter as a string.
Return the data filter as a string along with the units.
get_img
([yfunc])Return 1D dependent variable as a 1 x N image
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 statistical error on the dependent axis of a data set.
get_x
([filter, model, use_evaluation_space])get_xerr
([filter, model])Return linear view of bin size in independent axis/axes"
Return label for linear view of independent axis/axes
get_y
([filter, yfunc, use_evaluation_space])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
Return label for dependent axis in N-D view of dependent variable"
ignore
(*args, **kwargs)notice
([bin_mask])Notice or ignore the given range.
set_dep
(val)Set the dependent variable values.
set_indep
(val)to_component_plot
([yfunc, staterrfunc])to_fit
([staterrfunc])to_guess
()to_plot
([yfunc, staterrfunc])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
notice
andignore
is now cleared when the independent axis is changed.- Return type
tuple of array_like
- mask
Mask array for dependent variable
- Returns
mask
- Return type
- ndim = 1
The dimensionality of the dataset, if defined, or None.
- size
The number of elements in the data set.
- Returns
size – If the size has not been set then None is returned.
- Return type
int or None
- specresp
- 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.
- x
Used for compatibility, in particular for __str__ and __repr__
- xhi
Property kept for compatibility
- xlo
Property kept for compatibility
- y
The dependent axis.
If set, it must match the size of the independent axes.
Methods Documentation
- apply_arf(src, *args, **kwargs)[source] [edit on github]
Fold the source array src through the ARF and return the result
- apply_filter(data) [edit on github]
- eval_model(modelfunc) [edit on github]
Evaluate the model on the independent axis.
- eval_model_to_fit(modelfunc) [edit on github]
Evaluate the model on the independent axis after filtering.
- get_bounding_mask() [edit on github]
- get_dep(filter=False)[source] [edit on github]
Return the dependent axis of a data set.
- Parameters
filter (bool, optional) – Should the filter attached to the data set be applied to the return value or not. The default is
False
.- Returns
axis – The dependent axis values for the data set. This gives the value of each point in the data set.
- Return type
array
See also
get_indep
Return the independent axis of a data set.
get_error
Return the errors on the dependent axis of a data set.
get_staterror
Return the statistical errors on the dependent axis of a data set.
get_syserror
Return the systematic errors on the dependent axis of a data set.
- get_dims(filter=False) [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.
- Return type
- get_error(filter=False, staterrfunc=None) [edit on github]
Return the total error on the dependent variable.
- Parameters
- Returns
axis – The error for each data point, formed by adding the statistical and systematic errors in quadrature.
- Return type
array or
None
See also
get_dep
Return the independent axis of a data set.
get_staterror
Return the statistical errors on the dependent axis of a data set.
get_syserror
Return the systematic errors on the dependent axis of a data set.
- get_evaluation_indep(filter=False, model=None, use_evaluation_space=False) [edit on github]
- get_filter(format='%.4f', delim=':') [edit on github]
Return the data filter as a string.
For each noticed range the filter is reported as starting at the low edge of the first bin and ends at the upper edge of the last bin in the range.
Changed in version 4.14.0: Prior to 4.14.0 the filter used the mid-point of the bin, not its low or high value.
- Parameters
- Returns
filter – The filter, represented as a collection of ranges separated by commas.
- Return type
See also
Examples
>>> xlo = np.asarray([1, 2, 3, 5, 6]) >>> xhi = xlo + 1 >>> y = np.ones(5) >>> d = Data1DInt('example', xlo, xhi, y) >>> d.get_filter() '1.0000:7.0000' >>> d.ignore(2.5, 4.5) >>> d.get_filter() '1.0000:2.0000,5.0000:7.0000'
>>> d.get_filter(format='%i', delim='-') '1-2,5-7'
- get_filter_expr() [edit on github]
Return the data filter as a string along with the units.
This is a specialised version of get_filter which adds the axis units.
- Returns
filter – The filter, represented as a collection of single values or ranges, separated by commas.
- Return type
See also
Examples
>>> d.get_filter_expr() '1.0000-2.0000,5.0000-6.0000 x'
- get_img(yfunc=None) [edit on github]
Return 1D dependent variable as a 1 x N image
- Parameters
yfunc –
- get_imgerr() [edit on github]
- get_indep(filter=False)[source] [edit on github]
Return the independent axes of a data set.
- Parameters
filter (bool, optional) – Should the filter attached to the data set be applied to the return value or not. The default is
False
.- Returns
axis – The independent axis values for the data set. This gives the coordinates of each point in the data set.
- Return type
tuple of arrays
See also
get_dep
Return the dependent axis of a data set.
- get_staterror(filter=False, staterrfunc=None) [edit on github]
Return the statistical error on the dependent axis of a data set.
- Parameters
- Returns
axis – The statistical error for each data point. A value of
None
is returned if the data set has no statistical error array andstaterrfunc
isNone
.- Return type
array or
None
See also
get_error
Return the errors on the dependent axis of a data set.
get_indep
Return the independent axis of a data set.
get_syserror
Return the systematic errors on the dependent axis of a data set.
- get_syserror(filter=False) [edit on github]
Return the statistical error on the dependent axis of a data set.
- Parameters
filter (bool, optional) – Should the filter attached to the data set be applied to the return value or not. The default is
False
.- Returns
axis – The systematic error for each data point. A value of
None
is returned if the data set has no systematic errors.- Return type
array or None
See also
get_error
Return the errors on the dependent axis of a data set.
get_indep
Return the independent axis of a data set.
get_staterror
Return the statistical errors on the dependent axis of a data set.
- get_x(filter=False, model=None, use_evaluation_space=False) [edit on github]
- get_xerr(filter=False, model=None) [edit on github]
Return linear view of bin size in independent axis/axes”
- Parameters
filter –
yfunc –
- get_xlabel()[source] [edit on github]
Return label for linear view of independent axis/axes
- get_y(filter=False, yfunc=None, use_evaluation_space=False) [edit on github]
Return dependent axis in N-D view of dependent variable”
- Parameters
filter –
yfunc –
use_evaluation_space –
- get_yerr(filter=False, staterrfunc=None) [edit on github]
Return errors in dependent axis in N-D view of dependent variable
- Parameters
filter –
staterrfunc –
- get_ylabel()[source] [edit on github]
Return label for dependent axis in N-D view of dependent variable”
- Parameters
yfunc –
- ignore(*args, **kwargs) [edit on github]
- notice(bin_mask=None)[source] [edit on github]
Notice or ignore the given range.
Ranges are inclusive for the lower limit and exclusive for the upper limit.
Changed in version 4.14.0: Filtering Data1DInt datasets has been improved to fix a number of corner cases. As part of this the upper limit has been changed to be exclusive whereas previously it was not obvious what the filter was doing.
- Parameters
xlo (number or None, optional) – The range to change. A value of None means the minimum or maximum permitted value.
xhi (number or None, optional) – The range to change. A value of None means the minimum or maximum permitted value.
ignore (bool, optional) – Set to True if the range should be ignored. The default is to notice the range.
See also
Notes
If no ranges have been ignored then a call to
notice
withignore=False
will select just thelo
tohi
range, and exclude any bins outside this range. If there has been a filter applied then the rangelo
tohi
will be added to the range of noticed data (whenignore=False
).Examples
>>> edges = np.arange(0.4, 2.6, 0.2) >>> xlo, xhi = edges[:-1], edges[1:] >>> y = np.ones_like(xlo) >>> d = Data1DInt('example', xlo, xhi, y) >>> d.xlo[0], d.xhi[-1] (0.4, 2.400000000000001) >>> d.get_filter(format='%.1f') '0.4:2.4' >>> d.notice(0.8, 1.9) >>> d.get_filter(format='%.1f') '0.8:2.0'
>>> d.notice() >>> d.get_filter(format='%.1f') '0.4:2.4'
- set_dep(val) [edit on github]
Set the dependent variable values.
- Parameters
val (sequence or number) – If a number then it is used for each element.
- set_indep(val) [edit on github]
- to_component_plot(yfunc=None, staterrfunc=None) [edit on github]
- to_fit(staterrfunc=None) [edit on github]
- to_guess() [edit on github]
- to_plot(yfunc=None, staterrfunc=None) [edit on github]