function corsh1, line ;+ ; ; function: corsh1 ; ; purpose: find the shift of line by finding the minimum intensity to ; sub-pixel accuracy with polynomial interpolation ; ;============================================================================== if n_params() ne 1 then begin print print, "usage: ret = corsh1(line)" print print, " Find the shift of line by finding the minimum" print, " intensity to sub-pixel accuracy with polynomial" print, " interpolation." print return, 0 endif ;- nx = sizeof(line, 1) amin = min(line, imin) ; ensure imin stays within acceptable limits imin = imin < (nx-2) imin = imin > 1 xx = indgen(nx) ; fit quadratic about this point using poly_fit ;coeff = poly_fit(xx(imin-1:imin+1), line(imin-1:imin+1), 2) ; use direct solution for quadratic coeff = fltarr(3) l0 = line(imin-1) & l1 = line(imin) & l2 = line(imin+1) xx0 = xx(imin-1) & xx1 = xx(imin) & xx2 = xx(imin+1) coeff(2) = (l2-l0)*(xx1-xx0)-(l1-l0)*(xx2-xx0) coeff(2) = coeff(2)/((xx1-xx0)*(xx2-xx0)*(xx2-xx1)) coeff(1) = (l1-l0)/(xx1-xx0) - coeff(2)*(xx1+xx0) ; constant coefficient coeff(0) not needed ;coeff(0) = l0 - coeff(1)*x1 - coeff(2)*x1*x1 ; return root of equation return, -coeff(1) / 2.0 / coeff(2) end