MAKEMOS registers the set of images supplied by matching their pixel indices and then forms a
mosaic by combining the separate input pixel values at each location using a nominated
data-combination method (by default, it takes the median). The resulting mosaic is of sufficient extent
to accommodate all the input data, with any output data pixels which do not receive values from the
input being set to the
" pixel value. Account is taken of variance information associated with the
input images, and all calculations are optimally weighted to minimise the output noise. Output
variance estimates for the final mosaic may also be produced.
Forming a mosaic in this way will normally be successful only so long as the input data are mutually consistent. Unfortunately, this is often not the case, since data frequently have differing effective exposure times and background levels which give discontinuities in the final mosaic. Thus, MAKEMOS also addresses the problem of normalising the input images to make them mutually consistent. It does this by optionally applying optimised multiplicative and/or additive corrections (termed scale-factor and zero-point corrections) to each image before forming the mosaic. These optimised corrections are determined by inter-comparing the input images in pairs, using the regions where they overlap to determine the relative scale-factor and/or zero-point difference between each pair. A self-consistent set of corrections is then found which, when applied to each input image, will best eliminate these observed differences and give a smooth mosaic.
"data combination method is selected for producing the output mosaic (see the METHOD parameter). A fraction alpha (approximately) of the available values is removed from each extreme. This may take values in the range 0 to 0.5. [0.2]
"also counts, if supplied). In this case, if CMPVAR is set to TRUE, then variance information is used to correctly weight the input data whenever a pair of input images are inter-compared and both have variance information available.
The default behaviour is to use variance information during inter-comparisons. This may be
suppressed by setting CMPVAR to FALSE, which sometimes gives faster execution without greatly
affecting the result (also see the
" section). However, if input data with similar
values have widely differing variance values within the same input image, then use of input
variance information is recommended (this could happen, for instance, if an input image is
the result of a previous mosaic-ing process). [TRUE]
Otherwise if GENVAR is TRUE and either USEVAR is FALSE or some of the input images do not contain error information, then output variances will be generated using the natural variations in the input data. Obviously this method should only be used if there are many input datasets, which also provide good coverage of the output area. If this option is chosen any regions of the output image that have only one input value will have their associated variances set bad.
The default for this parameter depends on the presence of error information in the input images. If all have error information then the default is TRUE, otherwise it is FALSE.
The input images are normally accessed only for reading. However, if the MODIFY parameter is set to
TRUE (and scale-factor or zero-point corrections are being calculated) then each of the
will be modified by applying the calculated corrections.
If the logging system has been initialised using CCDSETUP, then the value specified there will be
used. Otherwise, the default is
TERMINAL – Send output to the terminal only
LOGFILE – Send output to the logfile only (see the LOGFILE parameter)
BOTH – Send output to both the terminal and the logfile
NEITHER – Produce no output at all
If the logging system has been initialised using CCDSETUP, then the value specified there will be
used. Otherwise, the default is
"data combination method is selected (see the METHOD parameter). [Maximum real value]
If the specified number of iterations is exceeded without achieving the accuracy required by the settings of the TOLS and TOLZ parameters, then a warning message will be issued, but the results will still be used. The value given for MAXIT must be at least one. 
MEAN – Mean of the input data values
MEDIAN – Weighted median of the input data values
TRIMMED – An
"alpha trimmed mean
" in which a fraction alpha of the values are removed from
MODE – An iteratively
" mean which approximates to the modal value
SIGMA – A sigma clipped mean
THRESHOLD – Mean with values above and below given limits removed
MINMAX – Mean with the highest and lowest values removed
BROADENED – A broadened median (the mean of a small number of central values)
FASTMED – Unweighted median of the input data values
"data combination method is selected (see the METHOD parameter). [Minimum real value]
"images and will not be modified. However, if scale-factor or zero-point corrections are being calculated (see the SCALE and ZERO parameters), then giving a TRUE value for MODIFY indicates that these images are themselves to be modified by applying the calculated corrections before the output mosaic is formed.
This facility provides a means of applying corrections to individual images (e.g. to mutually normalise them) without necessarily also combining them into a mosaic. It may also be useful if several invocations of MAKEMOS are to be made with different parameter settings; by specifying MODIFY=TRUE for the first invocation, scale-factor or zero-point corrections may be applied to normalise the input data so that this need not be repeated on each invocation.
WARNING: Caution should be exercised if setting MODIFY to TRUE, as information about the
uncorrected data values of the
" images will not be retained. [FALSE]
"data combination method is selected (see the METHOD parameter). 
"optimum number of overlaps
"which an image should have with its neighbours and controls the number of inter-comparisons made between pairs of overlapping images when determining scale-factor or zero-point corrections (see the SCALE and ZERO parameters).
The need for this parameter arises because when multiple input images are supplied there may be a large number of potential pair-wise overlaps between them. To prevent them all being used, which may take far longer than is justified, this set of potential overlaps is reduced by elimination, starting with the smallest ones (as measured by the number of overlapping pixels) and continuing until no more overlaps can be removed without reducing the number of overlaps of any image below the value given for OPTOV. In practice, this means that each image will end up with about (although not exactly) OPTOV overlaps with its neighbours, with the largest overlaps being preferred.
Note that although this algorithm is effective in reducing the number of overlaps, it is not guaranteed always to result in a set of overlaps which allow the optimum set of corrections to be calculated. In practice, problems from this cause are unlikely unless unusual patterns of image overlap are involved, but they may be solved by increasing the value of OVOPT and/or constructing the required mosaic in pieces by running MAKEMOS several times on different sets of input images.
In some cases, reducing the value of OVOPT may reduce the number of inter-comparisons made, and hence reduce the execution time, but if too few inter-comparisons are made, there is a risk that the corrections obtained may not be the best possible.
This parameter is only used if SCALE or ZERO is set to TRUE. 
"images are being modified (by setting the MODIFY parameter to TRUE), then it may optionally be omitted by supplying a null value (!). In this case, no output mosaic will be formed.
"in the output image. Alternatively, if a FALSE value is given, then the output image will be given an appropriate floating point data type.
When using integer input data, the former option is useful for minimising the storage space required for large mosaics, while the latter typically permits a wider output dynamic range when necessary. A wide dynamic range is particularly important if a large range of scale factor corrections are being applied (as when combining images with a wide range of exposure times).
If a global value has been set up for this parameter using CCDSETUP, then that value will be used. [TRUE]
This provides a means of retaining the calibration of a set of data, even when corrections are being applied, by nominating a reference image which is to remain unchanged. It also allows the output mosaic to be normalised to any externally-calibrated image with which it overlaps, and hence allows a calibration to be transferred from one set of data to another.
If the image supplied via the REF parameter is one of those supplied as input via the IN parameter, then this serves to identify which of the input images should be used as a reference, to which the others will be adjusted. In this case, the scale-factor and/or zero-point corrections applied to the nominated input image will be set to one and zero, and the corrections for the others will be adjusted accordingly.
Alternatively, if the reference image does not appear as one of the input images, then it will be included as an additional set of data in the inter-comparisons made between overlapping images and will be used to normalise the corrections obtained (so that the output mosaic is normalised to it). However, it will not itself contribute to the output mosaic in this case. [!]
If SCALE is set to TRUE, then MAKEMOS will inter-compare the images supplied as input and will estimate the relative scale-factor between selected pairs of input data arrays where they overlap. From this information, a global set of multiplicative corrections will be derived which make the input data as mutually consistent as possible. These corrections will be applied to the input data before combining them into a mosaic.
Calculation of scale-factor corrections may also be combined with the use of zero-point corrections (see the ZERO parameter). By default, no scale-factor corrections are applied. [FALSE]
"data combination methods are selected (see the METHOD parameter). This value must be positive. [4.0]
"sky noise suppression factor
"used to control the effects of sky noise when pairs of input images are inter-compared to determine their relative scale-factor. It is intended to prevent the resulting scale-factor estimate being biased by the many similar values present in the
"of typical astronomical data. SKYSUP controls an algorithm which reduces the weight given to data where there is a high density of points with the same value, in order to suppress this effect. It is only used if a scale factor is being estimated (i.e. if SCALE is TRUE).
A SKYSUP value of unity can often be effective, but a value set by the approximate ratio
of sky pixels to useful object pixels (i.e. those containing non-sky signal) in a
image overlap region will usually be better. The precise value is not critical. A value of zero
disables the sky noise suppression algorithm completely. The default value for SKYSUP is
where n is the number of significant dimensions in the output mosaic. Hence, for a 2-dimensional
image, it will default to 10 which is normally reasonable for CCD frames of extended objects
such as galaxies (a larger value, say 100, may give slightly better results for star fields).
The value given for TOLS specifies the tolerable fractional error in the estimation of the relative scale-factor between any pair of input images. This value must be positive. [0.001]
The value given for TOLZ specifies the tolerable absolute error in the estimation of the relative zero-point between any pair of input images whose relative scale-factor is unity. If the relative scale-factor is also being estimated, then the value used is multiplied by this relative scale-factor estimate (which reflects the fact that an image with a larger data range can tolerate a larger error in estimating its zero-point). The TOLS value supplied must be positive. [0.05]
If insufficient input variance information is available, or if USEVAR is set to FALSE, then weights are instead derived from the scale-factor corrections applied to each image (see the WEIGHTS parameter for details); unit weight is used if no scale-factor corrections are being applied. Alternatively, explicit weights may be given for each input image via the WEIGHTS parameter.
If you want to add estimated variances to the output image (based on the natural variations of the input images) and all your input images contain variances then you will need to set this parameter FALSE (see GENVAR).
This parameter is only used if the USEVAR parameter is set to FALSE or if one or more of the input images does not contain variance information. Otherwise, the input variance values are used to weight the input data when they are combined. [!]
If ZERO is set to TRUE, then MAKEMOS will inter-compare the images supplied as input and will estimate the relative zero-point difference between selected pairs of input data arrays where they overlap. From this information, a global set of additive corrections will be derived which make the input data as mutually consistent as possible. These corrections will be applied to the input data before they are combined into a mosaic.
Calculation of zero-point corrections may also be combined with the use of scale-factor corrections (see the SCALE parameter). By default, no zero-point corrections are applied. [FALSE]
"into a single mosaic called mymos. By default, no normalisation corrections are applied to the input data, which are combined by taking the median in regions where several input images overlap.
’out=result scale zero
"into a single mosaic called result. Optimised scale factor and zero point corrections are applied before combining the data. This would be appropriate if, for instance, the input data had been acquired using different exposure times and also had different levels of sky background.
"out=result scale zero modify
"may be given for the OUT parameter if an output mosaic is not actually required.
’result scale zero ref=b
"and the other images are normalised to it. This means that if b has previously been calibrated, then the output mosaic will inherit this calibration.
’result scale zero ref=e
"e is not one of the input images and will not form part of the output mosaic. Nevertheless, the scale factor and zero point corrections applied will be such that all the input images are normalised to it (the reference image must overlap with at least one of the input images). Thus, if e has been calibrated, this calibration will be transferred to the output mosaic (note that if MODIFY is specified, then the calibration could also be transferred to each of the input images).
"mosaic nopreserve nogenvar method=minmax skysup=0
Rather than use a conventional least-squares fit for this purpose, which would be sensitive to spurious data, a fit based on minimisation of the sum of the absolute values of the residuals is used instead. This is considerably more robust. It also allows the residuals to be defined by the perpendicular distance of each point from the fitted line, rather than the vertical distance used in conventional least squares. In turn, this removes the distinction between dependent and independent variables and allows the statistical uncertainty on both axes (described by an error ellipse) to be properly taken into account along with other weighting factors used to implement sky noise suppression.
In general, this fitting algorithm is iterative and is controlled via the MAXIT, TOLS and TOLZ parameters which specify the convergence criteria. However, in some important cases the fit can be obtained in a single pass, with consequent savings in execution time. This occurs if:
Only zero-point corrections are being determined, or
Only scale-factor corrections are being determined and no input variance information is being used to weight the inter-comparison process (see the CMPVAR parameter).
The second stage of normalisation involves a global optimisation process which seeks to determine the best corrections to be applied to each input image. The algorithm which performs this task makes a guess at the best corrections to apply and then calculates the scale-factor and/or zero-point differences which would remain between each pair of overlapping images if they were corrected in this way. These corrections are then adjusted until the weighted sum of squares of the remaining differences is minimised. The weights used in this process are derived from error estimates produced by the earlier (inter-comparison) algorithm. This allows information about the required corrections to be optimally combined from many overlaps, even in cases where individual overlaps may be small and contain inadequate information on their own.
The algorithm used for combining the separate input images into a mosaic requires no special explanation, except to note that it is designed to operate on large mosaics without making excessive demands on system resources such as memory. It does this by partitioning the mosaic into small regions for processing.
"value is the value assigned on the last run of the application. If the application has not been run then the
"defaults, as shown in the parameter help, apply. The exceptions to this rule are:
SKYSUP – dynamically defaulted
"Output from MAKEMOS
Retaining parameter values has the advantage of allowing you to define the default behaviour of the application but does mean that additional care needs to be taken when using the application on new datasets/different devices, or after a break of sometime. The intrinsic default behaviour of the application may be restored by using the RESET keyword on the command line.
Certain parameters (LOGTO, LOGFILE and PRESERVE) have global values. These global values will always take precedence, except when an assignment is made on the command line. Global values may be set and reset using the CCDSETUP and CCDCLEAR commands.
" pixel values and all non-complex data types, with arithmetic being
performed using the appropriate floating point type. It can process images with any number of
dimensions. The DATA, TITLE and VARIANCE components of an image are directly supported, with
the AXIS, HISTORY, LABEL and UNITS components and all extensions being propagated from the
first input image supplied (note that AXIS values, if present, will normally be extrapolated as a result
of propagation to the output mosaic, which will typically have a larger extent than any of the input