| AHELP for CIAO 4.5 Sherpa v1 | load_table_model |
Context: modeling |
Synopsis
Load a table model
Syntax
load_table_model( modelname, filename|TABLECrate, [ncols=2,colkeys=None,dstype=Data1D, method=linear_interp] ) load_table_model( modelname, filename|IMAGECrate, [coord="logical"] )
Description
The load_table_model command reads data from a file or crate and assigns it to an instance of the table model class that can be combined arithmetically with the source model. The table model stores the y-values from an input data file and returns them as an array when the table model is asked to "calculate" y-values. The model has one parameter, "ampl", the amplitude; the y-values are multiplied by the amplitude. Additive (atable) and multiplicative (mtable) XSPEC-style table models are also supported.
The Sherpa table model supports linear, nearest-neighbor, and polynomial interpolation. Interpolation is used by the table model to match the data grid to the model grid - which must match before the fit statistics can be calculated for fitting. Importing sherpa.utils is required in order to access available interpolation methods.
The Sherpa table model also supports interpolation of data points on the data set grid from the grid supplied from file. The grids need not be of constant or comparable bin size. If the table model grid is not sorted, Sherpa will sort it in ascending order.
The input may be 1D data from a FITS table, ASCII table data, or 2D data from a FITS image file; allowed crates types are TABLECrate and IMAGECrate.
- modelname - the name for the table model
- filename|TABLECrate|IMAGECrate - the name of the file (with path) or crate which contains the data
- ncols (table input) - number of columns to read; default=2
- colkeys (table input) - list of column names; default=None
- dstype (table input) - dataset type: Data1D, Data1DInt, Data2D, Data2DInt; default=Data1D
- coord (image input) - the coordinate system: logical, image, physical, world, or wcs; default=logical
- method - interpolation method in sherpa.utils: linear_interp, nearest_interp, neville, neville2d; default=linear_interp
Selecting table columns
The columns to load are specified by a Data Model filter on the filename or the colkeys option of the load_table_model command, as shown in the examples. Vector columns are separated to form two dstype columns when the file is loaded.
If no columns are specified, the first two columns in the file are read by default. If only one column is specified, the dstype is irrelevant.
The columns must be listed in the order required by the dataset type:
- Data1D: x, y, staterror=None, syserror=None
- Data1DInt: xlo, xhi, y, staterror=None, syserror=None
- Data2D: x0, x1, y, shape=None, staterror=None, syserror=None
- Data2DInt: x0lo, x1lo, x0hi, x1hi, y, shape=None, staterror=None, syserror=None
Selecting interpolation method
Selection of interpolation methods is available in sherpa.utils. Importing sherpa.utils is required to access these methods.
This can be done for a specific function:
from sherpa.utils import neville, nearest_interp, neville2d, linear interp
or by importing all the functions in sherpa.utils:
import sherpa.utils
Example 1
sherpa> load_table_model("emap", "expmap.fits")A table model named "emap" is created from the exposure map image in expmap.fits. The model can be viewed:
sherpa> print(emap) tablemodel.emap Param Type Value Min Max Units ----- ---- ----- --- --- ----- emap.ampl thawed 1 -3.4e+38 3.4e+38
Example 2
sherpa> import sherpa.utils
sherpa> load_table_model("tab", "file.fits", ncols=2,
method=nearest_interp)Create a table model named "tab" by loading the first two columns of file.fits and use nearest-neighbor interpolation method. Note the required import for selecting the interpolation method.
Example 3
sherpa> imgcr = read_file("psf.img")
sherpa> load_table_model("psfmod", imgcr)The image is read into an IMAGECrate (named "imgcr") from source.img. The crate is then used to create a table model named "psfmod".
Example 4
sherpa> load_table_model("tab1", "bhmodel.fits")The XSPEC-style table model 'plasma_model.fits' is loaded into Sherpa with the load_table_model command. Both additive and multiplicative XSPEC-style table models are supported using load_table_model.
sherpa> load_pha("source.pi")
sherpa> load_table_model("tab1", "plasma_model.fits")
sherpa> show_source()
Model: 1
xstablemodel.tab1
Param Type Value Min Max Units
----- ---- ----- --- --- -----
xstbl.log mass thawed 0.977121 0.477121 1.47712
xstbl.log lumin thawed -1 -2 0
xstbl.inc thawed 0.5 0 1
xstbl.spin thawed 0.4 0 0.8
xstbl.log alpha thawed -2 -2 -1
xstbl.norm thawed 1 0 1e+24
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- data
- dataspace1d, dataspace2d, fake, get_bkg_plot, load_arf, load_arrays, load_ascii, load_bkg, load_bkg_arf, load_bkg_rmf, load_data, load_grouping, load_image, load_multi_arfs, load_multi_rmfs, load_pha, load_quality, load_rmf, load_staterror, load_syserror, load_table, pack_image, pack_pha, pack_table, unpack_arf, unpack_arrays, unpack_ascii, unpack_bkg, unpack_data, unpack_image, unpack_pha, unpack_rmf, unpack_table
- filtering
- load_filter
- info
- get_default_id, list_bkg_ids, list_data_ids, list_model_ids, show_bkg_model, show_bkg_source
- modeling
- add_model, add_user_pars, clean, create_model_component, delete_bkg_model, delete_model, delete_model_component, get_model, get_model_autoassign_func, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_order_plot, get_par, get_pileup_model, get_source, get_source_component_image, get_source_component_plot, image_model, image_model_component, image_source, image_source_component, integrate, integrate1d, link, load_template_model, load_user_model, normal_sample, reset, save_model, save_source, set_bkg_model, set_full_model, set_model_autoassign_func, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset, t_sample, uniform_sample
- plotting
- get_lrt_plot, get_lrt_results, get_pvalue_plot, get_pvalue_results, plot_cdf, plot_lrt, plot_model, plot_model_component, plot_pdf, plot_pvalue, plot_scatter, plot_source, plot_source_component, plot_trace
- psfs
- delete_psf, load_conv
- saving
- save_arrays, save_data, save_delchi, save_error, save_filter, save_grouping, save_image, save_pha, save_quality, save_resid, save_staterror, save_syserror, save_table
- statistics
- load_user_stat
- utilities
- calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, eqwidth
- visualization
- contour_model, contour_ratio, contour_resid, get_ratio, get_resid

![[Sherpa Logo]](../imgs/sherpa_logo_navbar.gif)