Filter
- class sherpa.data.Filter[source] [edit on github]
Bases:
objectA class for representing filters of N-Dimensional datasets.
The filter does not know the size of the dataset or the values of the independent axes.
- Attributes:
maskMask array for dependent variable
Methods
apply(-> None)Apply this filter to an array
notice(mins, maxes, axislist[, ignore, ...])Select a range to notice or ignore (remove).
Attributes Summary
Mask array for dependent variable
Methods Summary
apply(-> None)Apply this filter to an array
notice(mins, maxes, axislist[, ignore, ...])Select a range to notice or ignore (remove).
Attributes Documentation
- mask
Mask array for dependent variable
- Returns:
- maskbool or
numpy.ndarray
- maskbool or
Methods Documentation
- apply(array: None) None[source] [edit on github]
- apply(array: Sequence[float] | ndarray) ndarray
Apply this filter to an array
- Parameters:
- arrayarray_like or
None Array to be filtered
- arrayarray_like or
- Returns:
- Raises:
sherpa.utils.err.DataErrThe filter has removed all elements or there is a mismatch between the
maskand thearrayargument.
See also
- notice(mins: Sequence[float] | ndarray, maxes: Sequence[float] | ndarray, axislist: Sequence[Sequence[float] | ndarray], ignore: bool = False, integrated: bool = False) None[source] [edit on github]
Select a range to notice or ignore (remove).
The
axislistargument is expected to be sent the independent axis of aDataobject - so(x, )for one-dimensional data,(xlo, xhi)for integrated one-dimensional data,(x0, x1)for two-dimensional data, and(x0lo, x1lo, x0hi, x1hi)for integrated two-dimensinal data. Theminsandmaxesmust then be set to match this ordering.- Parameters:
- minssequence
The minimum value of the valid range (elements may be None to indicate no lower bound). When not None, it is treated as an inclusive limit, so points >= min are included.
- maxessequence
The maximum value of the valid range (elements may be None to indicate no upper bound). It is treated as an inclusive limit (points <= max) when integrated is False, and an exclusive limit (points < max) when integrated is True.
- axislist: sequence of arrays
The axis to apply the range to. There must be the same number of elements in mins, maxes, and axislist. The number of elements of each element of axislist must also agree (the cell values do not need to match).
- ignorebool,
optional If True the range is to be ignored, otherwise it is included. The default is to include the range.
- integratedbool,
optional Is the data integrated (we have low and high bin edges)? The default is False. When True it is expected that axislist contains a even number of rows, where the odd values are the low edges and the even values the upper edges, and that the mins and maxes only ever contain a single value, given in (None, hi) and (lo, None) ordering.
See also
Examples
Select points in xs which are in the range 1.5 <= x <= 4:
>>> f = Filter() >>> f.mask True >>> xs = [1, 2, 3, 4, 5] >>> f.notice([1.5], [4], (xs, )) >>> f.mask array([False, True, True, True, False])
Filter the data to select all points with x0 >= 1.5 and x1 <= 4:
>>> f = Filter() >>> x0 = [1, 1.4, 1.6, 2, 3] >>> x1 = [2, 2, 4, 4, 6] >>> f.notice([1.5, None], [None, 4], (x0, x1)) >>> f.mask array([False, False, True, True, False])
For integrated data sets the lower and upper edges should be sent separately with the max and min limits, along with setting the integrated flag. The following selects the bins that cover the range 2 to 4 and 1.5 to 3.5:
>>> xlo = [1, 2, 3, 4, 5] >>> xhi = [2, 3, 4, 5, 6] >>> f = Filter() >>> f.notice([None, 2], [4, None], (xlo, xhi), integrated=True) >>> f.mask array([False, True, True, False, False]) >>> f.notice([None, 1.5], [3.5, None], (xlo, xhi), integrated=True) >>> f.mask array([ True, True, True, False, False])