Sherpa

Introduction

  • Installation
  • A quick guide to modeling and fitting in Sherpa
  • Sherpa and CIAO

User Documentation

  • What data is to be fit?
  • Creating model instances
  • Evaluating a model
  • Available Models
  • What statistic is to be used?
  • Optimisers: How to improve the current parameter values
  • Fitting the data
  • Visualization
  • Markov Chain Monte Carlo and Poisson data
  • Utility routines

Worked Examples

  • Simple Interpolation
  • Comparing Gaussian, Lorentzian, and Voigt 1D models
  • Simple user model

An interactive application

  • Using Sessions to manage models and data
    • Examples
    • Reference/API
      • The sherpa.ui module
      • The sherpa.astro.ui module
        • add_model
        • add_user_pars
        • calc_bkg_stat
        • calc_bkg_stat_info
        • calc_chisqr
        • calc_data_sum
        • calc_data_sum2d
        • calc_energy_flux
        • calc_kcorr
        • calc_model
        • calc_model_sum
        • calc_model_sum2d
        • calc_photon_flux
        • calc_source
        • calc_source_sum
        • calc_source_sum2d
        • calc_stat
        • calc_stat_info
        • clean
        • conf
        • confidence
        • contour
        • contour_data
        • contour_fit
        • contour_fit_resid
        • contour_kernel
        • contour_model
        • contour_psf
        • contour_ratio
        • contour_resid
        • contour_source
        • copy_data
        • covar
        • covariance
        • create_arf
        • create_model_component
        • create_rmf
        • dataspace1d
        • dataspace2d
        • delete_bkg_model
        • delete_data
        • delete_model
        • delete_model_component
        • delete_pileup_model
        • delete_psf
        • eqwidth
        • fake
        • fake_pha
        • fit
        • fit_bkg
        • freeze
        • get_analysis
        • get_areascal
        • get_arf
        • get_arf_plot
        • get_axes
        • get_backscal
        • get_bkg
        • get_bkg_arf
        • get_bkg_chisqr_plot
        • get_bkg_delchi_plot
        • get_bkg_fit_plot
        • get_bkg_model
        • get_bkg_model_plot
        • get_bkg_plot
        • get_bkg_ratio_plot
        • get_bkg_resid_plot
        • get_bkg_rmf
        • get_bkg_scale
        • get_bkg_source
        • get_bkg_source_plot
        • get_bkg_stat_info
        • get_cdf_plot
        • get_chisqr_plot
        • get_conf
        • get_conf_opt
        • get_conf_results
        • get_confidence_results
        • get_contour_prefs
        • get_coord
        • get_counts
        • get_covar
        • get_covar_opt
        • get_covar_results
        • get_covariance_results
        • get_data
        • get_data_contour
        • get_data_contour_prefs
        • get_data_image
        • get_data_plot
        • get_data_plot_prefs
        • get_default_id
        • get_delchi_plot
        • get_dep
        • get_dims
        • get_draws
        • get_energy_flux_hist
        • get_error
        • get_exposure
        • get_filter
        • get_fit_contour
        • get_fit_plot
        • get_fit_results
        • get_functions
        • get_grouping
        • get_indep
        • get_int_proj
        • get_int_unc
        • get_iter_method_name
        • get_iter_method_opt
        • get_kernel_contour
        • get_kernel_image
        • get_kernel_plot
        • get_method
        • get_method_name
        • get_method_opt
        • get_model
        • get_model_autoassign_func
        • get_model_component
        • get_model_component_image
        • get_model_component_plot
        • get_model_components_plot
        • get_model_contour
        • get_model_contour_prefs
        • get_model_image
        • get_model_pars
        • get_model_plot
        • get_model_plot_prefs
        • get_model_type
        • get_num_par
        • get_num_par_frozen
        • get_num_par_thawed
        • get_order_plot
        • get_par
        • get_pdf_plot
        • get_photon_flux_hist
        • get_pileup_model
        • get_plot_prefs
        • get_prior
        • get_proj
        • get_proj_opt
        • get_proj_results
        • get_projection_results
        • get_psf
        • get_psf_contour
        • get_psf_image
        • get_psf_plot
        • get_pvalue_plot
        • get_pvalue_results
        • get_quality
        • get_rate
        • get_ratio_contour
        • get_ratio_image
        • get_ratio_plot
        • get_reg_proj
        • get_reg_unc
        • get_resid_contour
        • get_resid_image
        • get_resid_plot
        • get_response
        • get_rmf
        • get_rmf_plot
        • get_rng
        • get_sampler
        • get_sampler_name
        • get_sampler_opt
        • get_scatter_plot
        • get_source
        • get_source_component_image
        • get_source_component_plot
        • get_source_components_plot
        • get_source_contour
        • get_source_image
        • get_source_plot
        • get_specresp
        • get_split_plot
        • get_stat
        • get_stat_info
        • get_stat_name
        • get_staterror
        • get_syserror
        • get_trace_plot
        • group
        • group_adapt
        • group_adapt_snr
        • group_bins
        • group_counts
        • group_snr
        • group_width
        • guess
        • ignore
        • ignore2d
        • ignore2d_id
        • ignore2d_image
        • ignore_bad
        • ignore_id
        • image_close
        • image_data
        • image_deleteframes
        • image_fit
        • image_getregion
        • image_kernel
        • image_model
        • image_model_component
        • image_open
        • image_psf
        • image_ratio
        • image_resid
        • image_setregion
        • image_source
        • image_source_component
        • image_xpaget
        • image_xpaset
        • int_proj
        • int_unc
        • link
        • list_bkg_ids
        • list_data_ids
        • list_functions
        • list_iter_methods
        • list_methods
        • list_model_components
        • list_model_ids
        • list_models
        • list_pileup_model_ids
        • list_priors
        • list_psf_ids
        • list_response_ids
        • list_samplers
        • list_stats
        • load_arf
        • load_arrays
        • load_ascii
        • load_ascii_with_errors
        • load_bkg
        • load_bkg_arf
        • load_bkg_rmf
        • load_conv
        • load_data
        • load_filter
        • load_grouping
        • load_image
        • load_multi_arfs
        • load_multi_rmfs
        • load_pha
        • load_psf
        • load_quality
        • load_rmf
        • load_staterror
        • load_syserror
        • load_table
        • load_table_model
        • load_template_interpolator
        • load_template_model
        • load_user_model
        • load_user_stat
        • load_xstable_model
        • normal_sample
        • notice
        • notice2d
        • notice2d_id
        • notice2d_image
        • notice_id
        • pack_image
        • pack_pha
        • pack_table
        • paramprompt
        • plot
        • plot_arf
        • plot_bkg
        • plot_bkg_chisqr
        • plot_bkg_delchi
        • plot_bkg_fit
        • plot_bkg_fit_delchi
        • plot_bkg_fit_ratio
        • plot_bkg_fit_resid
        • plot_bkg_model
        • plot_bkg_ratio
        • plot_bkg_resid
        • plot_bkg_source
        • plot_cdf
        • plot_chisqr
        • plot_data
        • plot_delchi
        • plot_energy_flux
        • plot_fit
        • plot_fit_delchi
        • plot_fit_ratio
        • plot_fit_resid
        • plot_kernel
        • plot_model
        • plot_model_component
        • plot_model_components
        • plot_order
        • plot_pdf
        • plot_photon_flux
        • plot_psf
        • plot_pvalue
        • plot_ratio
        • plot_resid
        • plot_rmf
        • plot_scatter
        • plot_source
        • plot_source_component
        • plot_source_components
        • plot_trace
        • proj
        • projection
        • reg_proj
        • reg_unc
        • resample_data
        • reset
        • restore
        • sample_energy_flux
        • sample_flux
        • sample_photon_flux
        • save
        • save_all
        • save_arf
        • save_arrays
        • save_data
        • save_delchi
        • save_error
        • save_filter
        • save_grouping
        • save_image
        • save_model
        • save_pha
        • save_quality
        • save_resid
        • save_rmf
        • save_source
        • save_staterror
        • save_syserror
        • save_table
        • set_analysis
        • set_areascal
        • set_arf
        • set_backscal
        • set_bkg
        • set_bkg_full_model
        • set_bkg_model
        • set_bkg_source
        • set_conf_opt
        • set_coord
        • set_counts
        • set_covar_opt
        • set_data
        • set_default_id
        • set_dep
        • set_exposure
        • set_filter
        • set_full_model
        • set_grouping
        • set_iter_method
        • set_iter_method_opt
        • set_method
        • set_method_opt
        • set_model
        • set_model_autoassign_func
        • set_par
        • set_pileup_model
        • set_plot_backend
        • set_prior
        • set_proj_opt
        • set_psf
        • set_quality
        • set_rmf
        • set_rng
        • set_sampler
        • set_sampler_opt
        • set_source
        • set_stat
        • set_staterror
        • set_syserror
        • set_xlinear
        • set_xlog
        • set_ylinear
        • set_ylog
        • show_all
        • show_bkg
        • show_bkg_model
        • show_bkg_source
        • show_conf
        • show_covar
        • show_data
        • show_filter
        • show_fit
        • show_kernel
        • show_method
        • show_model
        • show_proj
        • show_psf
        • show_source
        • show_stat
        • show_xsabund
        • simulfit
        • subtract
        • t_sample
        • thaw
        • ungroup
        • uniform_sample
        • unlink
        • unpack_arf
        • unpack_arrays
        • unpack_ascii
        • unpack_bkg
        • unpack_data
        • unpack_image
        • unpack_pha
        • unpack_rmf
        • unpack_table
        • unsubtract
      • The sherpa.ui.utils module
      • The sherpa.astro.ui.utils module

Notebooks

  • Sherpa Quick Start
  • Notebook support in Sherpa
  • A sample of plots
  • Axis labelling
  • Viewing PHA responses
  • Asymmetric errors

Extra Functionality

  • Optimizing functions

Getting Help

  • Bug Reports
  • Contributing to Sherpa development
  • Indices and tables
Sherpa
  • Using Sessions to manage models and data
  • The sherpa.astro.ui module
  • link
  • View page source

link

sherpa.astro.ui.link(par, val)

Link a parameter to a value.

A parameter can be linked to another parameter value, or function of that value, rather than be an independent value. As the linked-to values change, the parameter value will change.

Changed in version 4.16.1: Source models no longer have to contain the linked parameter.

Parameters:
  • par (str or Parameter) – The parameter to link.

  • val – The value - which can be a numeric value or a function of other model parameters, to set par to.

See also

freeze

Fix model parameters so they are not changed by a fit.

set_par

Set the value, limits, or behavior of a model parameter.

thaw

Allow model parameters to be varied during a fit.

unlink

Unlink a parameter value.

Notes

The link attribute of the parameter is set to match the mathematical expression used for val.

In the following, the fit will vary the pos parameter even though the src2 component is not part of the source expression (this behavior changed in the 4.16.1 release):

>>> set_source(1, gauss1d.src1)
>>> gauss1d.src2
>>> link(src1.pos, src2.pos)
>>> fit(1)

The lpars attribute of a source model will include these “extra” parameters:

>>> get_source(1).lpars
(<Parameter 'pos' of model 'src2'>,)

Examples

The fwhm parameter of the g2 model is set to be the same as the fwhm parameter of the g1 model.

>>> link(g2.fwhm, g1.fwhm)

Fix the pos parameter of g2 to be 2.3 more than the pos parameter of the g1 model.

>>> gauss1d.g1
>>> gauss1d.g2
>>> g1.pos = 12.2
>>> link(g2.pos, g1.pos + 2.3)
>>> g2.pos.val
14.5
>>> g1.pos = 12.1
>>> g2.pos.val
14.399999999999999
Previous Next

© Copyright 2019–2025, Chandra X-ray Center, Smithsonian Astrophysical Observatory. Last updated on 22 Aug 2025.

Built with Sphinx using a theme provided by Read the Docs.