1
C===========================================================================
2
C Copyright (C) 1995-2008 European Southern Observatory (ESO)
4
C This program is free software; you can redistribute it and/or
5
C modify it under the terms of the GNU General Public License as
6
C published by the Free Software Foundation; either version 2 of
7
C the License, or (at your option) any later version.
9
C This program is distributed in the hope that it will be useful,
10
C but WITHOUT ANY WARRANTY; without even the implied warranty of
11
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
C GNU General Public License for more details.
14
C You should have received a copy of the GNU General Public
15
C License along with this program; if not, write to the Free
16
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
C Correspondence concerning ESO-MIDAS should be addressed as follows:
20
C Internet e-mail: midas@eso.org
21
C Postal address: European Southern Observatory
22
C Data Management Division
23
C Karl-Schwarzschild-Strasse 2
24
C D 85748 Garching bei Muenchen
26
C===========================================================================
28
C +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
C 1.0 from 1986 orig code move to ST interfaces
35
C ----------------------------------------------------------------------
37
SUBROUTINE GXMOVIT(A,B,AOFF,BOFF,NOPIX,NOLINS,AXSIZE,BXSIZE,RCUTS)
39
C copy stuff from array A to array B
42
C ................. ..............
43
C ....aaaaaaa...... .bbbbbbb......
44
C ....aaaaaaa...... ==> .bbbbbbb......
45
C ....aaaaaaa...... .bbbbbbb......
46
C ................. ..............
47
C ................. ..............
52
REAL A(*),B(*),RCUTS(2)
54
INTEGER AOFF,BOFF,NOPIX,NOLINS,AXSIZE,BXSIZE
55
INTEGER NY,NX,AAOFF,BBOFF,KOFF,LOFF,LINLIM
58
BBOFF = BOFF !we don't modify original offsets...
60
IF ((NOPIX+BOFF-1).GT.BXSIZE) THEN
61
LINLIM = BXSIZE - BOFF + 1
71
IF (B(LOFF).LT.RCUTS(1)) RCUTS(1) = B(LOFF)
72
IF (B(LOFF).GT.RCUTS(2)) RCUTS(2) = B(LOFF)
76
AAOFF = AAOFF + AXSIZE
77
BBOFF = BBOFF + BXSIZE
83
SUBROUTINE GXDOIT(A,B,C,THR,INOUT,SIZE,TRUSIZ)
87
INTEGER INOUT,SIZE,TRUSIZ
90
REAL A(SIZE),B(SIZE),C(*),THR(2)
93
IF(INOUT .EQ. 0) THEN !use .GE. for backw. compatibility
95
IF (B(N).GE.THR(1)) THEN
101
ELSE IF(INOUT .EQ. 1) THEN
103
IF ((B(N).GE.THR(1)) .AND.
104
+ (B(N).LE.THR(2))) THEN
112
IF ((B(N).LT.THR(1)) .OR.
113
+ (B(N).GT.THR(2))) THEN
124
SUBROUTINE GXIZAMAP(NPIXA,NPIXB,STARTB,STEPB,A,B,C,FLAG)
129
REAL RVAL,ENDB,DIFF,DIFF1,DIFF2
131
DOUBLE PRECISION STARTB,STEPB
133
INTEGER NPIXA(*),NPIXB(*),FLAG(*)
134
INTEGER N,KIDX,TOTAL,IOFF,NN,MCLOSE
136
TOTAL = NPIXA(1) * NPIXA(2) * NPIXA(3)
137
IF (FLAG(2).EQ.1) GOTO 3000
138
IF (FLAG(2).EQ.2) GOTO 5000
140
C -------------------------------------------------------C
142
C here for equidistant map space
144
C -------------------------------------------------------C
146
ENDB = STARTB + ((NPIXB(1) - 1) * STEPB)
147
IF (FLAG(1).EQ.1) GOTO 1000
152
IF (RVAL.LE.STARTB) THEN
154
ELSE IF (RVAL.GE.ENDB) THEN
157
KIDX = NINT((RVAL-STARTB)/STEPB) + 1
165
C here we leave all pixels with intensities outside the map coordinate space
168
1000 DO 1400 N=1,TOTAL
171
IF ( (RVAL.LT.STARTB) .OR. (RVAL.GT.ENDB) ) THEN
174
KIDX = NINT((RVAL-STARTB)/STEPB) + 1
181
C -------------------------------------------------------C
183
C here we have the coordinates stored in the 1. line of the map frame,
184
C intensities follow in the 2. line
186
C -------------------------------------------------------C
191
IF (FLAG(1).EQ.1) GOTO 4000
196
IF (RVAL.LE.STARTB) THEN
198
ELSE IF (RVAL.GE.ENDB) THEN
202
DIFF1 = ABS(RVAL-STARTB)
204
DO 3200 NN=2,IOFF !find closest coordinate
205
DIFF = ABS(RVAL-B(NN))
206
IF (DIFF.LT.DIFF1) THEN
221
C here we leave all pixels with intensities outside the map coordinate space
224
4000 DO 4500 N=1,TOTAL
227
IF ( (RVAL.LT.STARTB) .OR. (RVAL.GT.ENDB) ) THEN
232
DIFF1 = ABS(RVAL-STARTB)
234
DO 4200 NN=2,IOFF !find closest coordinate
235
DIFF = ABS(RVAL-B(NN))
236
IF (DIFF.LT.DIFF1) THEN
251
C -------------------------------------------------------C
253
C here we have the intervals stored in the 1. line of the map frame,
254
C intensities follow in the 2. line (for start,end - in between interpolation ...)
256
C -------------------------------------------------------C
261
IF (FLAG(1).EQ.1) GOTO 6000
266
IF (RVAL.LT.STARTB) THEN
268
ELSE IF (RVAL.GT.ENDB) THEN
272
DO 5200 NN=1,IOFF,2 !find enclosing interval
273
IF (RVAL.LE.B(NN+1)) THEN
276
ELSE IF (RVAL.LT.B(NN+2)) THEN
278
GOTO 5555 !no interval there ...!
282
5333 DIFF = B(KIDX+1) - B(KIDX)
283
DIFF1 = (RVAL - B(KIDX)) / DIFF
284
DIFF2 = (B(KIDX+1) - RVAL) / DIFF
285
KIDX = KIDX + IOFF !point to data line
286
C(N) = ( B(KIDX+1) * DIFF1 ) + ( B(KIDX) * DIFF2 )
291
C here we leave all pixels with intensities outside the map coordinate space
294
6000 DO 6555 N=1,TOTAL
297
IF (RVAL.LT.STARTB) THEN
300
ELSE IF (RVAL.GT.ENDB) THEN
305
DO 6200 NN=1,IOFF,2 !find enclosing interval
306
IF (RVAL.LE.B(NN+1)) THEN
309
ELSE IF (RVAL.LT.B(NN+2)) THEN
311
GOTO 6555 !no interval there ...!
315
6333 DIFF = B(KIDX+1) - B(KIDX)
316
DIFF1 = (RVAL - B(KIDX)) / DIFF
317
DIFF2 = (B(KIDX+1) - RVAL) / DIFF
318
KIDX = KIDX + IOFF !point to data line
319
C(N) = ( B(KIDX+1) * DIFF1 ) + ( B(KIDX) * DIFF2 )
325
SUBROUTINE GXMATRX(A,NPIX,C)
327
C +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
329
C straight forward transposition of an image (seen as a matrix)
330
C this however implies, that the first element is in the upper left corner
331
C since matrices are usually written like that ...
333
C -------------------------------------------------------------------
339
INTEGER XDIM,YDIM,OFFA,OFFC,WORK
347
WORK = XDIM * (YDIM-1)
349
C loop through rows in output matrix
353
DO 400 NY=1,YDIM !loop till middle of row
354
C(NY+OFFC) = A(NX+OFFA)