Function: SKYFIT Purpose: SKYFIT is a routine for determining the sky-projection parameters. It takes a set of grid positions and a set of sky coordinates to fit the parameters. The method is a mixture of the steepest descent method and the Taylor method. Category: MATH File: skyfit.c Author: K.G. Begeman Use: INTEGER SKYFIT( X , Input DOUBLE PRECISION ARRAY Y , Input DOUBLE PRECISION ARRAY A , Input DOUBLE PRECISION ARRAY D , Input DOUBLE PRECISION ARRAY N , Input INTEGER XF , Output DOUBLE PRECISION ARRAY YF , Output DOUBLE PRECISION ARRAY FPAR , In/Output DOUBLE PRECISION ARRAY EPAR , Output DOUBLE PRECISION ARRAY MPAR , Input INTEGER ARRAY TOL , Input REAL ITS , Input INTEGER LAB , Input REAL PROJ ) Input INTEGER SKYFIT Returns number of iterations needed to achieve convergence according to TOL. When this number is negative, the fitting was not continued because a fatal error occurred: -1 Unknown projection. -2 No free parameters. -3 Not enough degrees of freedom. -4 Maximum number of iterations too small to obtain a solution which satisfies TOL. -5 Diagonal of matrix contains elements which are zero. -6 Determinant of the coefficient matrix is zero. -7 Square root of negative number. X Contains x grid coordinates. Y Contains y grid coordinates. XF Contains fitted x grid coordinates. YF Contains fitted x grid coordinates. A Contains longitude coordinates. D Contains latitude coordinates. N Number of positions. FPAR On input contains initial estimates of the parameters, on output the fitted parameters. There are seven parameters, so the dimension of FPAR (and EPAR and MPAR) must be seven. The order of the parameters is the following: 1: longitude projection centre 2: latitude projection centre 3: rotation angle 4: grid size x grid 5: grid size y grid 6: reference x grid position 7: reference y grid position EPAR Contains estimates of errors in fitted parameters. MPAR Logical mask telling which parameters are free (MPAR(J)=non-zero) and which parameters are fixed (MPAR(J)=0). TOL Relative tolerance. LSQFIT stops when successive iterations fail to produce a decrement in reduced chi-squared less than TOL. If TOL is less than the minimum tolerance possible, TOL will be set to this value. This means that maximum accuracy can be obtained by setting TOL=0.0. ITS Maximum number of iterations. LAB Mixing parameter, LAB determines the initial weight of steepest descent method relative to the Taylor method. LAB should be a small value (i.e. 0.01). PROJ Projection type. 2: Cylindrical projection. 3: Flat projection. 4: Gnomonic projection. 5: Orthographic projection. 6: Rectangular projection. 7: Global Sinusoidal projection. 8: North Celestial Pole projection. 9: Stereographic projection. Updates: Jul 6, 1991: KGB, Document created. Aug 23, 1993: VOG, Output of fitted grid coordinates.