calc_dtmax_mw function

Calculate dTmax by the moving window method