calc_autofocus function

Compute the autofocus portion of the stochastic gradient routine