Corrects logic in calc_leadtime_sd

Indexes in i, j and horizon were off