Sherpa is the modeling and fitting tool of CIAO software package. We have developed it with the primary goal that a user should be able to take full advantage of Chandra's unprecedented observational capabilities and be able to analyze data in up to four dimensions (energy or wavelength , time , and spatial location [,]) with a wide variety of models, optimization methods, and fit statistics. We have also made it as general as possible, so that users can analyze data from other X-ray missions (e.g., ROSAT, XMM) and from other wavebands.
S-Lang is an interpreted language created by John Davis of the Center for Space Research at MIT. S-Lang is a popular language, with several hundred users, and several applications that use it as an extension language. Embedding such a language into an application can enhance its flexibility and power by allowing users to more easily extend its capabilities. We have added S-Lang to CIAO, where it is currently used most heavily in ChIPS (Chandra Imaging and Plotting Software) and Sherpa.
Embedding S-Lang in Sherpa was an important first step. This allows users to call their own S-Lang functions from Sherpa. But simply calling new S-Lang functions is of limited use unless such functions can analyze data that have already been read into Sherpa.
Thus, we have added S-Lang functions that provide interfaces to Sherpa data structures. Among them are functions that copy Sherpa data from C++ to S-Lang variables. S-Lang scripts can now obtain copies of Sherpa data sets, and their associated errors and weights, as well as model values calculated from models fit to the data.
Data residing in S-Lang variables can also be copied back into Sherpa. S-Lang scripts can now copy data from a Sherpa data set, perform some analysis on the data, and then copy the data back into Sherpa. A Sherpa model can then be fit to this modified data set. We also provide other S-Lang functions to access other Sherpa information (e.g., values and ranges or model parameters).
The Sherpa documentation has a complete list of the S-Lang functions we provide, including examples using these functions.
These functions are available from the Sherpa command line; they are also available from a S-Lang module we distribute along with Sherpa itself. S-Lang modules are shared objects which can be dynamically linked to other S-Lang applications. Sherpa S-Lang functions, and thus, a Sherpa fitting session, can be run from any other S-Lang application (e.g., ChIPS, slsh).
ChIPS is the Chandra Imaging and Plotting Software. S-Lang has also been embedded in ChIPS. For the plots generated from Sherpa, we now use S-Lang as the interface between Sherpa and ChIPS.
Sherpa has a number of S-Lang scripts that create certain types of plots (e.g., plots of data with error bars, plots with data and model values overplotted, plots of residuals, and so on). These scripts copy the appropriate data, errors and model values from Sherpa and send them to ChIPS; the scripts then call various S-Lang functions which are equivalent to ChIPS plotting commands.
The plots Sherpa generates all have different default appearances. To allow users to change these defaults, we provide configuration variables that govern the attributes of the plots. Examples of such attributes include line style, point style, presence of x- and y-error bars, colors for line and points, etc.
The Sherpa documentation includes a list of all configuration variables and examples illustrating their use.
Sherpa provides a number of mathematical and physical models to which data can be fit. But Sherpa cannot possibly provide every model that every user might want. Therefore, we provide an interface to models written in S-Lang. Users can write their own models in S-Lang and then load the model into Sherpa. Once the model is in Sherpa, it can be used just as a native Sherpa model would be--the syntax is identical.
The enhancements we have added to Sherpa--S-Lang access to Sherpa data sets, a S-Lang interface to ChIPS, and a S-Lang interface to user models--help users to more easily write their own extensions to Sherpa. Such extensions could be functions to prepare Sherpa data sets for analysis, to modify plots produced by Sherpa plotting scripts, or to analyze data and fit results in ways that cannot be done with native Sherpa functions.
The CIAO Web pages include pointers to a number of ``threads'' that (among many other things) show how to use S-Lang to extend Sherpa. These topics include:
We conclude with a condensed version of another thread from our Web page--a thread that shows how to use Sherpa, with S-Lang extensions, to calculate k-corrections for any of the spectral models available from Sherpa. As an example we calculate the corrections necessary for the flux measured in the 0.5-2.0 keV energy range from a thermal plasma (as described by the Mewe-Kaastra-Liedahl--a.k.a. MEKAL--model) for a range of redshifts and gas temperatures. The aim is to emulate the figure presented in Appendix B of Jones et al. (1998).
The first step is to create an instance of the xsmekal model, and set the plasma temperature and metal abundance to be 7 keV and 0.3 times solar respectively.
sherpa> paramprompt off Model parameter prompting is off sherpa> source = xsmekal[plasma] sherpa> plasma.kt = 7 sherpa> plasma.abund = 0.3
For the rest-frame energy range (0.5-2.0 keV) and redshift range (0-2) considered in this example, we need to ensure that the model is evaluated over at least 0.5 to 4.0 keV. It does not matter if the energy range is larger than that, so we chose 0.01 to 10 keV, with a grid spacing of 0.01 keV.
sherpa> dataspace (0.01:10:0.01) histogram
We can then use the calc_kcorr function from the Sherpa utility package ( sherpa_utils.sl, available for download from the Sherpa Web page). This function can return the k-correction for a single redshift, or a range of redshifts. Here we calculate the correction values for the redshift range 0 to 2.
sherpa> z = [0.0:2.1:0.1] sherpa> kc = calc_kcorr( 1, z, 0.5, 2.0 )
This method can then be used to calculate the k-correction at plasma temperatures of 1, 2, 4, and 10 keV. The result is shown in Figure 1, which resembles that of Jones.
Doe, S., Noble, M., & Smith, R. 2001, in ASP Conf. Ser., Vol. 238, Astronomical Data Analysis Software and Systems X, ed. F. R. Harnden, Jr., Francis A. Primini, & Harry E. Payne (San Francisco: ASP), 310
Jones, L. R., Scharf, C., Ebeling, H., Perlman, E., Wegner, G., Malkan, M., & Horner, D. 1998, ApJ, 495, 100