Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/de_gulch_sort.pro'
function de_gulch_sort, image_data, sky, MIN_SORT=mins, BORDER=bo
;+
; NAME:
; de_gulch_sort
; PURPOSE:
; Estimate column pattern background in an image by
; sorting columns and then subtract the background
; to return flat fielded image.
; CALLING EXAMPLE:
; image_flat = de_gulch_sort( image, sky, MIN_SORT=9 )
; INPUTS:
; image = 2D array of data
; KEYWORDS:
; MIN_SORT = index of which element of sort to use at background,
; MIN=0 causes minimum to be the assumed background,
; MIN = #pixels_per_row/2 causes median to be used (default).
; OUTPUTS:
; imback = the estimated sky or row/column pattern background.
; RESULT:
; Function returns the flat fielded image (background subtracted).
; EXTERNAL CALLS:
; function flat_by_sort
; PROCEDURE:
; MODIFICATION HISTORY:
; Written, Frank Varosi NASA/GSFC 1992.
;-
imtmp = image_data
sim = size( imtmp )
ny = sim(2)
if N_elements( bo ) NE 1 then bo=2
imtmp(0,bo) = flat_by_sort( image_data(*,bo:ny-bo-1), sky, $
MIN_S=mins, /TRANSPOSE )
if (bo GT 0) then begin
imtmp(0,0) = imtmp(*,0:bo-1) - sky(*,0:bo-1)
imtmp(0,ny-bo) = imtmp(*,ny-bo:ny-1) - sky(*,0:bo-1)
endif
return, imtmp
end