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

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/get_model_params.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 get_model_params Context: sherpa

Synopsis

Access to the default model and instrument parameters of Sherpa from S-Lang.

Syntax

Array_Type get_model_params([String_Type])
Array_Type get_inst_model_params([String_Type])

Error Return Value: NULL

Argument:

(1) matching string (default none: list all models)

Description

The two functions allow you to get the default parameter values for all the models in Sherpa: get_model_params() works on "source" models - such as xsraymond and gauss2d - whilst get_inst_model_params() works on "instrument" models such as rsp1d. Each model is described by a structure and the functions return an array of structures, one for each model whose name contains the function argument (if no argument is given all models are returned).

These functions return information about the default parameter values of each model (i.e. what the initial values for the models are set to when an instance of the model is created). The get_par() function should be used to get the current parameter values of a particular instance of a model.

Structure returned by get_model_params() and get_inst_model_params().

Field name Description
name The name of the model.
type The type of the model: "sherpa", "xspec", or "usermodel".
numpars The number of parameters in the model.
integrated What is the default integration mode for this model: 1 for on, 0 for off.
params An array of structures containing the parameter values. This structure is a subset of that returned by the get_par() function and is described below.

Contents of the params field.

Field name Description
name The parameter name.
value The default parameter value.
min The default minimum value for the parameter.
max The default maximum value for the parameter.
units The units of the parameter. The field will be set to NULL if no units are defined.
frozen Set to 1 if the parameter is frozen by default, 0 otherwise.

Example 1

List the parameters of the GAUSS1D model:

sherpa> gpars = get_model_params("gauss1d")
sherpa> gpars
Struct_Type[1]
sherpa> print(gpars[0])
name             =  gauss1d
type             =  sherpa
numpars          =  3
integrated       =  1
params           =  Struct_Type[3]

This shows that the model contains three parameters. The default values for these parameters can be found by examining the array of structures stored in the params field:

sherpa> print(gpars[0].params[0])
name             =  fwhm
value            =  10
min              =  2.22507e-308
max              =  1.79769e+308
units            =  NULL
frozen           =  0
sherpa> print(gpars[0].params[1])
name             =  pos
value            =  0
min              =  -1.79769e+308
max              =  1.79769e+308
units            =  NULL
frozen           =  0
sherpa> print(gpars[0].params[2])
name             =  ampl
value            =  1
min              =  -1.79769e+308
max              =  1.79769e+308
units            =  NULL
frozen           =  0

Example 2

Find the parameters of all the models whose name contain the word "raymond":

sherpa> ray = get_model_params("raymond")
sherpa> print(length(ray))
2
sherpa> print(ray[0])
name             =  xsraymond
type             =  xspec
numpars          =  4
integrated       =  1
params           =  Struct_Type[4]
sherpa> print(ray[1])
name             =  xsvraymond
type             =  xspec
numpars          =  15
integrated       =  1
params           =  Struct_Type[15]

The function has returned the default parameter settings for the XSRAYMOND and XSVRAYMOND models. The type of both models is set to "xspec" since they are taken from the XSPEC spectral library. As we know the temperature (kT) is the first parameter in the list for both models, we can see its default value for the two models by using:

sherpa> print(ray[0].params[0])
name             =  kT
value            =  1
min              =  0.008
max              =  64
units            =  keV
frozen           =  0
sherpa> print(ray[1].params[0])
name             =  kT
value            =  6.5
min              =  0.0808
max              =  80
units            =  keV
frozen           =  0

Example 3

Find all the instrument models:

sherpa> im = get_inst_model_params()
sherpa> print(length(im))
9
sherpa> foreach(im) { s=(); vmessage("%-10s  [%d]",s.name,s.numpars); }
farf        [2]
fexpmap     [2]
fpsf1d      [5]
fpsf2d      [6]
frmf        [1]
rsp         [2]
rsp2d       [7]
tpsf1d      [5]
tpsf2d      [5]

We called get_inst_model_params() with no argument so all the instrument models are returned and stored in the variable im. The foreach command is used to loop through each element of the im array, which gets stored into the variable s; this is then used in the vmessage() function to write out the model name and number of parameters (s.name and s.numpars respectively).

Bugs

See the Sherpa bug pages online for an up-to-date listing of known bugs.

Hardcopy (PDF): A4 | Letter
Last modified: December 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.