About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 18 June 2009

How can I plot a spectrum in photon flux units (photons s-1 cm-2 keV-1)?


In the current incarnation of Sherpa 4.1, model-fitted source spectra are plotted in units of counts s-1keV-1 (or per channel or wavelength). This is because Sherpa convolves an assumed source model in photon flux units with the instrument response functions to get a model-predicted flux in counts s-1keV-1, so that this model may be compared to a data set in counts. To plot in photon flux units (photons s-1 cm-2 keV-1) would require doing things the other way around - it requires deconvolving the data using the RMF and ARF instrument responses and comparing it to a model which is unconvolved (i.e., the model representation of source flux before it passes through the detector).

The following set of Sherpa 4.1 (Python) commands may be used to plot a model-fitted source spectrum in photon flux units; it mimics the behaviour of the Sherpa 3.4 function "lplot UFIT", which does not yet have a Sherpa 4.1 analog.

(Please note that the following produces only an approximation of the deconvolved source data.)

Referencing the example data used in the Sherpa thread "Introduction to Fitting PHA Data (S-Lang or Python)":

sherpa> plot_data()
sherpa> plot_source()

# Plot Sherpa 3.4 'lp udata'
sherpa> xx = get_fit_plot().dataplot.x
sherpa> dd = get_fit_plot().dataplot.y
sherpa> ee = get_fit_plot().dataplot.yerr
sherpa> mm = get_fit_plot().modelplot.y

sherpa> src = get_source()(xx)
sherpa> add_curve(xx, dd/mm*src, [ee/mm*src],
["line.style", "0", "err.style", "line",
"symbol.style", "4","symbol.size", "3",
"symbol.fill", "false"])
sherpa> set_plot_ylabel("Photons sec^{-1} cm^{-2} kev^{-1}")
sherpa> set_plot_xlabel("Energy (keV)")

# Plot Sherpa 3.4 'lp ufit'
sherpa> plot_source(overplot=True)
sherpa> log_scale()

First, data is loaded (with load_pha (S-Lang or Python help)) and plotted with plot_data (S-Lang or Python help), then a source model is defined (with set_source (S-Lang or Python help)) and plotted with plot_source (S-Lang or Python help). The get_fit_plot (S-Lang or Python help) function is then used to store the x and y arrays of the data plot to variables 'xx' and 'dd', respectively; the data y errors to variable 'ee'; and the y array of the model plot to variable 'mm'. Next, the get_source (S-Lang or Python help) function is used to store the unconvolved model values to the variable 'src' (while 'mm' contains the convolved model values). Finally, the ChIPS function add_curve (S-Lang or Python help) creates a plot of photon flux (photons s-1 cm-2 keV-1) versus energy (keV), and the 'overplot' option of plot_source (S-Lang or Python help) is used to add the convolved model to the plot.

The plotted values in Figure 1 represent the ratio of the source count rate to the convolved model count rate, times the unconvolved model (photons s-1 cm-2 kev-1).

[ Model-fitted source spectrum plotted in photon                flux units, in a linear scale on the left and log scale                on the right. ]

Figure 1. Model-fitted source spectrum plotted in photon flux units, in a linear scale on the left and log scale on the right.

Background:

The primary function of software packages like Sherpa is to solve the integral equation (instrument response) which relates the total counts produced in a given pulse-height bin in a spectrum to the incident source spectrum. Therefore, once you have a pulse-height spectrum and the appropriate RMF and ARF instrument response, you can use Sherpa to fold the source data through an assumed model to determine the "true" source flux (see also the Sherpa function 'calc_photon_flux (S-Lang or Python help), which returns non-integrated flux in units of photons s-1 cm-2 keV-1 when supplied with a single energy value, and when working in energy space with set_analysis("energy") (S-Lang or Python help)).

Though be warned that Sherpa has no explicit knowledge of data or model units; the units displayed with computed fluxes are defaults, generally correct for standard analyses of 1-D PHA energy/wavelength spectra (XSPEC-like analyses). They may be incorrect for non-standard analyses, or for analyses of 2-D spatial images with exposure maps, etc. The correct units can be determined by working backwards from the data, taking into account the exposure time, the units of the instrument model, the bin units, etc.



Last modified: 18 June 2009


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.