Last modified: December 2020

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/calc_energy_flux.html
AHELP for CIAO 4.13 Sherpa v1

calc_energy_flux

Context: utilities

Synopsis

Integrate the unconvolved source model over a pass band.

Syntax

calc_energy_flux(lo=None, hi=None, id=None, bkg_id=None, model=None)

lo - number, optional
hi - number, optional
id - int or str, optional
bkg_id - int or str, optional
model - model, optional

Description

Calculate the integral of E * S(E) over a pass band, where E is the energy of the bin and S(E) the spectral model evaluated for that bin (that is, the model without any instrumental responses applied to it).


Examples

Example 1

Calculate the integral of the unconvolved model over the full range of the default data set:

>>> calc_energy_flux()

Example 2

Return the flux for the data set labelled "core":

>>> calc_energy_flux(id='core')

Example 3

Calculate the energy flux over the ranges 0.5 to 2 and 0.5 to 7 keV:

>>> set_analysis('energy')
>>> calc_energy_flux(0.5, 2)
5.7224906878061796e-10
>>> calc_energy_flux(0.5, 7)
1.3758131915063825e-09

Example 4

Calculate the energy flux density at 0.5 keV for the source "core":

>>> calc_energy_flux(0.5, id="core")
5.2573786652855304e-10

Example 5

Calculate the flux for the model applied to the second background component of the 'jet' data set, for the wavelength range 20 to 22 Angstroms:

>>> set_analysis('jet', 'wave')
>>> calc_energy_flux(20, 22, id='jet', bkg_id=2)

Example 6

For the following example, the source model is an absorbed powerlaw - `xsphabs.gal * powerlaw.pl` - so that the `fabs` value represents the absorbed flux, and `funabs` the unabsorbed flux (i.e. just the power-law component):

>>> fabs = calc_energy_flux(0.5, 7)
>>> funabs = calc_energy_flux(0.5, 7, model=pl)

PARAMETERS

The parameters for this function are:

Parameter Definition
lo If both are None or both are set then calculate the flux over the given band. If only one is set then calculate the flux density at that point. The units for `lo` and `hi` are given by the current analysis setting.
hi If both are None or both are set then calculate the flux over the given band. If only one is set then calculate the flux density at that point. The units for `lo` and `hi` are given by the current analysis setting.
id Use the source expression associated with this data set. If not given then the default identifier is used, as returned by get_default_id .
bkg_id If set, use the model associated with the given background component rather than the source model.
model The model to integrate. If left as `None` then the source model for the dataset will be used. This can be used to calculate the unabsorbed flux, as shown in the examples.

Return value

The return value from this function is:

flux -- The flux or flux density. For X-Spec style models the flux units will be erg/cm^2/s and the flux density units will be either erg/cm^2/s/keV or erg/cm^2/s/Angstrom, depending on the analysis setting.

Notes

The units of lo and hi are determined by the analysis setting for the data set (e.g. get_analysis ).

Any existing filter on the data set - e.g. as created by ignore or notice - is ignored by this function.

The units of the answer depend on the model components used in the source expression and the axis or axes of the data set. It is unlikely to give sensible results for 2D data sets.

Changes in CIAO

Changed in CIAO 4.12.1

The model parameter was added.


Bugs

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

See Also

data
get_bkg_chisqr_plot, get_bkg_delchi_plot, get_bkg_fit_plot, get_bkg_model_plot, get_bkg_plot, get_bkg_ratio_plot, get_bkg_resid_plot, get_bkg_source_plot
info
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_num_par_frozen, get_num_par_thawed, get_order_plot, get_par, get_pileup_model, get_source, get_source_component_image, get_source_component_plot, get_source_contour, get_source_image, get_source_plot, get_xsabund, get_xscosmo, get_xsxsect, get_xsxset, image_model, image_model_component, image_source, image_source_component, integrate, link, load_table_model, load_template_interpolator, load_template_model, load_user_model, normal_sample, reset, save_model, save_source, set_bkg_model, set_bkg_source, set_full_model, set_model, set_model_autoassign_func, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset, t_sample, uniform_sample
plotting
get_cdf_plot, get_pdf_plot, get_pvalue_plot, get_pvalue_results, plot_cdf, 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_delchi, save_resid
tools
aprates, modelflux
utilities
calc_chisqr, calc_data_sum, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, eqwidth, gamma, igam, igamc, incbet, lgam
visualization
contour_model, contour_ratio, contour_resid