1
C @(#)astrm.for 19.1 (ES0-DMD) 02/25/03 13:30:45
2
C===========================================================================
3
C Copyright (C) 1995 European Southern Observatory (ESO)
5
C This program is free software; you can redistribute it and/or
6
C modify it under the terms of the GNU General Public License as
7
C published by the Free Software Foundation; either version 2 of
8
C the License, or (at your option) any later version.
10
C This program is distributed in the hope that it will be useful,
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
C GNU General Public License for more details.
15
C You should have received a copy of the GNU General Public
16
C License along with this program; if not, write to the Free
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
21
C Internet e-mail: midas@eso.org
22
C Postal address: European Southern Observatory
23
C Data Management Division
24
C Karl-Schwarzschild-Strasse 2
25
C D 85748 Garching bei Muenchen
27
C===========================================================================
29
C +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
C.COPYRIGHT: Copyright (c) 1987 European Southern Observatory,
32
C.IDENTIFICATION: ASTRM
33
C.PURPOSE: Routine for main program star written by P.B.Stetson
34
C performs the gaussian astrometric fitting
35
C.LANGUAGE: F77+ESOext
37
C.ALGORITHM: see Stetson, P.B., 1979 Astron. J. 84 1149
38
C.INPUT/OUTPUT: -> KRX input array
39
C -> JX low side local minimun
40
C -> LX high side local minimum
41
C <-> XI input/ouput estimates of the image centre
42
C <- S1 error estimate of the output image centre
43
C 0. fitting procedure failed or if
44
C KOUNT .NE. 0 then KOUNT too small
45
C <-> SX input/output estimate of the image width
46
C <- DO output estimate of the image height
47
C <- B output estimate of the background marginal iensity.
48
C <-> KOUNT number of iterations required/ status
49
C 0 fitting procedure failed
50
C.COMMENTS: If the solution fails to converge, XI will come back with
51
C the input value.... with S1 = 0. just in case you want to try
52
C doing the photometry with the estimated centre from SERCH.
53
C.KEYWORDS : photometry,astrometry
54
C.VERSION: 8212?? P. Stetsan
55
C.VERSION: 871123 R.H. Warmels ESO Fortran Conversion
56
C.VERSION: ?????? H. Waldhausen Vax implementation
57
C ---------------------------------------------------------------------
58
SUBROUTINE ASTRM(KRX,JX,LX,XI,S1,SX,DO,B,KOUNT)
61
DOUBLE PRECISION KRX(1)
81
DOUBLE PRECISION CTF(5)
82
DOUBLE PRECISION CTC(5,5)
88
C.. this part of the program uses the estimates of the image centre
89
C.. and width from SERCH to derive initial estimates of the image
90
C.. height and background density by linear least-squares.
92
IF ((LX-JX).GT.4) THEN
105
EX = EXP(-DX*DX*SXSI)
113
DO = (DO-S1*S2/F)/ (B-S2*S2/F)
115
IF (DO.LT.20.0) D = 20.0
116
IF (SX.LT.2.0) SX = 2.0
119
C.. main iteration loop
120
DO 90 KNT = 1,KOUNT ! iteration loop
132
C.. set normal equations
133
DO 60 L = JX,LX ! equation loop
147
CTF(I) = CTF(I) + F*C(I)
148
CTC(I,4) = CTC(I,4) + C(I)
150
CTC(I,J) = CTC(I,J) + C(I)*C(J)
153
CTF(4) = CTF(4) + F ! equation loop
156
CTC(4,4) = FLOAT(LX-JX+1)
164
C.. solve normal equations
166
CALL VMUL(CTC,4,CTF,V)
168
C.. if DA is the correction to the estimate of A, then replace DA by
169
C.. DA/(1+(DA/X)) = DA' prevents an ill-determined solution from
170
C.. jumping around too much in subsequent iterations. DA' is less
171
C.. than X, and DA' goes to DA for DA much less than X.
172
C.. If X = A/R for some R greater than one, then an intrinsically
173
C.. positive parameter will never be permitted to pass through zero.
174
C.. This can be helpful for parameters like image width or height.
176
XO = XO - V(1)/ (1.0+DABS(V(1)/5.0))
177
DO = DO - V(2)/ (1.0+2.0*DABS(V(2)/DO))
178
SX = SX - V(3)/ (1.0+2.0*DABS(V(3)/SX))
179
B = B - V(4)/ (1.0+2.0*DABS(V(4)/B))
182
IF ((DO.LT.20.0) .OR. (SX.LT.1.0) .OR.
183
+ (SX.GT.0.5*DELX)) THEN
190
IF ((DABS(V(1)).LT.0.01) .AND.
191
+ ((FOLD-FF)/FOLD.LT.0.05)) THEN
193
S1 = S1*CTC(1,1)*DELX/ (S2* (DELX-4.0))
198
90 CONTINUE ! iteration loop
200
C.. number of iterations too small