Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: December 2013

URL: http://cxc.harvard.edu/sherpa/ahelp/set_filter.html
Jump to: Description · Examples · See Also


AHELP for CIAO 4.6 Sherpa v2

set_filter

Context: filtering

Synopsis

Apply user-defined filter to a data set

Syntax

set_filter( [id,] val [,bkg_id=None, ignore=False] )

Description

The set_filter command applies a user-defined array of filter flags to a data set, overriding any filter contained within the PHA file. If the 'ignore' keyword argument is set to 'False' (default), an element in a filter array set to a value of 1 or greater marks a 'good' bin and an element set to less than 1 marks a 'bad' bin; the opposite holds if the ignore flag is set to 'True'. To filter a data set with an array contained in a FITS table, column-based ASCII table, or FITS image, use the load_filter command (see "ahelp load_filter").

  • id - the id of the dataset to use; if not given, uses the default dataset id (id=1 by default, see "ahelp get_default_id")
  • val - an array defining the filter, which must be the same length as the input data set. An element set to x >= 1 marks a good bin and an element set to x < 1 marks a bad bin.
  • bkg_id - the id of the background, if the filter is to be applied to the background data; default=None
  • ignore - True/False Boolean switch to indicate which elements in a filter array should be used to filter the associated data set; default is False

Example 1

sherpa> set_filter([1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0,
...] )

The set_filter command is used to apply a user-defined array of filter flags to default data set id=1; the filter array contains as many elements as the data array. Since the 'ignore' argument is set to 'False' by default, only the elements in the filter array containing values of 1 will be retained in the corresponding places in the data set.

Example 2

sherpa> c=[0,0,1,1,0,1]
sherpa> set_filter(2, c, bkg_id=1)

The 6-element array of filter flags stored in variable 'c' is applied to the background of data set 2 with the set_filter command. The filtered background data array contains the values corresponding only to the third, fourth, and sixth elements of the original 6-element data array.

Example 3

sherpa> f=[0,1,1,1,0,1]
sherpa> set_filter(f, ignore=True)
sherpa> print(get_filter())
0.0000,4.0000

The 6-element array of filter flags stored in variable 'f' is applied to data set 1 with the set_filter command, using an 'ignore' setting of 'True'. The filtered data array contains the values corresponding only to the first and fifth elements of the original 6-element data array.

Example 4

sherpa> c=[0,0,1,1,0,1]
sherpa> set_filter(c, ignore=False)
sherpa> print(get_filter())
2.0000,3.0000,5.0000

The 6-element array of filter flags stored in variable 'c' is applied to data set 1 with the set_filter command, using the 'ignore' setting of 'False'. The filtered data array contains the values corresponding only to the third, fourth, and sixth elements of the original 6-element data array.

See Also

confidence
set_conf_opt, set_covar_opt, set_proj_opt
data
copy_data, dataspace1d, dataspace2d, delete_data, fake, get_axes, get_bkg_plot, get_counts, get_data, get_data_plot, get_dep, get_dims, get_error, get_quality, get_specresp, get_staterror, get_syserror, group, load_ascii, load_data, load_grouping, load_quality, set_areascal, set_arf, set_backscal, set_bkg, set_coord, set_counts, set_data, set_exposure, set_grouping, set_quality, set_rmf, set_staterror, set_syserror, ungroup, unpack_ascii, unpack_data
filtering
get_filter, load_filter
info
get_default_id, list_data_ids, list_response_ids
methods
set_iter_method, set_iter_method_opt, set_method, set_method_opt
modeling
clean, get_par, set_bkg_model, set_full_model, set_par, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset
plotting
plot_data, set_xlinear, set_xlog, set_ylinear, set_ylog
saving
save_error, save_filter, save_grouping, save_quality, save_staterror, save_syserror
statistics
set_prior, set_sampler, set_sampler_opt, set_stat
utilities
calc_data_sum, calc_data_sum2d, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum2d, calc_source_sum2d, get_rate, set_analysis, set_default_id
visualization
contour, contour_data, contour_ratio, get_ratio, get_resid, histogram1d, histogram2d, image_data, image_setregion, rebin

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email:   cxcweb@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2014. All rights reserved.