Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2010

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.3 Sherpa v1


Context: modeling


Load data into a table model


load_table_model( modelname, filename|TABLECrate,
[ncols=2,colkeys=None,dstype=Data1D] )
load_table_model( modelname, filename|IMAGECrate, [coord="logical"] )


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 and multiplicative XSPEC-style table models are supported by the Sherpa table model using load_table_model.

The Sherpa table model 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

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

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)
   Param        Type          Value          Min          Max      Units
   -----        ----          -----          ---          ---      -----
   emap.ampl    thawed            1     -3.4e+38      3.4e+38

Example 2

sherpa> load_table_model("tab", "file.fits", ncols=2)

Create a table model named "tab" by loading the first two columns of file.fits.

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
   Param        Type          Value          Min          Max      Units
   -----        ----          -----          ---          ---      -----
   xstbl.log mass thawed     0.977121     0.477121      1.47712           
   xstbl.log lumin thawed           -1           -2            0         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           


See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

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
get_default_id, list_bkg_ids, list_data_ids, list_model_ids, show_bkg_model, show_bkg_source
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, link, load_user_model, 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
plot_model, plot_model_component, plot_source, plot_source_component
delete_psf, load_conv
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
calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, eqwidth
contour_model, contour_ratio, contour_resid, get_ratio, get_resid

Last modified: December 2010
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2019. All rights reserved.