% @(#)skyflaccd.hlq	19.1 (ESO-IPG) 02/25/03 14:15:05
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%.COPYRIGHT  (c)  1993 European Southern Observatory
%.IDENT      skyflaccd.hlq
%.AUTHOR     RHW, IPG/ESO
%.KEYWORDS   MIDAS, ccd package, SKYFLAT/CCD
%.PURPOSE    On-line help file for the command: SKYFLAT/CCD
%.VERSION    930827 RHW Documentation created
%---------------------------------------------------------------------
\se
SECTION./CCD
\es\co
SKYFLAT/CCD                                                     25-Mar-1993 RHW
\oc\su
SKYCOR/CCD [in_spec] [out_frm] [xboxmn,xboxmx] [yboxmn,yboxmx] [clip] 
           [lowsig,higsig]
	Apply sky observation to flat field to remove illumination pattern
\us\pu
Purpose: 
	Apply sky observation to flat field to remove illumination pattern
\up\sy
Syntax:     
        SKYFLAT/CCD [in_spec] [out_frm] [xboxmn,xboxmx] [yboxmn,yboxmx]
                    [clip] [lowsig,higsig]
\ys\pa
        in_spec = single sky frame or MIDAS CCD reduction table (with the
                  extension .tbl) containing the names of the sky frame(s) 
                  in column :SKY. Default input is taken from the keyword 
                  CCD_IN.
\ap\pa
        out_frm = name of the illumination corrected sky flat field. Default 
                  the output file the same as the input sky flat frame. Hence,
                  by default the input sky flat frame will be OVERWRITTEN.\\
                  This parameter is only used is case of single frame input 
                  for the first parameter. In case the output is taken a 
                  reduction table the output frame(s) will also OVERWRITE the 
                  original flat frames.
\ap\pa  
        xboxmn,xboxmx = minimum and maximum smoothing box size along the x 
                  axes.  The minimum box size is used at the edges and grows 
                  to the maximum size in the middle of the image.  This 
                  allows the smoothed image to better represent gradients 
                  at the edge of the image. If a size is less then 1 it is 
                  interpreted as a fraction of the image size. If a size is
                  greater than or equal to 1 then it is the box size in 
                  pixels.  A size greater than the size of image selects a 
                  box equal to the size of the image. Default values are taken
                  from the keyword IL_XBOX.
\ap\pa
        yboxmn,yboxmx = see above. Default values are taken from IL_YBOX.
\ap\pa
        clip =    Clean the input frame(s) of objects? If yes then a clipping 
                  algorithm is used to detect and exclude objects from the 
                  smoothing. Default taken from IL_CLIP.
\ap\pa
        lowsig,higgsig = sigma clipping thresholds above and below the 
                  smoothed illumination. Default values are taken from
                  the keyword IL_SIGMA. The keyword is only read in case 
                  clip=yes.
\ap\no
Note:     
        The command operates very similar to the command REDUCE/CCD, which
        the exception that the command not check for the exposure type of 
        the input frame.

        In case the input is an association table the command will check for
        the existence of the flat frames in the column :SKY in the association
        table. Flat frames that do not exit will be created first, provided 
        the association table contain the :SKY column. Other relevant 
        calibration frames for processing the flat frames, will be taken 
        from the corresponding calibration columns.\\

        After the reduced sky frame is obtained, the sky illumination frame 
        is produced by heavily smoothing the calibrated sky frames using a 
        moving "boxcar" average. The effects of objects in the frames may be 
        minimized by using a sigma clipping algorithm to detect and exclude 
        the objects from the average. This illumination frame will be used to 
        make an illumination corrected flat field (sky flat) according to the 
        formula: \\
                     f_new = f_old*ill_sky/scale, where\\
        f_new is the corrected flat field, f_old is the original input flat,
        used to reduce the blank sky frame, ill_sky is the illumination 
        correction determined from the sky, and scale is the nomalisation 
        factor. \\

        The original flat frame is multiplied by the scaled sky illumination 
        correction frame to produce the illumination corrected flat. The 
        output will OVERWRITE the original (reduced) flat frames. Hence, the 
        output sky flat will automatically be used as flat in subsequent 
        calibration procedure(s).\\
        NOTE: THE MASTER FLAT FIELDS WILL BE OVERWRITTEN BY THE CORRECTED ONES.
\\
        In the case of single frame input and all calibration frames input 
        will be taken from the SC_ keywords and must exist. Also here, by
        default in the output illumination corrected flat will replace the 
        input flat.\\

        The IM_SEC keyword may be used to assign a region of interest for which
        the correction has to be done.\\

        For more information see the CCD chapter in Volume B of the User's 
        manual.

\on\see
See also:   
        SET/CCD, SHOW/CCD, HELP/CCD, REDUCE/CCD, SKYCOR/CCD, 
\ees\exs
Examples:
\ex
        SKYFLAT/CCD redtbl.tbl
        Reduce all sky frames in the the ccd reduction table redtbl.tbl. All 
        master calibration frames will be obtained from that reduction table. 
        Do the calibration according to the keyword settings, including the 
        flat fielding. From the calibrated sky produce the illumination frame,
        using the  `IL_' keyword settings. Hereafter compute the output sky 
        flat by multiplying the illumination frame with the original flat 
        field. The output sky flats will have overwrite the original flats.
\xe\ex
        SKYFLAT/CCD m100rraw_sk m100rraw_sf
        Start the ccd reduction sequence for the frame m100rraw. The output
        frame will be m100rraw_sf. In case only dark and flat field correction
        is to be applied the names of these two calibration frames will be 
        obtained from the keyword SC_DKFRM and SC_FFFRM, respectively.
\xe\sxe



