Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: 26 October 2016

URL: http://cxc.harvard.edu/sherpa/gallery/plot.html

Gallery: Plotting Data

Examples


1D PHA data: Counts/sec/keV versus Energy (keV)

Here we display a background-subtracted PHA source counts spectrum filtered in energy space.

[Filtered and bkg-subtracted 1D PHA data set]

Sherpa 4.8
load_pha("3c273.pi")

subtract()

notice_id(1, 0.1, 6.0)

plot_data()
Sherpa 3.4
data 3c273.pi

subtract

notice energy 0.1:6.0

lplot data

For detailed information about each of the steps in the script, see the Sherpa thread "Introduction to Fitting PHA Spectra", which also contains links to the ahelp files for each Sherpa function used.


1D PHA data: Source spectrum in Counts/sec/Angstrom versus Wavelength (Angstrom)

Here we display a background-subtracted PHA source counts spectrum filtered in wavelength space, with a linear-scale y-axis and log-scale x-axis.

[Filtered and bkg-subtracted 1D PHA data set in wavelength space, with log scale x-axis]

Sherpa 4.8
load_pha("3c273.pi")

subtract()

notice_id(1, 0.1, 6.0)

set_analysis("wave")

plot_data() 

log_scale(X_AXIS)
Sherpa 3.4
data 3c273.pi

subtract

notice energy 0.1:6.0

analysis wave

sherpa.dataplot.x_log = 1

lplot data

For detailed information about the input data in this script, see the Sherpa thread "Introduction to Fitting PHA Spectra".


1D PHA data: Deconvolved source spectrum in Photons/sec/cm2/keV vs. Energy (keV)

Here we display a deconvolved source spectrum in photon flux units, along with the corresponding unconvolved source model, on a logarithmic scale.

[deconvolved 1D PHA data with unconvolved model in photon flux units]

Sherpa 4.8
load_pha("3c273.pi")
subtract()
notice_id(1, 0.1, 6.0)
plot_data()

set_source(xsphabs.abs1 * powlaw1d.p1)
abs1.nH = 0.07
freeze(abs1.nH)
guess(p1)
plot_source()

xx = get_fit_plot().dataplot.x
dd = get_fit_plot().dataplot.y
ee = get_fit_plot().dataplot.yerr
mm = get_fit_plot().modelplot.y

src = get_source()(xx)

add_curve(xx, dd/mm*src, [ee/mm*src],
["line.style", "0", "err.style", "line",
"symbol.style", "4","symbol.size", "3",
"symbol.fill", "false"])

set_plot_ylabel("Photons sec^{-1} cm^{-2} kev^{-1}")
set_plot_xlabel("Energy (keV)")

plot_source(overplot=True)

log_scale()
Sherpa 3.4
() = evalfile("sherpa_plotfns.sl");

data 3c273.pi
subtract
notice energy 0.1:6.0

paramprompt off
source = xsphabs[abs1] * powlaw1d[p1]
abs1.nH = 0.07
freeze abs1
guess p1 

fit

set_log

lp 2 ufit ratio












For detailed information about the steps in this script, see the Sherpa FAQ entry "How can I plot a spectrum in photon flux units (photons s-1 cm-2 keV-1)?", or the Sherpa 3.4 thread "Advanced customization of Sherpa plots."


1D PHA data: Background spectrum in Counts/sec/keV versus Energy (keV)

Here we display the background counts spectrum associated with a PHA source spectrum.

[background for 1D pha data]
Sherpa 4.8
load_pha("3c273.pi")

plot_bkg()

[or, if bkg not automatically loaded]

load_pha("3c273.pi")

load_bkg("3c273_bg.pi")

plot_bkg()
Sherpa 3.4
data 3c273.pi

lplot back

[or, if bkg not automatically loaded]

data 3c273.pi

back 3c273_bg.pi

lplot back

For detailed information about the input data in this script, see the Sherpa thread "Introduction to Fitting PHA Spectra."


1D PHA data: ACIS-S/HETG source grating spectra in Counts/sec/Angstrom vs. Wavelength (Angstrom)

Here we display the +1/-1 HEG and +/-1 MEG grating spectral orders resulting from an ACIS-S/HETG observation of a source, filtered in wavelength space.

[1D acisshetg orders]

Sherpa 4.8
load_pha(1, "459_heg_m1_bin10.pha")
load_pha(2, "459_heg_p1_bin10.pha")
load_pha(3, "459_meg_m1_bin10.pha")
load_pha(4, "459_meg_p1_bin10.pha")

set_analysis("wave")

ignore()

notice(1., 15.)

plot("data", 1, "data", 2, "data", 3, "data", 4)















Sherpa 3.4
data 1 459_heg_m1_bin10.pha
data 2 459_heg_p1_bin10.pha
data 3 459_meg_m1_bin10.pha
data 4 459_meg_p1_bin10.pha
 
rsp[hegm1]
rsp[hegp1]
rsp[megm1]
rsp[megp1]

hegm1.arf = 459_heg_m1.arf
hegp1.arf = 459_heg_p1.arf
megm1.arf = 459_meg_m1.arf
megp1.arf = 459_meg_p1.arf

instrument 1 = hegm1
instrument 2 = hegp1
instrument 3 = megm1
instrument 4 = megp1

analysis wave

ignore allsets all

notice allsets wave 1:15

lplot 4 data 1 data 2 data 3 data 4

For detailed information about each of the steps in the script, see the Sherpa thread "Fitting Grating Data."


1D PHA data: HRC-S/LETG source grating spectra

Here we display a customized plot of the +1/-1 LEG spectral grating orders resulting from an HRC-S/LETG observation of a source. The data points are connected with a solid line, and the data point symbols and y-axis error bars are removed.

[1D hrcsletg +1/-1 orders]

Sherpa 4.8
load_pha(1, "460_leg_m1_bin10.pha") 
load_pha(2, "460_leg_p1_bin10.pha")

set_analysis("wave")

plot("data", 1, "data", 2)

prefs = get_data_plot_prefs()

prefs["linestyle"] = chips_solid

prefs["symbolstyle"] = chips_none

prefs["yerrorbars"] = 0

plot_data()















Sherpa 3.4
data 1 460_leg_m1_bin10.pha
data 2 460_leg_p1_bin10.pha

frmf1d[rmfm1](460_leg_-1.grmf)
frmf1d[rmfm2](460_leg_-2.grmf)
frmf1d[rmfm3](460_leg_-3.grmf)
frmf1d[rmfp1](460_leg_1.grmf)
frmf1d[rmfp2](460_leg_2.grmf)
frmf1d[rmfp3](460_leg_3.grmf)

farf1d[arfm1](460_LEG_-1.garf)
farf1d[arfm2](460_LEG_-2.garf)
farf1d[arfm3](460_LEG_-3.garf)
farf1d[arfp1](460_LEG_1.garf)
farf1d[arfp2](460_LEG_2.garf)
farf1d[arfp3](460_LEG_3.garf)

instrument 1 = arfm1*rmfm1 + arfm2*rmfm2 + arfm3*rmfm3
instrument 2 = arfp1*rmfp1 + arfp2*rmfp2 + arfp3*rmfp3

analysis wave

sherpa.dataplot.curvestyle="solid"

sherpa.dataplot.symbolstyle ="none"

sherpa.dataplot.y_errorbars = 0

lplot 2 data 1 data 2

For detailed information about each of the steps in the script, see the Sherpa thread "Fitting Multiple Orders of HRC-S/LETG Data."


ARF data: cm2 vs. Energy (keV)

Here we display the Auxiliary Response Function (ARF) corresponding to a particular ACIS observation of a source.

[ARF plot]
Sherpa 4.8
load_pha("3c273.pi")

plot_arf()

[or, if ARF not automatically loaded]

load_pha("3c273.pi")

load_arf("3c273.arf")

plot_arf()
Sherpa 3.4
data 3c273.pi

lplot arf

[or, if ARF not automatically loaded]

data 3c273.pi

arf = readarf("3c273.arf")

lplot arf

For detailed information about the input data in this script, see the Sherpa thread "Introduction to Fitting PHA Spectra."


2D PHA data: DS9 source counts image

Here we display the 2-dimensional counts image of a source in DS9, Sherpa's default data imager.

[PHA image data in DS9]

Sherpa 4.8
load_image("image2.fits")
image_data()
 
set_coord("physical")
set_stat("cash")
set_method("simplex")

notice2d("circle(4072.46,4249.34,108)") 
image_data()


Sherpa 3.4
data image2.fits
image data
 
coord physical
statistic cash
method simplex

ignore all
notice physical "circle(4072.46,4249.34,108)"
 
image data

For detailed information about each of the steps in the script, see the Sherpa thread "Fitting FITS Image Data."


2D PHA data: Surface brightness profile in Counts/pixel2 vs. Radius (pixels)

Here we display a background-subtracted radial profile extracted from a 2D PHA data set (either spatial table or image file) with the CIAO tool dmextract.

[Radial profile fit to image data with residuals]

Sherpa 4.8
load_data(1, "1838_rprofile_rmid.fits", 3, \
["RMID","SUR_BRI","SUR_BRI_ERR"])

plot_data()
Sherpa 3.4
read data 1 "1838_rprofile_rmid.fits[columns rmid,sur_bri]" FITSBIN
read errors 1 "1838_rprofile_rmid.fits[columns rmid,sur_bri_err]" FITSBIN

lplot 2 data 1 errors 1

For detailed information about the input data in the script, see the CIAO thread "Obtain and Fit a Radial Profile."


Last modified: 26 October 2016
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:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.