Skip to the navigation links
Last modified: 11 December 2023

URL: https://cxc.cfa.harvard.edu/sherpa/scripts/index.html

Quick Scripts

This page provides quick access to the Sherpa 4.16 Python scripts used in the Sherpa threads. Each script below is also included in the "Scripting It" section at the bottom of the corresponding thread.


Fitting Data

Python script

Perform a basic fit to a PHA data set. Load the data and instrument responses, filter the data, subtract the background, define a source model expression, fit the model to the data, and examine the quality of the fit.

Python script

Empirically fit 1-D data from an ASCII file with polynomials of several orders. Define a parameter expression to link the polynomial offset with one of the constants. Plot the data and fits, and customize the plots with ChIPS commands.

Python script

Change the grouping of a data set after it has been read into Sherpa with the group commands.

Python script

Simultaneously model multiple independent data sets.

Python script

Fit a source and/or background spectrum with a single model expression including components convolved by different responses.

Python script

Fit a spectral data set with a multi-component source model.

Python script

Simultaneously fit source and background spectra with proper and distinct RMFs and ARFs.

Python script

Include a pileup model in the source model expression used to fit a data set.

Python script

Perform a basic fit to a FITS image data set.

Python script

Plot radial and elliptical profiles of an imaging fit.

Python script

Use a file-based exposure map model to fit image data.

Python script

Fit image data using a PSF image as the convolution kernel.

Python script

Fit image data with a manually defined model expression which includes both convolved and unconvolved components.

Python script

Perform a basic fit to a ACIS-S/HETG grating data set.

Python script

Fit the overlapping spectral orders of a HRC-S/LETG data set.

Python script

Perform a simple fit to a line feature in an ACIS-S/HETG spectrum. Calculate the error bars on the line normalizations, positions, and widths, and calculate the line equivalent widths.

Python script

Perform a simple fit to several line features in an ACIS-S/LETG spectrum. Calculate the error bars on the line normalizations, positions, and widths, and calculate the line equivalent widths.

Python script

Create the unconvolved source spectrum required as input to ChART or MARX for simulating the Chandra PSF.

Python script

Conduct Bayesian Low-Counts X-ray Spectral (BLoCXS) analysis in the Sherpa environment with the pyBLoCXS routine.

Plotting Data

Python script

Plot spectral data in Sherpa using common options.

Computing Statistics

Python script

Estimate confidence intervals for fit parameters.

Python script

Determine flux uncertainties by sampling fit parameter values using an uncorrelated, normal distribution.

Python script

Calculate the flux and associated flux uncertainty due to a Sherpa model, and any of the model subcomponents.

Simulating Data

Python script

Perform a basic 1-D data simulation using the fake_pha command.

Python script

Simulate a spectrum of a point source obtained with the ACIS-S detector aboard Chandra, with and without consideration of a background component.

Python script

Simulate a spectrum of a point source as observed with a different Chandra instrument configuration than that used to produce an existing data set.

Python script

Create the unconvolved source spectrum required as input to ChART or MARX for simulating the Chandra PSF.

Miscellaneous

Python script

Learn how to calculate the K-correction for a given spectral model, redshift, and energy range using the Sherpa calc_kcorr command.