|AHELP for CIAO 4.9 Sherpa v1||
Introduction to Sherpa, the CIAO modeling and fitting package
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.
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 "Starting Sherpa" thread has more details.
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.
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
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 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>
Syntax, description and examples for a specific command:
unix% ahelp <command>
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.
- 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".
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.
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.
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).
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.
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.
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.