def errfunc(Aj, beta): new_beta = SEDTools.spectralSlope(wl, fitfunc(Aj), dFlux, wlStart, wlStop, beta, strongLines=strongLines, lineWidths=lineWidths) return abs(new_beta[1]-beta)