Access to the default model and instrument parameters of Sherpa
from S-Lang.
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)
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().
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.
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.
|
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
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
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).
- sherpa
-
autoest,
background,
create,
create_model,
createparamset,
fit,
freeze,
get_defined_models,
get_models,
get_num_par,
get_par,
get_stackexpr,
getx,
gety,
guess,
instrument,
integrate,
is_paramset,
jointmode,
kernel,
lineid,
linkparam,
mdl,
modelexpr,
modelstack,
nestedmodel,
noise,
paramprompt,
paramset,
pileup,
rename,
run_fit,
set_par,
set_paramset,
set_stackexpr,
source,
thaw,
truncate,
unlink
|