## LinearInterp

The routines included in the Rebin namespace can be used to map XSPEC model flux arrays onto different energy bins. The first step is always to run the findFirstBins and initializeBins routines to set up the mapping between the current and target energy arrays.

```bool findFirstBins(const RealArray& currentBins, const RealArray& targetBins,
const Real FUZZY, size_t& currentStart, size_t& targetStart)
void initializeBins(const RealArray& currentBins, const RealArray& targetBins,
const Real FUZZY, size_t& currentStart, size_t& targetStart,
IntegerVector& startBin, IntegerVector& endBin,
RealArray& startWeight, RealArray& endWeight)
```

FUZZY is a fractional fuzziness for deciding whether bin boundaries are equal. The output arrays from initializeBins define the mapping between the current and target energies.

For additive models the rebin function should be used and for multiplicative models the interpolate function should be used. Examples can be found in zashift.cxx and zmshift.cxx in the XSFunctions directory. The lowValue and highValue arguments can be used to define output values below and above the energies available from the input. If left out they default to 0.

```void rebin(const RealArray& inputArray, const IntegerVector& startBin,
const IntegerVector& endBin, const RealArray& startWeight,
const RealArray& endWeight, RealArray& outputArray,
const Real lowValue=0.0, const Real highValue=0.0);
void interpolate(const RealArray& inputArray, const IntegerVector& startBin,
const IntegerVector& endBin, const RealArray& startWeight,
const RealArray& endWeight, RealArray& outputArray,
bool exponential, const Real lowValue=0.0,
const Real highValue=0.0)
```

The gainRebin function is a special case used within the gain command and linInterpInteg assumes that the input is in photons/cm/s/keV at specific energy points and is integrated over the target bin sizes.

```void gainRebin(const RealArray& inputArray, const IntegerVector &startBin,
const IntegerVector& endBin, const RealArray& startWeight,
const RealArray& endWeight, RealArray& outputArray)
void linInterpInteg(const RealArray& currentPoints,
const RealArray& inputdValues,
const RealArray& targetBins, RealArray& outputValues,
const Real lowValue=0.0, const Real highValue=0.0)
```

HEASARC Home | Observatories | Archive | Calibration | Software | Tools | Students/Teachers/Public