darkhistory.spec.spectools.discretize — DarkHistory documentation

# darkhistory.spec.spectools.discretize

`darkhistory.spec.spectools.` `discretize`(eng, func_dNdE, *args)

  Discretizes a continuous function.

  The function is integrated between the bin boundaries specified by eng to obtain the discretized spectrum, so that the final spectrum conserves number and energy between the bin boundaries.

  Parameters: | eng : ndarray Both the bin boundaries to integrate between and the new abscissa after discretization (bin centers). func_dNdE : function A single variable function that takes in energy as an input, and then returns a dN/dE spectrum value. *args : optional Additional arguments and keyword arguments to be passed to func_dNdE.
  Returns: | Spectrum The discretized spectrum. rs is set to -1, and must be set manually.

  See also

  `rebin_N_arr()`

  Notes

  Given a spectrum \(dN/dE\), represented by the function `func_dNdE`, this function calculates the following quantities at the energy values \(E_i\) specified in `eng`:

  \[N[i] = \int_{E_i}^{E_{i+1}} \frac{dN}{dE} \, dE\]
  \[\epsilon[i] = \frac{1}{N[i]} \int_{E_i}^{E_{i+1}} E \frac{dN}{dE} \, dE\]

  We can now treat \(N[i]\) and \(\epsilon[i]\) as a list of bins with energies \(\epsilon[i]\) and number of particles \(N[i]\). This is now rebinned into the abscissa specified by `eng` using `rebin_N_arr()`, which conserves the total number.

#### Previous topic

darkhistory.spec.spectools

#### Next topic

darkhistory.spec.spectools.engloss_rebin_fast

### This Page

Show Source