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
copyattribute toFalse.- Parameters:
- id
intorstr,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,orNone,optional Identify the background component to use, if there are multiple ones associated with the data set.
- recalcbool,
optional If
Falsethen the results from the last call toplot_bkg_source(orget_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.
- id
- Returns:
- source
asherpa.astro.plot.BkgSourcePlotinstance An object representing the data used to create the plot by
plot_bkg_source.
- source
- Raises:
sherpa.utils.err.ArgumentErrIf the data set does not contain PHA data.
sherpa.utils.err.IdentifierErrIf the
bkg_idparameter is invalid.sherpa.utils.err.ModelErrIf no model expression has been created for the background data.
See also
get_bkg_model_plotReturn the data used by plot_bkg_model.
plot_bkg_modelPlot the model for the background of a PHA data set.
plot_bkg_sourcePlot 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_analysiscommand. 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)