calc_photon_flux
- sherpa.astro.utils.calc_photon_flux(data, src, lo=None, hi=None)[source] [edit on github]
Integrate the source model over a pass band.
Calculate the integral of S(E) over a pass band, where S(E) is the spectral model evaluated for each bin.
- Parameters:
data – The data object to use.
src – The source expression: this should not include any instrument responses.
lo (number, optional) – 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
andhi
are given by the current analysis setting of thedata
parameter.hi (number, optional) – 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
andhi
are given by the current analysis setting of thedata
parameter.
- Returns:
The flux or flux density of the source model. For X-Spec models the flux units will be photon/cm^2/s and the flux density is either photon/cm^2/s/keV or photon/cm^2/s/Angstrom, depending on the analysis setting.
- Return type:
flux
See also
calc_data_sum
Sum up the data values over a pass band.
calc_model_sum
Sum up the fitted model over a pass band.
calc_energy_flux
Integrate the source model over a pass band.
calc_source_sum
Sum up the source model over a pass band.
Notes
The units of
lo
andhi
are determined by the analysis setting for the data set (e.g.data.get_analysis
).Any existing filter on the data set is ignored by this function.
The flux is calculated from the given source model, so if it includes an absorbing component then the result will represent the absorbed flux. The absorbing component can be removed, or set to absorb no photons, to get the un-absorbed flux.
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.
Examples
Calculate the photon flux over the ranges 0.5 to 2 and 0.5 to 7 keV, and compared to the energy fluxes for the same bands:
>>> data.set_analysis('energy') >>> calc_photon_flux(data, smodel, 0.5, 2) 0.35190275 >>> calc_photon_flux(data, smodel, 0.5, 7) 0.49050927 >>> calc_energy_flux(data, smodel, 0.5, 2) 5.7224906878061796e-10 >>> calc_energy_flux(data, smodel, 0.5, 7) 1.3758131915063825e-09
Calculate the photon flux density at 0.5 keV:
>>> calc_photon_flux(data, smodel, 0.5) 0.64978176