load_table_model

sherpa.ui.load_table_model(modelname, filename, ncols=2, colkeys=None, dstype=<class 'sherpa.data.Data1D'>, sep=' ', comment='#', method=<function linear_interp>)

Load ASCII tabular data and use it as a model component.

A table model is defined on a grid of points which is interpolated onto the independent axis of the data set. The model has a single parameter, ampl, which is used to scale the data, and it can be fixed or allowed to vary during a fit.

Parameters:
  • modelname (str) – The identifier for this table model.
  • filename (str) – The name of the ASCII file to read in.
  • ncols (int, optional) – The number of columns to read in (the first ncols columns in the file). It should be 1 or 2.
  • colkeys (array of str, optional) – An array of the column name to read in. The default is None, which uses the first ncols columns in the file. The default column names are col followed by the column number, so col1 for the first column.
  • dstype (data class to use, optional) – What type of data is to be used. Supported values include Data1D (the default) and Data1DInt.
  • sep (str, optional) – The separator character for columns. The default is ' '.
  • comment (str, optional) – Lines starting with this string are ignored. The default is '#'.
  • method (func) – The interpolation method to use to map the input data onto the coordinate grid of the data set. Linear, nearest-neighbor, and polynomial schemes are provided in the sherpa.utils module.

See also

load_conv()
Load a 1D convolution model.
load_psf()
Create a PSF model
load_template_model()
Load a set of templates and use it as a model component.
set_model()
Set the source model expression for a data set.
set_full_model()
Define the convolved model expression for a data set.

Notes

Examples of interpolation schemes provided by sherpa.utils are: linear_interp, nearest_interp, neville, and neville2d.

See unpack_data for a description of the supported file format.

When reading in two columns, the data will be re-ordered so that the first column read in (the independent axis) is numerically increasing.

If ncols=1, only the model values (dependent axis) are read in. In this case, the data set to which the model is applied - via set_source - must have the same number of data points as the model.

When used with an integrated data set (for example, Data1DInt), then the first column of the table - the independent axis - should be the left-edge of the bin, and the second column is the integrated value for that bin.

Examples

Load in the data from filt.dat and use it to multiply the source model (a power law and a gaussian). Allow the amplitude for the table model to vary between 1 and 1e6, starting at 1e3.

>>> load_table_model('filt', 'filt.dat')
>>> set_source(filt * (powlaw1d.pl + gauss1d.gline))
>>> set_par(filt.ampl, 1e3, min=1, max=1e6)