New compact particle acceleration structures, including but not limited to plasma, THz and direct laser driven accelerators, have in common that they cover a wide energy range of potential final energies and often show a large energy spread. Moreover, they may initially have a rather large emittance. To analyze the energy range of a single shot and/or to deflect the beam to safely dump the electrons away from an end-station requires an electron kicker covering a large energy range. Here, we present a magnetic dipole structure based on a 2D Halbach array. For the current experimental test accelerator in AXSIS, an electron beam in the energy range from 4 to 20 MeV is deflected by 90 degree and energetically dispersed. In direct contrast to a simple magnetic dipole, an array of cubic magnet blocks with tailored magnetization directions allows a focusing of the beam for both longitudinal and transverse directions at 90 degree bend. A generic algorithm optimizes the magnetic field array to the predefined deflection angle and divergence. The modular array structure, in combination with the algorithm enables a simple exchange of magnets to adapt for different beam parameters.