notice
- sherpa.astro.ui.notice(lo=None, hi=None, **kwargs) None
Include data in the fit.
Select one or more ranges of data to include by filtering on the independent axis value. The filter is applied to all data sets.
Changed in version 4.15.0: The change in the filter is now reported for each dataset.
Changed in version 4.14.0: Integrated data sets - so Data1DInt and DataPHA when using energy or wavelengths - now ensure that the
hiargument is exclusive and better handling of theloargument when it matches a bin edge. This can result in the same filter selecting a smaller number of bins than in earlier versions of Sherpa.- Parameters:
lo (number or str, optional) – The lower bound of the filter (when a number) or a string expression listing ranges in the form
a:b, with multiple ranges allowed, where the ranges are separated by a,. The term:bmeans include everything up tob(an exclusive limit for integrated datasets), anda:means include everything that is higher than, or equal to,a.hi (number, optional) – The upper bound of the filter when
lois not a string.bkg_id (int or str, optional) – The filter will be applied to the associated background component of the data set if
bkg_idis set. Only PHA data sets support this option; if not given, then the filter is applied to all background components as well as the source data.
See also
notice_idInclude data for a data set.
sherpa.astro.ui.notice2dInclude a spatial region in an image.
ignoreExclude data from the fit.
show_filterShow any filters applied to a data set.
Notes
The order of
ignoreandnoticecalls is important, and the results are a union, rather than intersection, of the combination.If
noticeis called on an un-filtered data set, then the ranges outside the noticed range are excluded: it can be thought of as ifignorehad been used to remove all data points. Ifnoticeis called after a filter has been applied then the filter is applied to the existing data.For binned data sets, the bin is included if the noticed range falls anywhere within the bin, but excluding the
hivalue (except for PHA data sets when usingchannelunits).The units used depend on the
analysissetting of the data set, if appropriate.To filter a 2D data set by a shape use
notice2d.The report of the change in the filter expression can be controlled with the
SherpaVerbositycontext manager, as shown in the examples below.Examples
Since the
noticecall is applied to an un-filtered data set, the filter chooses only those points that lie within the range 12 <= X <= 18.>>> load_arrays(1, [10, 15, 20, 30], [5, 10, 7, 13]) >>> notice(12, 28) dataset 1: 10:30 -> 15:20 x >>> get_dep(filter=True) array([10, 7])
As no limits are given, the whole data set is included:
>>> notice() dataset 1: 15:20 -> 10:30 x >>> get_dep(filter=True) array([ 5, 10, 7, 13])
The
ignorecall excludes the first two points, but thenoticecall adds back in the second point:>>> ignore(hi=17) dataset 1: 10:30 -> 20:30 x >>> notice(12, 16) dataset 1: 20:30 -> 15:30 x >>> get_dep(filter=True) array([10, 7, 13])
Only include data points in the range 8<=X<=12 and 18<=X=22:
>>> ignore() dataset 1: 15:30 x -> no data >>> notice("8:12, 18:22") dataset 1: no data -> 10 x dataset 1: 10 -> 10,20 x >>> get_dep(filter=True) array([5, 7])
The messages from
noticeandignoreuse the standard Sherpa logging infrastructure, and so can be ignored by usingSherpaVerbosity:>>> from sherpa.utils.logging import SherpaVerbosity >>> with SherpaVerbosity("WARN"): ... notice() ...