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

Skip the navigation links
Last modified: 14 Nov 2007
Hardcopy (PDF): A4 | Letter

Starting Sherpa

Sherpa Threads (CIAO 4.0 Beta)



Overview

Last Update: 14 Nov 2007 - new for CIAO 4.0 Beta 3

Synopsis:

This thread describes how to start Sherpa for the first time, how to change the default from Python to S-Lang, and how to access the help files for Sherpa commands in a variety of ways.

Proceed to the HTML or hardcopy (PDF: A4 | letter) version of the thread.




Contents



Starting Sherpa for the First Time

Sherpa can be run in two different languages: S-Lang and Python. CIAO must be told which language to use the first time that Sherpa is run.

This is done by setting the SHERPA_SCRIPT_LANG environment variable. If this variable is not set, Sherpa starts up in the Python mode by default.

unix% setenv SHERPA_SCRIPT_LANG python

or

unix% setenv SHERPA_SCRIPT_LANG slang

Then, from the CIAO command line, type:

unix% sherpa

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



Setting the Default Sherpa Language

There is not yet a method to set which language Sherpa should use by default. Users should include the appropriate setenv line in the $HOME/.cshrc (csh and tcsh users) or $HOME/.login (sh, ksh, and bash users) file.



Getting Help

There are several ways to access the Sherpa help files.

From the CIAO command line

  • Python syntax, description and examples for a specific command:

    unix% ahelp py.sherpa <command>
    

    or to list all Sherpa Python help files:

  • S-Lang syntax, description and examples for a specific command:

    unix% ahelp sl.sherpa <command>
    

    or to list all Sherpa S-Lang help files:


From within Sherpa

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

  • Python:

    sherpa-3> ahelp "<command>"
    
    sherpa-4> !ahelp py.sherpa <command>
    
  • S-Lang:

    sherpa-3> ahelp("<command>");
    
    sherpa-4> !ahelp sl.sherpa <command>
    

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

# Python
sherpa-5> help <command>

% S-Lang
sherpa-5> help <command>

Creating an ahelp alias

Users can create an alias for ahelp to default to one syntax.

To always use Python:

unix% alias shelp "ahelp py.sherpa"
unix% shelp notice

To always use S-Lang:

unix% alias shelp "ahelp sl.sherpa"
unix% shelp notice


Finding a Command

Here are some tips on how to find the name of a command while working in Sherpa.

In Python: ? and <TAB>

To search for a phrase, use the "?" system:

sherpa-6> ? *arf*
get_arf
get_arf_plot
is_arf
load_arf
load_multi_arfs
plot_arf
read_arf
set_arf
write_arf

Type the start of a command and hit <TAB> for all possible completions:

sherpa-7> write_
write_arf    write_file   write_pha    write_table
write_data   write_image  write_rmf

In S-Lang: apropos

The apropos command returns a list of functions that contain that the given string:

sherpa-6> apropos arf
 apropos arf ==>
  ARFCrate
  get_arf
  get_arf_plot
  is_arf
  load_arf
  load_multi_arfs
  plot_arf
  read_arf
  set_arf
  write_arf

sherpa-7> apropos write
 apropos write ==>
  WriteError
  fwrite
  write
  write_arf
  write_data
  write_file
  write_image
  write_pha
  write_rmf
  write_table


Running CIAO and unix commands from the Sherpa Prompt

Any line beginning with "!" is passed from Sherpa to the shell. This allows you to run CIAO and shell commands from the Sherpa prompt.

For example:

sherpa-8> !pwd
/data/ciao_demo/threads/acis-s/1838/primary

sherpa-9> !ls
acisf01838_000N001_bpix1.fits  acisf01838N001_src2.fits
acisf01838N001_evt2.fits       pcadf084244404N001_asol1.fits

sherpa-10> !dmkeypar acisf01838N001_evt2.fits OBJECT echo+
G21.5-0.9

sherpa-11> !dmcopy "acisf01838N001_evt2.fits[energy=300:10000]" 1838_energy.fits


Exiting Sherpa

Type "quit" or use <CTRL>-D to exit Sherpa.



Using Sherpa from S-Lang and Python

The Sherpa, ChIPS, and Crates modules can be loaded into S-Lang and Python by saying

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

and

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

respectively.



History

14 Nov 2007 new for CIAO 4.0 Beta 3

Return to Threads Page: Top | All | Intro
Hardcopy (PDF): A4 | Letter
Last modified: 14 Nov 2007


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.