idlastro / FITS I/O: SKYADJ_CUBE

[Source code]

NAME
SKYADJ_CUBE
PURPOSE
Sky adjust the planes of a datacube.
EXPLANATION
When removing cosmic rays from a set of images, it is desirable that
all images have the same sky level.    This procedure (called by
CR_REJECT) removes the sky from each image in a data cube.    
CALLING SEQUENCE
SKYADJ_CUBE,Datacube,Skyvals,Totsky
MODIFIED ARGUMENT
Datacube:  3-D array with one image of same field in each plane.
           Returned with sky in each plane adjusted to zero.
OUTPUT ARGUMENTS
Skyvals:   Array of sky values used on each plane of datacube.
           For a scalar sky, this parameter is a vector
           containing the sky value for each image plane.  For a
           vector sky, this parameter is a 2-D array where each
           line corresponds to one image plane.
INPUT KEYWORD PARAMETERS
REGION   - [X0,X1,Y0,Y1] to restrict area used for computation
           of sky.  Default is 0.1*Xdim, 0.9*Xdim, 0.1*Ydim,
           0.9*Ydim.  If INPUT_MASK is specified, the two 
           specs are combined, i.e., the intersection of the
           areas is used.
VERBOSE  - Flag.  If set, print information on skyvals.
NOEDIT   - Flag.  If set, return sky values without changing
           datacube.
XMEDSKY  - Flag.  If set, return vector sky as a function of X.
SELECT   - Array of subscripts of planes of the cube to process.
           (Default=all)
EXTRAPR  - Applies only in XMEDSKY mode.
           Subregion to use for polynomial extrapolation of sky
           vector into portions excluded by REGION parameter.
           (Default=first and last 10% of pixels; set to zero
           to defeat extrapolation)
EDEGREE  - Applies only in XMEDSKY mode.  
           Degree of polynomial for extrapolation (Default=1)
INPUT_MASK - Cube of flags corresponding to data cube.  If used,
           the sky computation is restricted to the smallest 
           contiguous rectangle containing all the pixels flagged
           valid (with 1 rather than 0).
PROCEDURE
Uses astronomy library "sky" routine for scalar sky and
column-by-column median for vector sky.
MODIFICATION HISTORY
10 Jul. 1997   - Written.  R. S. Hill, Hughes STX
20 Oct. 1997   - 1-D sky option.  RSH
 7 Aug. 1998   - SELECT keyword.  RSH
 6 Oct. 1998   - Extrapolation.  RSH
 7 Oct. 1998   - INPUT_MASK added.  RSH
21 Oct. 1998   - Fallback to 3-sigma clipped mean if mode fails.  RSH
22 Mar. 2000   - Combine mask with region rather having mask
                 override region.  Improve comments.  RSH
16 June 2000   - On_error and message used.  Square brackets for array 
                 subscripts.  EXTRAP included in this file.  
                 WBL & RSH, 16 June 2000
NAME
EXTRAP
PURPOSE
This procedure fills in the ends of a one-dimensional array from
interior portions using polynomial extrapolation.
CATEGORY
Image processing
CALLING SEQUENCE
EXTRAP, Deg, X, Y, Y2
INPUT POSITIONAL PARAMETERS
Deg:   Degree of polynomial
X:     Independent variable
Y:     Dependent variable
KEYWORD PARAMETERS
LIMS:  3-element array giving range of X to be used to fit
       polynomial and starting point where extrapolation is
       to be substituted; if not given, you click on a plot;
       order of elements is [xmin, xmax, xstart]; if LIMS is
       specified, then program is silent
OUTPUT POSITIONAL PARAMETERS
Y2:    Dependent variable with extrapolated portion filled in
SIDE EFFECTS
May pop a window for selecting range.
MODIFICATION HISTORY
Written by RSH, RITSS, 14 Aug 98
Spiffed up for library.  RSH, 6 Oct 98