get_bkg_source_plot
- sherpa.astro.ui.get_bkg_source_plot(id=None, lo=None, hi=None, bkg_id: IdType | None = None, recalc=True)
Return the data used by plot_bkg_source.
- Parameters:
id (int 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
.lo (number, optional) – The low value to plot.
hi (number, optional) – The high value to plot.
bkg_id (int, str, or None, optional) – Identify the background component to use, if there are multiple ones associated with the data set.
recalc (bool, optional) – If
False
then the results from the last call toplot_bkg_source
(orget_bkg_source_plot
) are returned, otherwise the data is re-generated.
- Returns:
source – An object representing the data used to create the plot by
plot_bkg_source
.- Return type:
a
sherpa.astro.plot.BkgSourcePlot
instance- 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)