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

URL: http://cxc.harvard.edu/sherpa/ahelp/sherpa4.html
AHELP for CIAO 4.9 Sherpa v1

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 Sherpa website.

Sherpa is designed for use in a variety of modes: as a user-interactive application and in batch mode. The Sherpa command launches an interactive Python session (using the IPython interpreter), in which Sherpa commands (which are Python functions) can be used, as well as ChIPS commands (to create and modify plots); Crates commands for reading and writing files; as well as other Python functions. It is possible to write Python scripts that import the relevant Sherpa modules, and so run non-interactively.

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|-n|-b|-rcfile|-norcfile] <file>

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

  • -x : launch Sherpa shell in separate display terminal.
  • -n : prevents the Sherpa banner from being displayed on startup.
  • -b : runs Sherpa in batch mode
  • -rcfile : specify a specific .sherpa.rc file to use; refer to "ahelp sherparc" for details.
  • -norcfile : do not load any .sherpa.rc file; overrides "-rcfile" if both are set.
  • <file>: Python command file to execute

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 "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

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 *

You may also find it useful to load the numpy module

import numpy as np

Getting Help

There are several ways to access the Sherpa help files. Note that in the CIAO 4.9 release the Pyton docstrings are the preferred option, and that the ahelp pages for Sherpa commands are not guaranteed to be kept up to date.

Within Sherpa

Within the Sherpa application, the native Python help system can be used:

sherpa> help <command>

It is also possible to do a wildcard search for commands, by taking advantage of the native IPython support:

sherpa> plot* ?
sherpa> *psf ?

Alternatively, the ahelp system can be used either directly:

sherpa> ahelp("<command>")
sherpa> ,ahelp <command>

or by running the ahelp command-line program:

sherpa> !ahelp <command>

From the CIAO command line

Syntax, description and examples for a specific command:

unix% ahelp <command>

The ChIPS GUI

The ChIPS GUI can be used to modify any Sherpa plot. It is launched by right clicking on an existing ChIPS window and selecting "Launch GUI" or by running the show_gui command from within a ChIPS session. A Python terminal is built into the GUI, allowing access to ChIPS and other Python commands.

Features include:

  • the ability to edit the properties of an object, such as the symbol style of a curve or the font used for an axis label,
  • zoom, pan, and select objects in the plot,
  • update the plot ranges,
  • move plot areas and annotations,
  • resize plot areas, labels, and points,
  • and an object tree which describes existing plot objects.

Futher information is available from the built-in help menu in the GUI and via "ahelp chipsgui".

Contributing to Sherpa

Development of Sherpa has moved to GitHub and can be found at https://github.com/sherpa/sherpa. Please consider contributing to Sherpa development - whether it is reporting bugs, providing documentation updates, fixing bugs, or adding new functionality. Using this repository, Sherpa can be installed outside of CIAO, and so used with Python packages that can not be installed into the CIAO environment.

Changes in CIAO 4.9

Python 3.5

Sherpa is now compatible with Python 3.5. The version available in CIAO depends on the installation; use

% python --version

to check. CIAO 4.9 provides either Python 2.7.11 or 3.5.1.

IPython

The version of IPython shipped with CIAO has been upgraded to version 4.2.0 (it was 3.0.0 in CIAO 4.8). When Sherpa is first started, users may see a warning message about this change (and be required to answer questions about the upgrade).

Documentation

The Pyton docstrings are the preferred means for documenting Sherpa's behavior. The ahelp files are still provided but are not guaranteed to be kept up to date. This means that the recommended command to use for help is now the Python help command, rather than ahelp, for Sherpa functions.

XSPEC models update

The XSPEC models have been updated to release 12.9.0o in CIAO 4.9. The nlapec model is not included, but this can be replaced by using the xsapec model and setting the APECNOLINES xset variable to 'on' with the set_xsxset function.

Bugs

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


Last modified: December 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.