Skip to the navigation links
Last modified: 11 December 2024

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

This page provides quick access to the Sherpa 4.17 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

Introduction to Fitting PHA Spectra

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.

Introduction to Fitting ASCII Data with Errors: Single-Component Source Models

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.

Changing the grouping scheme of a data set within Sherpa

Python script

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

Simultaneously Fitting Two Data Sets

Python script

Simultaneously model multiple independent data sets.

Fitting a PHA Data Set with Multiple Responses

Python script

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

Fitting PHA Data with Multi-Component Source Models

Python script

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

Simultaneously Fitting Source and Background Spectra

Python script

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

Using A Pileup Model

Python script

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

Fitting FITS Image Data

Python script

Perform a basic fit to a FITS image data set.

Radial and elliptical profiles of Image Data

Python script

Plot radial and elliptical profiles of an imaging fit.

Using an Exposure Map in Fitting Image Data

Python script

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

Accounting for PSF Effects in 2D Image Fitting

Python script

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

Fitting Image Data with Convolved and Unconvolved Model Components

Python script

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

Fitting Grating Data

Python script

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

Fitting Multiple Orders of HRC-S/LETG Data

Python script

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

Measuring Line Parameters with an HETG/ACIS-S Spectrum

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.

Measuring Line Parameters with an LETG/ACIS-S Spectrum

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.

Creating an Input Spectrum for MARX and ChaRT Simulations

Python script

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

Bayesian Analysis in Sherpa

Python script

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

Plotting Data

Plotting in Sherpa Using Common Options

Python script

Plot spectral data in Sherpa using common options.

Computing Statistics

Step-by-Step Guide to Estimating Errors and Confidence Levels

Python script

Estimate confidence intervals for fit parameters.

Calculating Uncertainties by Simulating Flux Distributions

Python script

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

Calculating Model Flux and Flux Uncertainty

Python script

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

Simulating Data

Simulating X-ray Spectral Data (PHA): the fake_pha command

Python script

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

Simulating Chandra ACIS-S Spectra with Sherpa

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.

Simulating Chandra ACIS-S LETG Spectra with Sherpa

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.

Creating an Input Spectrum for MARX and ChaRT Simulations

Python script

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

Miscellaneous

Calculating K-corrections using Sherpa

Python script

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