;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; KPK geometric correction for 1/6 pixel gap in each of center rows of 2D ;;; array of radiance values (call them "radiances"): shift radiances ;;; 1/6 pixel inward toward center rows ;;; ;;; Model: center rows (rows (Nrow/2) & ((Nrow/2)-1)) are each 5/6 the height ;;; of other rows and are adjacent with no gap between them e.g. for ;;; an array of 1024 rows numbered from 0 at the bottom to 1023 at the ;;; top, with each row N split up into 6 sub-rows N.0 through N.5, with ;;; N.0 being the bottom sub-row in each row, the arrangement looks ;;; like the the following diagram: ;;; ;;; / 513.5 ;;; / 513.4 ;;; Row 513 ___/ 513.3 ;;; \ 513.2 ;;; \ 513.1 ;;; \ 513.0 ___ boundary between rows 512 & 513 ;;; / 512.5 ;;; / 512.4 ;;; Row 512 ---< 512.3 ;;; \ 512.2 ;;; \ 512.1 ___ missing 511.5 and 512.0 at 511/512 boundary ;;; / 511.4 ;;; / 511.3 ;;; Row 511 ---< 511.2 ;;; \ 511.1 ;;; \ 511.0 ___ boundary between rows 510 & 511 ;;; / 511.5 ;;; / 510.4 ;;; Row 510 ___/ 510.3 ;;; \ 510.2 ;;; \ 510.1 ;;; \ 510.0 ;;; ;;; Assumptions: ;;; ;;; 1) Input array already radiance-calibrated and flat-fielded to account for ;;; smaller area of center rows' pixels ;;; ;;; 2) All radiances for which no change is desired are excluded from ;;; input array argument (RarrIn) ;;; ;;; 3) No correction is applied to the top and bottom rows of the input array ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Inverse function function dical_onethirdgap_kpk_invert, RarrIn, frac, ifrac, dim2, halfdim2 rfrac = 1 / frac Rtmp = RarrIn iLoHi = [1L, dim2 - 2L] dLoHi = [1L, -1L] while iLoHi[0] lt iLoHi[1] do begin Rtmp[*,iLoHi] = (RarrIn[*,iLoHi] - Rtmp[*,iLoHi-dLoHi] * ifrac) * rfrac iLoHi = iLoHi + dLoHi endwhile return, Rtmp end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Main function function dical_onethirdgap_kpk, RarrIn, fraction=fracArg, invert=invert if n_elements(fracArg) eq 1L then begin frac=float(fracArg[0]) endif else begin frac=5./6 fracArg=frac endelse ifrac = 1-frac dims=size(RarrIn,/dim) ;;; assume 2-D dim2=dims[1] ;;; # of rows halfdim2 = dim2/2L ;;; half # of rows if keyword_set(invert) then $ return, dical_onethirdgap_kpk_invert( RarrIn, frac, ifrac, dim2, halfdim2) iw = indgen(dim2) ;;; indices of all rows iw = where(iw ne (halfdim2-1L) and iw ne halfdim2) ;;; " exluding 511 & 512 Rtmp=RarrIn ;;; copy input radiance array Rtmp[*,1:(dim2-2)] = RarrIn[*,iw] ;;; Array with all radiances shifted one ;;; row toward center rows return, RarrIn*frac + Rtmp*ifrac ;;; return frac of each row's radiances ;;; PLUS (1-frac) of next outward row's end