idlastro / FITS I/O: XMEDSKY

[Source code]

NAME
XMEDSKY
PURPOSE
Subtract sky from an image as a 1-D function of X
EXPLANATION
This procedure is designed to remove the sky from slitless spectra.
The sky is assumed to vary with wavelength (along a row) but not with
position (along a column).    The sky is computed as the 
column-by-column median of pixels within 3 sigma of the image global 
median.   This procedure is called by the cosmic ray rejection routine
CR_REJECT
CALLING SEQUENCE
XMEDSKY, Image, Bkg, [ CLIP=[x0, x1, y0, y1], NSIG= ]
INPUTS
Image:  Input image for which sky vector is to be computed.
INPUT KEYWORD PARAMETERS
CLIP:   [x0, x1, y0, y1]: region of image to be used for all
        statistical computations.    Default is to use the entire
        image.   For STIS 1024 x 512 slitless spectra, the suggested
        value is CLIP = [32,1023,12,499]
NSIG:   Positive scalar giving the number of sigma a pixel must be above
        the global median to be reject.   Default is 3 sigma.
OUTPUT PARAMETER
Bkg:    Vector of sky values.
MODIFICATION HISTORY
Written by:     R. S. Hill, Hughes STX, 20 Oct. 1997
Converted to V5.0, use STDDEV()   W. Landsman   June 1998
Check for valid WHERE, added NSIG keyword  W. Landsman   December 2000 
Assume since V5.1 so always use STDDEV  W. Landsman Feb 2004 
Assume since V5.6 use DIMEN keyword to MEDIAN W. Landsman Jan 2008