This is a very straightforward implementation of the Kelner & Aharonian (2008) analytical parametrisation of the electron spectrum for Bethe-Heitler pair production (see Eq. 62 in their paper) for arbitrary tabulated photon fields. An example photon field (CMB) and output spectrum are provided for illustration purposes.
The output file format is intended to be compatible with CRPropa.
Nb: Numba is required to run the script in a reasonable amount of time.