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

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


AHELP for CIAO 4.9 Sherpa v1

get_bkg_plot

Context: data

Synopsis

Return the data and preferences defining a background plot.

Syntax

get_bkg_plot( [id, bkg_id] )
get_bkg_source_plot( [id, lo, hi, bkg_id] )
get_bkg_model_plot( [id, bkg_id] )
get_bkg_fit_plot( [id, bkg_id] )
get_bkg_resid_plot( [id, bkg_id] )
get_bkg_ratio_plot( [id, bkg_id] )
get_bkg_chisqr_plot( [id, bkg_id] )
get_bkg_delchi_plot( [id, bkg_id] )

Description

  • id - the id of the data set to use; if not given, uses the default dataset id (id=1 by default, see "ahelp get_default_id")
  • bkg_id - the id of the background to use, e.g. if more than one background is associated with the data; default is the first background dataset loaded in the Sherpa session
  • lo - low bound of the desired plotting range; default=None
  • hi - high bound of the desired plotting range; default= None

get_bkg_plot

The get_bkg_plot() function returns the data and preferences defining a plot of a background associated with a source data set. The function lists the x and y data arrays used in the background plot created with plot_bkg() (e.g. counts/sec/keV vs. energy), in addition to the values for the x label, y label, units, title, and other plotting preferences (such as linestyle, linethickness, etc.). The information returned by get_bkg_plot() may be stored in a variable, or printed to the screen, as shown in the examples section.

get_bkg_source_plot, get_bkg_model_plot

The get_bkg_source_plot() and get_bkg_model_plot() functions return the data and preferences defining a plot of an unconvolved and convolved background model, repspectively. Once a model has been assigned to a background associated with a data set, these functions can be used to list the x and y data arrays used in the background model plot created with plot_bkg_source() or plot_bkg_model(), in addition to the values for the x label, y label, units, title, and other plotting preferences (such as linestyle, linethickness, etc.). The information returned by these functions may be stored in a variable, or printed to the screen, as shown in the examples section.

Plot attributes returned by get_bkg_source_plot:

  • title - title of plot
  • xlabel - x axis label
  • ylabel - y axis label
  • units - units of grid
  • xlo - grid array, low bins
  • xhi - grid array, high bins
  • flux - unconvolved counts
  • y - convolved counts

get_bkg_fit_plot

The get_bkg_fit_plot() function returns the data and preferences defining the 'bkgdataplot' and 'bkgmodelplot' which together produce the plot of a model fit to a background data set. Once a model is assigned to a background associated with a source data set, this command can be used to list the x, y, x error, and y error data arrays used in the background data and model plots, in addition to the values for the x label, y label, units, title, and other plotting preferences (such as linestyle, linethickness, etc.). The information returned by get_bkg_fit_plot() may be stored in a variable, or printed to the screen, as shown in the examples section. The background data, the model assigned to the background, and the fit of the model to the background can be visualized with plot_bkg(), plot_bkg_model(), and plot_bkg_fit(), respectively.

get_bkg_resid_plot

The get_bkg_resid_plot() function returns the data and preferences defining a plot of data-minus-model fit residuals for a 1-D background data set. Once a model is assigned to a background associated with a source data set, this command can be used to list the x, y, x error, and y error data arrays used in the background fit residuals plot created with plot_bkg_resid(), in addition to the values for the x label, y label, units, title, and other plotting preferences (such as linestyle, linethickness, etc.). The information returned by get_bkg_resid_plot() may be stored in a variable, or printed to the screen, as shown in the examples section.

get_bkg_ratio_plot

The get_bkg_ratio_plot() function returns the data and preferences defining a plot of the (data/model) ratio for a 1-D background data set. Once a model is assigned to a background associated with a source data set, this command can be used to list the x, y, x error, and y error data arrays used in the background ratio plot created with plot_bkg_ratio(), in addition to the values for the x label, y label, units, title, and other plotting preferences (such as linestyle, linethickness, etc.). The information returned by get_bkg_ratio_plot() may be stored in a variable, or printed to the screen, as shown in the examples section.

get_bkg_chisqr_plot

The get_bkg_chisqr_plot() command returns the data and preferences defining a plot of the chi^2 of a background data set, where the quantity 'chi^2' represents the background-minus-model fit residuals divided by background uncertainties, the quantity squared. Once a model is assigned to a background associated with a source data set, this command can be used to list the x, y, x error, and y error data arrays used in the chi^2 plot created with plot_bkg_chisqr(), in addition to the values for the x label, y label, title, and other plotting preferences. The information returned by get_bkg_chisqr_plot() may be stored in a variable, or printed to the screen, as shown in the examples section.

get_bkg_delchi_plot

The get_bkg_delchi_plot() command returns the data and preferences defining a plot of the delta chi of a background data set, where the quantity 'delta chi' represents the background-minus-model fit residuals divided by background uncertainties. Once a model is assigned to a background associated with a source data set, this command can be used to list the x, y, x error, and y error data arrays used in the delta chi plot created with plot_bkg_delchi(), in addition to the values for the x label, y label, title, and other plotting preferences. The information returned by get_bkg_delchi_plot() may be stored in a variable, or printed to the screen, as shown in the examples section.

Example 1

sherpa> get_bkg_plot()

When called with no arguments, get_bkg_plot() returns the data and preferences defining a plot of the default background for the default data set. If a data set ID is specified without a background ID, the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot= get_bkg_plot()
sherpa> print(bplot)
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.      0.      0.     ...,  0.0012  0.      0.0921]
yerr   = [ 0.0045  0.0023  0.0023 ...,  0.0028  0.0023  0.0118]
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Counts/sec/keV
title  = simple_bkg.pi
plot_prefs = {'errstyle': 'line', 'symbolfill': False, 'symbolstyle': 4, 'linestyle': 0, 'symbolsize': 3, 'yerrorbars': True}

sherpa> get_bkg_plot(2).title
1843_bkg.pi

sherpa> get_bkg_plot(2,2).title
1843_bkg2.pi

Example 2

sherpa> get_bkg_source_plot()

When called with no arguments, get_bkg_source_plot() returns the the data and preferences defining a plot of the unconvolved background model for the default background. If a data set ID is specified without a background ID, the unconvolved model for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> set_bkg_model(1, "const1d.c1", 1)
sherpa> set_bkg_model(2, "const1d.c2_1", 1)
sherpa> set_bkg_model(2, "const1d.c2_2", 2)

sherpa> bplot_source=get_bkg_source_plot()
sherpa> print(bplot_source)
xlo    = [  0.3    0.31   0.32 ...,  10.97  10.98  10.99]
xhi    = [  0.31   0.32   0.33 ...,  10.98  10.99  11.  ]
flux   = [ 1.  1.  1. ...,  1.  1.  1.]
y      = [ 0.01  0.01  0.01 ...,  0.01  0.01  0.01]
xlabel = Energy (keV)
ylabel = Photons/sec/keV/cm^2
units  = energy
title  = Source Model of simple_bkg.pi
plot_prefs = {'symbolstyle': 0, 'linethickness': 3, 'linestyle': 1,
'linecolor': 'red'}

sherpa> get_bkg_source_plot(2).title
Source Model of 1843_bkg.pi

sherpa> get_bkg_source_plot(2,2).title
Source Model of 1843_bkg2.pi

Example 3

sherpa> get_bkg_model_plot()

When called with no arguments, get_bkg_model_plot() returns the data and preferences defining a plot of the convolved background model for the default background. If a data set ID is specified without a background ID, the convolved model for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> set_bkg_model(1, "const1d.c1", 1)

sherpa> bplot_model=get_bkg_model_plot()
sherpa> print(bplot_model)
xlo    = [  7.3000e-03   1.4600e-02   2.9200e-02 ...,   1.4907e+01   1.4921e+01
   1.4936e+01]
xhi    = [  1.4600e-02   2.9200e-02   4.3800e-02 ...,   1.4921e+01   1.4936e+01
   1.4950e+01]
y      = [ 0.  0.  0. ...,  0.  0.  0.]
xlabel = Energy (keV)
ylabel = Counts/sec/keV
title  = Model
histo_prefs = {'linethickness': 2, 'linecolor': 'red'}

Example 4

sherpa> get_bkg_fit_plot()

When called with no arguments, get_bkg_fit_plot() returns the data and preferences defining a plot of a model fit to the default background data set. If a data set ID is specified without a background ID, the model fit to the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot_fit=get_bkg_fit_plot()
sherpa> print(bplot_fit)
dataplot   = simple_bkg.pi
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.      0.      0.     ...,  0.0012  0.      0.0921]
yerr   = [ 0.0045  0.0023  0.0023 ...,  0.0028  0.0023  0.0118]
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Counts/sec/keV
title  = simple_bkg.pi
plot_prefs = {'errstyle': 'line', 'symbolfill': False, 'symbolstyle': 4, 'linestyle': 0, 'symbolsize': 3, 'yerrorbars': True}

modelplot  = Background Model Contribution
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.  0.  0. ...,  0.  0.  0.]
yerr   = None
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Counts/sec/keV
title  = Background Model Contribution
plot_prefs = {'symbolstyle': 0, 'linethickness': 3, 'linestyle': 1, 'linecolor': 'red'}

Example 5

sherpa> get_bkg_resid_plot()

When called with no arguments, get_bkg_resid_plot() returns the data and preferences defining a plot of the background model fit residuals for the default background data set. If a data set ID is specified without a background ID, the model fit residuals for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot_resid=get_bkg_resid_plot()
sherpa> print(bplot_resid)
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.      0.      0.     ...,  0.0012  0.      0.0921]
yerr   = [ 0.0045  0.0023  0.0023 ...,  0.0028  0.0023  0.0118]
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Counts/sec/keV
title  = Residuals of simple_bkg.pi - Bkg Model
plot_prefs = {'symbolfill': False, 'errstyle': 'line', 'yerrorbars': True, 'xaxis': True, 'symbolstyle': 2, 'linestyle': 0, 'xerrorbars': True, 'symbolsize': 3}

Example 6

sherpa> get_bkg_ratio_plot()

When called with no arguments, get_bkg_ratio_plot() returns the data and preferences defining a plot of the background-to-model ratio for the default background data set. If a data set ID is specified without a background ID, the ratio for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot_ratio=get_bkg_ratio_plot()
sherpa> print(bplot_ratio)
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.  0.  0. ...,  0.  0.  0.]
yerr   = [ 0.0045  0.0023  0.0023 ...,  0.0028  0.0023  0.0118]
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Data / Model
title  = Ratio of simple_bkg.pi : Bkg Model
plot_prefs = {'symbolfill': False, 'ratioline': True, 'errstyle': 'line', 'yerrorbars': True, 'symbolstyle': 2, 'linestyle': 0, 'xerrorbars': True, 'symbolsize': 3}

Example 7

sherpa> get_bkg_chisqr_plot()

When called with no arguments, get_bkg_chisqr_plot() returns the data and preferences defining a plot of the chi^2 of the default background data set. If a data set ID is specified without a background ID, the chi^2 for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot_chisqr=get_bkg_chisqr_plot()
sherpa> print(bplot_chisqr)
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [  0.       0.       0.     ...,   0.1853   0.      60.6268]
yerr   = None
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = chi2
title  = chi2 of simple_bkg.pi
plot_prefs = {'symbolstyle': 0, 'linethickness': 3, 'linestyle': 1, 'linecolor': 'red'}

Example 8

sherpa> get_bkg_delchi_plot()

When called with no arguments, get_bkg_delchi_plot() returns the data and preferences defining a plot of the delta chi residuals of the default background data set. If a data set ID is specified without a background ID, the delta chi residuals for the first background loaded for that data set is returned. If a background other than the default is desired, e.g. if more than one is associated with a data set, then both the data set ID and background ID must be specified.

sherpa> bplot_delchi=get_bkg_delchi_plot()
sherpa> print(bplot_delchi)
x      = [  1.0950e-02   2.1900e-02   3.6500e-02 ...,   1.4914e+01   1.4928e+01
   1.4943e+01]
y      = [ 0.      0.      0.     ...,  0.4305  0.      7.7863]
yerr   = [ 1.  1.  1. ...,  1.  1.  1.]
xerr   = [ 0.0073  0.0146  0.0146 ...,  0.0146  0.0146  0.0146]
xlabel = Energy (keV)
ylabel = Sigma
title  = Sigma Residuals of simple_bkg.pi
plot_prefs = {'symbolfill': False, 'errstyle': 'line', 'yerrorbars': True, 'xaxis': True, 'symbolstyle': 2, 'linestyle': 0, 'xerrorbars': True, 'symbolsize': 3}

Example 9

sherpa> get_bkg_*_plot().plot_prefs

This command lists the library of plotting preferences available for the get_bkg_*_plot() functions, and can be used to modify the plot settings:

sherpa> get_bkg_plot().plot_prefs
            
{'errstyle': 'line',
 'linestyle': 0,
 'symbolfill': False,
 'symbolsize': 3,
 'symbolstyle': 4,
 'yerrorbars': True}

sherpa> get_bkg_plot().plot_prefs["linestyle"]=3

sherpa> get_bkg_plot().plot_prefs
            
{'errstyle': 'line',
 'linestyle': 3,
 'symbolfill': False,
 'symbolsize': 3,
 'symbolstyle': 4,
 'yerrorbars': True}

Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

confidence
get_conf, get_covar, get_int_proj, get_int_unc, get_proj, get_reg_proj, get_reg_unc
contrib
get_chart_spectrum, get_data_prof, get_data_prof_prefs, get_delchi_prof, get_delchi_prof_prefs, get_fit_prof, get_model_prof, get_model_prof_prefs, get_resid_prof, get_resid_prof_prefs, get_source_prof, get_source_prof_prefs, plot_chart_spectrum, prof_data, prof_delchi, prof_fit, prof_fit_delchi, prof_fit_resid, prof_model, prof_resid, prof_source
data
copy_data, dataspace1d, dataspace2d, datastack, delete_data, fake, get_areascal, get_arf, get_arf_plot, get_axes, get_backscal, get_bkg, get_bkg_scale, get_coord, get_counts, get_data, get_data_plot, get_dep, get_dims, get_error, get_exposure, get_grouping, get_indep, get_quality, get_rmf, get_specresp, get_staterror, get_syserror, group, load_ascii, load_data, load_grouping, load_quality, set_data, set_quality, ungroup, unpack_ascii, unpack_data
filtering
get_filter, load_filter, set_filter
fitting
calc_stat_info, get_fit, get_stat_info
info
get_default_id, list_data_ids, list_model_ids, list_response_ids, list_stats, show_bkg_model, show_bkg_source
methods
get_draws, get_iter_method_name, get_iter_method_opt, get_method
modeling
add_model, add_user_pars, clean, create_model_component, delete_bkg_model, delete_model, delete_model_component, get_model, get_model_autoassign_func, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_order_plot, get_par, get_pileup_model, get_response, get_source, get_source_component_image, get_source_component_plot, image_model, image_model_component, image_source, image_source_component, integrate, integrate1d, link, load_table_model, load_template_model, load_user_model, normal_sample, reset, save_model, save_source, set_bkg_model, set_full_model, set_model_autoassign_func, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset, t_sample, uniform_sample
plotting
get_energy_flux_hist, get_lrt_plot, get_lrt_results, get_photon_flux_hist, get_pvalue_plot, get_pvalue_results, get_split_plot, plot, plot_arf, plot_bkg, plot_cdf, plot_chisqr, plot_data, plot_delchi, plot_energy_flux, plot_fit, plot_model, plot_model_component, plot_order, plot_pdf, plot_photon_flux, plot_pvalue, plot_ratio, plot_resid, plot_scatter, plot_source, plot_source_component, plot_trace, set_xlinear, set_xlog, set_ylinear, set_ylog
psfs
delete_psf, get_kernel, get_psf, load_conv, plot_kernel
saving
save_delchi, save_error, save_filter, save_grouping, save_quality, save_resid, save_staterror, save_syserror
statistics
get_chisqr_plot, get_delchi_plot, get_prior, get_sampler, get_stat
utilities
calc_chisqr, calc_data_sum, calc_data_sum2d, calc_energy_flux, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum, calc_model_sum2d, calc_photon_flux, calc_source_sum, calc_source_sum2d, calc_stat, eqwidth, get_analysis, get_rate
visualization
contour, contour_data, contour_model, contour_ratio, contour_resid, get_ratio, get_resid, histogram1d, histogram2d, image_data, image_getregion, 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:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.