If status is good on entry, the routine will set default return values to VAL__BADR except QUALITY set to 0. As progress is made through the routine the various image quantities will be set to their derived values, and QUALITY will be set to 1 if any problem is encountered.
An attempt will then be made to estimate the 0 level of the image by averaging valid data points in the corners of the map area. If there are any such points then the 0 level will be subtracted from the map.
Next the routine will calculate the 0th and 1st order moments of the image on the map. Map pixels with bad quality are ignored.
The 0th order is calculated as
![]() |
(14) |
![]() |
(15) |
![]() |
(16) |
If the 0th order moment of the image was 0, i.e. there is no image on the map, then a warning message will be output and the routine will return with good status and QUALITY set to 1. Otherwise, the x,y centre of the image is calculated from:-
![]() |
(17) |
![]() |
(18) |
With this information the image can be analysed further by one of 2 methods. The method used depends on the value of parameter FLAT_ANALYSIS. If there is an error reading this parameter, or its value is not either MOMENTS or FIT, then a warning message will be issued and a value of MOMENTS will be assumed.
For a MOMENTS analysis the 2nd order moments can be calculated about the centre of the image:-
![]() |
(19) |
![]() |
(20) |
![]() |
(21) |
The parameters of the weighted ellipse describing the data are then (following `Analysis of Astronomical Images using Moments', R.Stobie, J.B.I.S., 33, 323):-
![]() |
(22) |
| (23) |
| (24) |
For a FIT analysis, a 2-d Gaussian is fitted by a least-squares routine to the data. SCULIB_FIT_ROUTINE is the routine that performs the fit while SCULIB_GAUSSIAN_XISQ calculates the chi-squared of the fit to the data. An error will be reported and QUALITY set to 1 if there are any problems with the fit process. The fitted function is :-
![]() |
(25) |
where SIGMA (
) is an ellipse with semi-axis lengths A and B, with
THETA (
)
the angle between the x axis and A (THETA in radians, measured
anti-clockwise).
If all is well still, the volume under the image and the variance on it are calculated. The volume will be the sum of all map pixels under a circle of 12 arcsec radius for short-wave array bolometers, or 25 arcsec for other types. If this area laps over the edges of the map, or any pixels inside it have bad quality then a warning message will be output but QUALITY will stay good.
SURF Programming Interface