Rebin the energy grid used in the main stage by a factor eegridfactor
For each energy
if source box is circular or annular:
Calculate the enclosed fraction for this box radius
,off-axis angle and energy.
if source box is non-circular:
Generate a model of the PSF centred at [xdet,ydet].
Loop over each pixel in filtered detector map,
calculating PSF contribution in every cell.
Add cell contribution to running total.
This gives fraction of PSF within selected region for given energy
Write encircled energy fraction as an element of an encircled energy fraction vector.
Interpolate EE fraction vector to map to original energy grid used in main stage.