1
C @(#)twodim.for 19.1 (ES0-DMD) 02/25/03 13:25:40
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===========================================================================
30
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34
C-----------------------------------------------------------------------
35
SUBROUTINE TWODIM(AS, MAS, JAPYS, IBUFS, LZ,
36
& APSF, FPSF, IPSF, NCAT, PMTR,
37
& PRCT, NCT, PMT, PRC, IARR,
41
INCLUDE 'MID_REL_INCL:INVENT.INC/NOLIST'
44
INTEGER MAS((-MAXSUB):MAXSUB,(-MAXSUB):MAXSUB)
51
INTEGER NCAT(NIPAR,MAXCNT)
52
REAL PMTR(NRPAR,MAXCNT)
53
REAL PRCT(0:MAXSUB,MAXCNT)
69
INTEGER IOFF, IOFF1, IOFF0, IOFFI, IOFF2, IOFFC
92
REAL SIGM, SHLM, SIGM1
95
DOUBLE PRECISION AR(25) , X(5) , S(5)
96
LOGICAL CENTER , COMP , LAST , STAR
105
IF ( NCAT(10,LZ) .GT. 0 ) THEN
110
IF ( KSAT .EQ. -1 .AND. ABS(PMTR(3,LZ)) .LT. RARR(5) ) THEN
122
C *** Determine scaling parameter SCA for object and SCC for component.
124
CALL SCLDET( LZ, NCAT , PMTR , PRCT , NCT ,
125
& PMT , PRC , APSF , NPAS , SCA ,
127
IF ( SCA .LE. 5.0*RARR(3) ) THEN
131
C *** Save starting object coordinates.
142
IS = 0 ! addition for initialization
143
JS = 0 ! addition for initialization
154
IF ( IC .GT. 6 ) GOTO 11
156
IF ( IC .EQ. 1 ) THEN
159
SHLM = MIN( 0.6 , 1.0 / FLOAT(MSBP) )
162
C *** Identify object coordinates and subpixel.
164
CALL SUBPXL( NCAT(1,LZ) , PMTR(1,LZ) , LSBP , IACT , JACT ,
168
IF ( IC .EQ. 6 .OR. ( IC .GT. 1 .AND. I0 .EQ. I0OLD .AND.
169
& J0 .EQ. J0OLD .AND. IS .EQ. ISOLD .AND.
170
& JS .EQ. JSOLD .AND. NPX .EQ. NPXOLD ) ) THEN
176
C *** Check component's distance.
179
XDF = PMT(10) - FLOAT(NCAT(1,LZ))
180
YDF = PMT(11) - FLOAT(NCAT(2,LZ))
181
IDF = NCT(1) - NCAT(1,LZ)
182
JDF = NCT(2) - NCAT(2,LZ)
183
IF ( ABS(IDF) .LE. LPXL .AND. ABS(JDF) .LE. LPXL ) THEN
186
C *** Identify component's subpixel.
188
CALL SUBPXL( NCT , PMT , LSBP , ICM , JCM ,
197
C *** IOFF0 - adress of psf for central pixel at given IS and JS.
199
IOFF0 = ( (LSBP+JS) * MSBP + LSBP + IS ) * MPXL2 +
200
& LPXL * ( MPXL + 1 ) + 1
202
C *** IOFFC - difference of adress of central
203
C *** pixel at ISC and JSC minus IOFF0.
206
IOFFC = ( (JSC-JS) * MSBP + ISC - IS ) * MPXL2
209
C *** IOFF1 and IOFF2 - corresponding adresses of x and y gradients.
214
C *** Check if this object can serve as standard star.
216
LPLIM = INT( FLOAT(LPXL) * SQRT(2.0) )
217
IF ( STAR .AND. LAST .AND. KCLN .GT. LPLIM
218
& .AND. NNOR .EQ. 4 ) THEN
219
IF ( SIGM1 .GT. 0.0 ) THEN
224
CALL IFSTAR( IBUFS , SCAA , LPXL , LSBP , IS ,
225
& JS , MPRF , IPSF , FPSF , IOFF0 ,
226
& IOFF , STAR , IOFFI )
230
C *** Calculate normal equations.
232
CALL NRMLEQ( AS , MAS , JAPYS , IBUFS , LPXL ,
233
& APSF , FPSF , IOFF0 , IOFF1 , IOFF2 ,
234
& IOFFI , BGRD , I0 , J0 , SCA ,
235
& COMP , SCC , CENTER , IDF , JDF ,
236
& XDF , YDF , IOFFC , IC , SIGM ,
239
C *** Solve normal equations if there is enough of good points.
246
IF ( NPX .GT. NNOR .AND. ( .NOT. LAST ) ) THEN
247
CALL LSQSOL ( NNOR , AR , NPX , X , S )
249
SCA = SCA + SNGL(X(1))
252
C *** Save sigma from the first, non trimmed
253
C *** determination of object intensity.
255
IF ( IC .EQ. 1 ) THEN
258
IF ( ABS(CORX) .GT. SHLM ) THEN
259
CORX = SHLM * CORX / ABS(CORX)
261
PMTR(10,LZ) = FLOAT(NCAT(1,LZ)) +
262
& FLOAT(IS) / FLOAT(MSBP) - CORX
263
PMTR(22,LZ) = SNGL(S(2))
264
NCAT(1,LZ) = NINT(PMTR(10,LZ))
266
IF ( ABS(CORY) .GT. SHLM ) THEN
267
CORY = SHLM * CORY / ABS(CORY)
269
PMTR(11,LZ) = FLOAT(NCAT(2,LZ)) +
270
& FLOAT(JS) / FLOAT(MSBP) - CORY
271
PMTR(23,LZ) = SNGL(S(3))
272
NCAT(2,LZ) = NINT(PMTR(11,LZ))
274
SCC = SCC + SNGL(X(4))
287
C *** Apply corrections.
289
IF ( NPXOLD .GT. NNOR ) THEN
291
IF ( SCA .GT. 0.0 ) THEN
292
PMTR(24,LZ) = 1.086 * SNGL(S(1)) / SCA
297
IF ( NCAT(10,LZ) .GT. 0 ) THEN
298
PMT(2) = SCC / ( 9.0 / ( 1.0 + 8.0 * APSF(1) ) )
304
SIGMA = SNGL(S(NNOR))