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

Skip the navigation links
Last modified: December 2008

URL: http://cxc.harvard.edu/sherpa4.1/sherpa4.html
AHELP for Sherpa 4.1

sherpa

Context: sherpa

Synopsis

Introduction to Sherpa, the CIAO modeling and fitting package

Description

The CIAO 4 release includes a new, more powerful version of Sherpa, the CIAO modeling and fitting package. Sherpa enables the user to construct complex models from simple definitions and fit those models to data, using a variety of statistics and optimization methods.

This document provides an introduction to Sherpa; more information is available on the website: http://cxc.harvard.edu/sherpa/ .

Sherpa is designed for use in a variety of modes: as a user-interactive application and in batch mode. Sherpa is an importable module for scripting languages (Python or S-Lang) and is available as a C/C++ library for software developers. In addition, users may write their own Python and S-Lang scripts for use in Sherpa.

The Sherpa session can be saved into a platform-independent state file. The session can then be restored at any time.

Starting Sherpa

From the CIAO command line, type:

unix% sherpa [-x|-b|-l|-n] <file>

Any or all of the following options which may be supplied when Sherpa is started:

  • -x : launch Sherpa shell in separate display terminal.
  • -b : runs Sherpa in batch mode
  • -l : specifies which language to use, "slang" or "python".
  • -n : prevents the Sherpa banner from being displayed on startup.
  • <file>: a file of S-Lang or Python Sherpa commands to run

The startup script loads the Sherpa module, as well as the CRATES module, which handles file input and output ("ahelp crates"), and the Chips module, used for customizing the plots ("ahelp chips").

The language to use - S-Lang or Python - is determined by the hierarchy:

  • language specified by the "-l" command-line option
  • CHIPS_SCRIPT_LANG environment variable.
  • SHERPA_SCRIPT_LANG environment variable (see "ahelp ciaorc")
  • "shell" preference in the $HOME/.sherpa.rc file
  • if none of the above are set, default to PYTHON

The "Starting Sherpa" thread has more details.

The Sherpa Resource File: .sherpa.rc

When Sherpa is started, it processes the $HOME/.sherpa.rc resource file. The resource file defines default behavior for the Sherpa commands and can be customized to the user's preferences; refer to "ahelp sherparc" for details.

Loading Modules in Python

To import the Sherpa, CRATES, and Chips modules in Python without using the "sherpa" startup script:

from sherpa.astro.ui import *
from pychips.hlui import *
from pycrates import *

Loading Modules in S-Lang

To import the Sherpa, CRATES, and Chips modules in S-Lang without using the "sherpa" startup script:

require("sherpa");
require("chips_hlui");
require("crates");

Getting Help

There are several ways to access the Sherpa help files.

From the CIAO command line:

o) Syntax, description and examples for a specific command:

unix% ahelp <command>

List of all Sherpa help files by context:

unix% ahelp -c py.sherpa

or

unix% ahelp -c sl.sherpa

From within Python or S-Lang, ahelp may be called two ways:

o) Python:

sherpa> ahelp("<command>")

sherpa> !ahelp <command>

o) S-Lang:

sherpa> ahelp("<command>");

sherpa> !ahelp <command>;

The native help systems - called "help" in both cases - may also be used to obtain syntax information:

# Python
sherpa> help <command>

# S-Lang
sherpa> help <command>;

CHANGES IN CIAO 4.1

Startup Option

The "-l" command-line option may be specified when ChIPS is started to select the language; see the text for details.

Bugs

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

Last modified: December 2008



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.