srcmodel.spectrum

ximpol.srcmodel.spectrum.int_eflux2pl_norm(integral, emin, emax, index, erg=True)[source]

Convert an integral energy flux into the corresponding power-law normalization.

ximpol.srcmodel.spectrum.main()[source]
ximpol.srcmodel.spectrum.pl_norm(integral, emin, emax, index, energy_power=0.0)[source]

Return the power-law normalization resulting in a given integral flux (or integral energy flux, or more in general integral of the flux multiplied by a generic power of the energy) between the minimum and maximum energies assuming a given spectral index.

More specifically, given a power law of the form

\mathcal{S}(E) = C\left( \frac{E}{E_0} \right)^{-\Gamma}
\quad [{\rm keV}^{-1}~{\rm cm}^{-2}~{\rm s}^{-1}],

(where E_0 = 1~{\rm keV}) we define \beta = (1 + p - \Gamma) and calculate

I_{p} = \int_{E_{\rm min}}^{E_{\rm max}} E^{p}\mathcal{S}(E) dE =
\begin{cases}
\frac{C E_0^{\Gamma}}{\beta}
\left( E_{\rm max}^{\beta} - E_{\rm min}^{\beta}\right)
\quad \beta \neq 0\\
C E_0^{\Gamma} \ln \left( E_{\rm max}/E_{\rm min} \right)
\quad \beta = 0\\
\end{cases}
\quad [{\rm keV}^{p}~{\rm cm}^{-2}~{\rm s}^{-1}].

Hence

C =
\begin{cases}
\frac{I_p\beta}{E_0^{\Gamma}
\left( E_{\rm max}^{\beta} - E_{\rm min}^{\beta}\right)}
\quad \beta \neq 0\\
\frac{I_p}{E_0^{\Gamma}
\ln \left( E_{\rm max}/E_{\rm min} \right)}
\quad \beta = 0.
\end{cases}

Parameters:
  • integral (float or array) – The value of the integral flux or energy-to-some-power flux
  • emin (float) – The minimum energy for the integral flux
  • emax (float) – The maximum energy for the integral flux
  • index (float) – The power-law index
  • energy_power (float) – The power of the energy in the integral
  • erg (bool) – if True, convert erg to keV in the calculation.
ximpol.srcmodel.spectrum.power_law(C, Gamma)[source]

Photon energy spectrum as a function of energy and time.

If C and Gamma are callable, we assume that the argument of the __call__ function is the time, and this is how we treat them internally.

class ximpol.srcmodel.spectrum.xCountSpectrum(source_spectrum, aeff, t, column_density=0.0, redshift=0.0, scale_factor=1.0)[source]

Class representing a count spectrum, i.e., the convolution of the source photon spectrum and the detector effective area

\mathcal{C}(E, t) = \mathcal{S}(E, t) \times A_{\rm eff}(E)
\quad [\text{s}^{-1}~\text{keV}^{-1}].

This is a subclass of xUnivariateAuxGenerator, providing all the facilities implemented in a bivariate spline, along with the capability of extracting random numbers.

Note that the light curve corresponding to the count spectrum is calculated when a class object is instantiated.

build_energy_integral(emin=None, emax=None)[source]

Build the energy-integrated count spectrum, i.e.

\int_{E_{\rm min}}^{E_{\rm max}} \mathcal{C}(E, t) dE \quad
[\text{Hz}].

The output is stored in the form of a xUnivariateGenerator, featuring all the spline facilities, along with the capability of extracting random numbers.

build_light_curve()[source]

Build the light curve, i.e., the count spectrum, integrated over the entire energy range, as a function of time.

build_mdp_table(energy_binning, modulation_factor)[source]

Calculate the MDP values in energy bins, given the modulation factor of the instrument as a function of the energy.

Parameters:
  • energy_binning (array) – The energy binning
  • modulation_factor (ximpol.irf.mrf.xModulationFactor instance) – The instrument modulation factor as a function of the energy.
build_time_integral(tmin=None, tmax=None)[source]

Build the time-integrated count spectrum, i.e.

\int_{t_{\rm min}}^{t_{\rm max}} \mathcal{C}(E, t) dt \quad
[\text{keV}^{-1}].

The output is stored in the form of a xUnivariateGenerator, featuring all the spline facilities, along with the capability of extracting random numbers.

num_expected_counts(tmin=None, tmax=None, emin=None, emax=None)[source]

Return the number of expected counts within a given time interval and energy range

\int_{t_{\rm min}}^{t_{\rm max}}
\int_{E_{\rm min}}^{E_{\rm max}}
\mathcal{C}(E, t) dt dE