% @(#)fit_mosa.hlq	19.1 (ESO-SDAG) 02/25/03 14:15:00
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%.COPYRIGHT  (c) 1995 European Southern Observatory
%.IDENT      fit_mosa.hlq
%.AUTHOR     RHW, IPG/ESO
%.KEYWORDS   MIDAS, ccd package, FIT/CCD
%.PURPOSE    On-line help file for the command: FIT/CCD
%.VERSION    950724 RHW created
%---------------------------------------------------------------------
\se
SECTION./MOSAIC
\es\co
FIT/MOSAIC                                                    20-Sep-1995 RHW
\oc\su
FIT/MOSAIC in_frm in_msk in_tab out_frm [match] [nxrsub,nyrsub] [xref,yref] 
           [x_size,y_size]
	Align and match the elements of the mosaiced frame
\up\sy\us\pu
Purpose:    
	Align and match the elements of the mosaiced frame
\up\sy
Syntax:     
        FIT/MOSAIC in_frm in_msk in_tab out_frm [match] [nxrsub,nyrsub] 
                   [xref,yref] [x_size,y_size]
\ys\pa
        in_frm=  The mosaiced frame to be aligned. This frame must have been 
                 produced by the CREATE/MOSAIC command.
\ap\pa
        in_msk=  A input image containing information which of the pixels
                 of the input subrasters are considered bad and hence should
                 be excluded for the matching process. Valid data points 
                 should have the values 1. The size of the image must the 
                 identical to the size of the individual input subrasters. 
                 Default all pixels should be used.
\ap\pa
        in_tab=  The database table from the CREATE/MOSAIC task. This table 
                 contains all relevant information about the subrasters and
                 the way the mosaic is built.
\ap\pa 
        out_frm= The aligned output frame produced by the command. No default.
\ap\pa 
        match=   Match intensities using the overlap region between adjacent 
                 subrasters. The median intensity is computed in the overlap 
                 region and the intensity scale of the current subraster is  
                 scaled to that of the previous subraster. Intensities are 
                 matched in two dimensions, first in the order in which they
                 were placed in the output image and then in the orthogonal 
                 dimension. The default is "*", i.e. match everything.
                 Those subrasters to be matched must be listed by number. For 
                 example to match intensities for subrasters 1 to 5, 10 and 
                 20 set match = "1:5,10,20". To match all the subrasters set 
                 match = "*".
\ap\pa
        nxrsub,nyrsub= The column and row index of the reference subraster.
                 This will default to the central subraster.
\ap\pa
        xref,yref= The x and y offset of the destination in the output frame 
                 of the reference subraster. By default the reference 
                 subraster occupies the same position in the output frame that
                 it does in the input frame.
\ap\pa
        nocols,norows= The number of columns and lines in the output frame. The
                 defaults are the number of columns and lines in the input 
                 frame.
\ap\no
Note:
        Like the ALIGN and MATCH commands, FIT/MOSAIC is controlled by the 
        input parameters and an additional number of CCD keywords: \\
        MO_TRIM  - the number of columns or rows to trim off each edge of 
                   each input subraster before inserting it in the output 
                   frame. The default is to trim 1 column or row at each 
                   edge.\\
        MO_INTER - The type of interpolant use to shift the subraster. 
                   Possible options area : nearest, linear, poly3, poly5, and 
                   spline3.\\
        MO_BLANK - to define the pixel intensity in undefined regions.
\\
        FIT/MOSAIC is able to a mosaicing process taking into account all 
        information that is available to determine the best estimate for the 
        offsets between the individual frames. Rather then having a bootstrap 
        approach like in the command MATCH/MOSAIC the FIT/MOSAIC command 
        uses all offsets between all frames.
\\
        The commands does the mosaicing in a two step approach. The first one
        is to determine the offset between the single subraster in their
        overlapping regions. In the second step this information is then 
        used to do a least square fit. 
\\
        In the first step the overlapping areas are obtain from the input
        database table. Within the overlapping regions the median intensities
        are determined and the offsets of these median values calculated.
        Bad pixels indicated by the bad pixel input image will not be
        taken into account. Also, a pixel will only be used in the calculation 
        of the median if its corresponding pixel is also used in the other 
        frame. 
\\
        In the second step the relative offsets are used to determine the 
        best fitting background offset for each frame. Using the "match"
        input parameter the user can excluded one or more subrasters from 
        the fit. In addition to the output file, the command will output 
        the offset for each subraster and the square root of the sum of the
        residuals and the standard deviation of the residuals. From this
        information bad subraster can be identified and excluded from the fit.
        The best result may been obtained by continuing this process until all
        frames more than 3 sigma above the mean have been excluded.
\\
\on\see
See also:   
        SET/CCD, SHOW/CCD, CREATE/MOSAIC, SHIFT/MOSAIC, ALIGN/MOSAIC, 
        MATCH/MOSAIC
        
\ees\exs
Examples:
\ex
	FIT/MOSAIC mosin ? mosdb mosout
        Align and match the mosin frame with respect to default reference 
        subraster. Use the table mosdb for getting the overlap regions. The
        output frame is mosout. All pixels will be taken into account.
\xe\ex
 	FIT/MOSAIC mosin mosmsk mosdb mosout 3,4 6,5 
        The same as above but the reference frame in the mosaic is now 
        (subx=6, suby=5). The vaid pixels will bne taken from the mask mosmsk.
        the subrasters 3 and 4 will not be taken into account in the fitting.
\xe \sxe






