compile_energy_grid

sherpa.astro.utils.compile_energy_grid(arglist)[source] [edit on github]

Combine several grids (energy, channel, wavelength) into one.

This function combines several grids into one, such that the model does not have to be evaluated several times, just because the same energy point occurs in every grid.

This function works under the assumption that evaluating the model is expensive and it is is worthwhile to do some bookkeeping to be able to derive the model for all intervals needed with the minimum number of model points.

Parameters:

arglist (list of tuples) – The list contains the input energy grids. Each tuple is a pair of arrays specifying the lower and upper limits for the bins in each input grid.

Returns:

out – The elements of the list are: elo : array of lower bin values; ehi : array of upper bin values; and htable : list of tuples in the same format as the input. The entries in htable are indices into elo and ehi that return the original input arrays.

Return type:

list

Examples

>>> compile_energy_grid([([1,3,5], [3, 5, 7]), ([0, 1, 2], [1, 2, 3])])
[array([0, 1, 2, 3, 5]),
 array([1, 2, 3, 5, 7]),
 [(array([1, 3, 4], dtype=int32), array([2, 3, 4], dtype=int32)),
  (array([0, 1, 2], dtype=int32), array([0, 1, 2], dtype=int32))]]