get_bkg_source_plot

sherpa.astro.ui.get_bkg_source_plot(id: IdType | None = None, lo: float | None = None, hi: float | None = None, bkg_id: IdType | None = None, recalc: bool = True, copy: bool = True)

Return the data used by plot_bkg_source.

Changed in version 4.19.0: The plot object is now copied by default. To get the previous behaviour set the copy attribute to False.

Parameters:
idint or str, optional

The data set that provides the data. If not given then the default identifier is used, as returned by get_default_id.

lonumber, optional

The low value to plot.

hinumber, optional

The high value to plot.

bkg_idint, str, or None, optional

Identify the background component to use, if there are multiple ones associated with the data set.

recalcbool, optional

If False then the results from the last call to plot_bkg_source (or get_bkg_source_plot) are returned, otherwise the data is re-generated.

copybool, optional

Is the plot object copied before being returned? If so then the plot attributes will not be changed by multiple calls to this routine.

Returns:
sourcea sherpa.astro.plot.BkgSourcePlot instance

An object representing the data used to create the plot by plot_bkg_source.

Raises:
sherpa.utils.err.ArgumentErr

If the data set does not contain PHA data.

sherpa.utils.err.IdentifierErr

If the bkg_id parameter is invalid.

sherpa.utils.err.ModelErr

If no model expression has been created for the background data.

See also

get_bkg_model_plot

Return the data used by plot_bkg_model.

plot_bkg_model

Plot the model for the background of a PHA data set.

plot_bkg_source

Plot the model expression for the background of a PHA data set.

Examples

Retrieve the source plot information for the background of the default data set and display it:

>>> splot = get_bkg_source_plot()
>>> print(splot)

Return the background plot data for data set 2, and then use it to create a plot:

>>> s2 = get_bkg_source_plot(2)
>>> s2.plot()

Create a plot of the first two background components of the ‘histate’ data set, overplotting the second on the first:

>>> b1 = get_bkg_source_plot('histate', bkg_id=1)
>>> b2 = get_bkg_source_plot('histate', bkg_id=2)
>>> b1.plot()
>>> b2.overplot()

Retrieve the background source plots for the 0.5 to 7 range of the ‘jet’ and ‘core’ data sets and display them on the same plot:

>>> splot1 = get_bkg_source_plot(id='jet', lo=0.5, hi=7)
>>> splot2 = get_bkg_source_plot(id='core', lo=0.5, hi=7)
>>> splot1.plot()
>>> splot2.overplot()

For a PHA data set, the units on both the X and Y axes of the plot are controlled by the set_analysis command. In this case the Y axis will be in units of photons/s/cm^2 and the X axis in keV:

>>> set_analysis('energy', factor=1)
>>> splot = get_bkg_source_plot()
>>> print(splot)