Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2009

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.3 Sherpa v1


Context: contrib


Plot a radial or elliptical profile of the fit (data and model) and residuals (data-model)/error to imaging data.


prof_fit_delchi( [id], [model=None, rstep=None, rmin=None, rmax=None,
rlo=None, rhi=None, xpos=None, ypos=None, ellip=None, theta=None,
group_counts=None, group_snr=None, label=True, recalc=True] )


The prof_fit_delchi command calculates the radial - or elliptical - profile of the imaging data, model, and residual (data-model)/error, and plots them. It is a combination of the plot_fit() and plot_delchi() commands, where the residuals appear in a separate plot below the fit values. The profile is defined by the existing model compenents, although it is possible to over-ride these values.

The residual values are calculated as

(data - model) / error

The prof_fit_resid() command can be used if you want to plot

data - model

Loading the routine

The routine can be loaded into Sherpa by saying:

from sherpa_contrib.profiles import *

Argument options

The argument options are the same as for the prof_data() command, except for the overplot command which is not supported, and are described in the ahelp page for prof_data().

Changing the plot defaults

The plot created by prof_fit_delchi() is controlled by the data, model, and resid preferences - i.e. the values returned by get_data_prof_prefs(), get_model_prof_prefs(), and get_delchi_prof_prefs(). Changing these settings will therefore change the appearance of any new plots created by prof_fit_delchi(). For example

sherpa> get_data_prof_prefs()["xlog"] = True
sherpa> get_model_prof_prefs()["linecolor"] = "green"
sherpa> get_delchi_prof_prefs()["errstyle"] = "capped"

will cause any new fit plots to use logarithmic scaling for the X axis, draw the model using a green line, and use the capped style for drawing the error bars in the residual plot. See the ahelp files for get_data_prof_prefs, get_model_prof_prefs, and get_delchi_prof_prefs for the available preference settings.

Example 1

sherpa> prof_fit_delchi()
sherpa> log_scale(X_AXIS)
sherpa> current_plot("plot1")
sherpa> log_scale(Y_AXIS)
sherpa> get_data_prof_prefs()["ylog"] = True
sherpa> get_delchi_prof_prefs()["xlog"] = True
sherpa> prof_fit_delchi()

Since the command creates two plots, we first change the X-axis to use a log scale; since the two plots share a common X axis both get changed. Then we use the ChIPS command current_plot to change to the first plot and draw its Y axis using a log scale. The ChIPS info() and info_current() commands can be used to find out what plot objects have been created and which are current.

We then change the preference settings so that future plots created by prof_fit_delchi() are drawn in the same manner.

Example 2

sherpa> prof_fit_delchi()
sherpa> adjust_grid_yrelsize(1, 1.5)
sherpa> adjust_grid_ygap(0.05)

After creating the two plots we use ChIPS command to change the relative sizes (so that the first plot is 50 percent bigger than the second plot) and to add a small vertical gap between the plots.

Example 3

sherpa> prof_fit_delchi(group_snr=15)

The data is plotted after the bins have been grouped so that each bin has a signal to noise ratio of 15 or more.

Example 4

sherpa> prof_fit_delchi(rmin=10, rmax=100, rstep=5)

Calculate the profile in radial bins with low/high limits of 10-15, 15-20, 20-25, ..., 90-95, 95-100. If the group_counts or group_snr option was also given - e.g.

sherpa> prof_fit_delchi(rmin=10, rmax=100, rstep=5, group_counts=100)

then the grouping would be applied to these bins.

Example 5

sherpa> prof_fit_delchi(rlo=[0,10,20,40,60,100,200])

Calculate the profile in radial bins with low/high limits of 0-10, 10-20, 20-40, 40-60, 60-100, 100-200.

Example 6

sherpa> prof_fit_delchi(rstep=[1,10,2,20,5,50,10])

The radii used for the radial bins depends on the radius as shown in the table below:

radius bin width
0 to 10 1
10 to 20 2
20 to 50 5
above 50 10

The minimum and maximum radii used are taken from the data.

Example 7

sherpa> prof_fit_delchi("src1")
sherpa> current_plot("plot1")
sherpa> prof_model("src2", overplot=True)
sherpa> set_histogram(["line.color", "green"])

Plots the fit profiles (data and model) for the dataset called "src1" and then overplots the model results from dataset "src2" using a green line. Note that the residual plot only shows the residuals from the first dataset; to add the residuals from the second dataset you would say

sherpa> current_plot("plot2")
sherpa> prof_delchi("src2", overplot=True)
sherpa> set_histogram(["*.color", "green"])

which would overlay them as the green residuals in the bottom plot.

Example 8

sherpa> load_image("img.fits")
sherpa> set_source(beta2d.clus + gauss2d.qso + const2d.bgnd)
sherpa> fit()
sherpa> prof_fit_delchi(model=qso)
sherpa> thaw(clus.ellip)
sherpa> thaw(clus.theta)
sherpa> fit()
sherpa> prof_fit_delchi(model=clus)

Since the model expression contains two components which have xpos, ypos, ellip, and theta parameters - namely clus and qso - the model argument is used to select the gauss2d (qso) values for the first plot and the beta2d (clus) values for the second plot.

If the clus model has a non-zero ellipticity then the second plot will have used elliptical annuli to calculate the profile. To use circular annuli in this case we can manually override the model's ellipticity parameter by saying:

sherpa> prof_fit_delchi(model=clus, ellip=0)


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

See Also

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_resid, prof_model, prof_resid, prof_source, sherpa_profiles
get_arf_plot, get_bkg_plot
get_energy_flux_hist, get_photon_flux_hist, get_split_plot, plot, plot_arf, plot_bkg, plot_chisqr, plot_data, plot_delchi, plot_energy_flux, plot_fit, plot_model, plot_model_component, plot_order, plot_photon_flux, plot_ratio, plot_resid, plot_source, plot_source_component, set_xlinear, set_xlog, set_ylinear, set_ylog
get_chisqr_plot, get_delchi_plot

Last modified: December 2009
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: Smithsonian Institution, Copyright © 1998-2019. All rights reserved.