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

Skip the navigation links
Last modified: 21 September 2006
Hardcopy (PDF): A4 | Letter

How can I control whether Sherpa or S-Lang interprets a command?


Sherpa can interpret both native Sherpa/ChIPS commands and S-Lang statements. Although differences in syntax are generally sufficient to distinguish the two, ambiguous input is possible.

In the example below, the user tries to define a source model and a S-Lang variable "src", using the syntax src = ... in both cases. The syntactic ambiguity causes problems:

sherpa> src = const1d[c]   # Define a source model
sherpa> show src
c
const1d[c]  (integrate: on)
    Param   Type      Value        Min        Max                 Units
    -----   ----      -----        ---        ---                 -----
 1     c0 thawed          1          0 3.4028e+38                      
sherpa> src = "NGC 1068"   # Define the S-Lang variable "src"
sherpa> print(src)
NGC 1068
sherpa> show src
Model not defined.
sherpa> # S-Lang assignment erased the source model definition

Clearly, the best solution in this case is to choose a different name for the S-Lang variable. However, it is possible to force an input line to be interpreted as only a Sherpa command by using the sherpa_eval function or only a S-Lang statement by using the eval function.

The above example can be corrected by using eval to create the "src" variable:

sherpa> src = const1d[c]
sherpa> eval("variable src = \"NGC 1068\"")
sherpa> show src
c
const1d[c]  (integrate: on)
    Param   Type      Value        Min        Max                 Units
    -----   ----      -----        ---        ---                 -----
 1     c0 thawed          1          0 3.4028e+38                      
sherpa> print(src)
NGC 1068


Hardcopy (PDF): A4 | Letter
Last modified: 21 September 2006


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.