1
C @(#)maktab.for 19.1 (ES0-DMD) 02/25/03 14:29:42
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------------------------------------------------------------------------------
31
C Makes input table in proper format for DBLEND when working with combined
35
C fit option W, input table BTAB with center positions in column :X, input
36
C table ttemp with other info in normal form.
37
C fit option S, FWHM value to use in BTAB, input table ttemp with other info
39
C fit option A, centers in input table ttemp, FWHM's in keyword FWHM(6)
42
C table ttemp with all info in proper form for DBLEND
43
C------------------------------------------------------------------------------
45
C variable declarations
68
INTEGER NCOLD,NROWD,NCOLB,NROWB,NROWT
78
DOUBLE PRECISION START(2),STEP(2)
92
C connect to MIDAS environment
96
C get inputs from keywords
98
call stkrdc('BTAB',1,1,12,ACTVAL,INTAB,KUN,KNUL,STAT)
99
call stkrdc('FITOPT',1,1,1,ACTVAL,FOPT,KUN,KNUL,STAT)
100
call stkrdc('IN_A',1,1,60,ACTVAL,IMAGE,KUN,KNUL,STAT)
102
call upcas(FOPT,FOPT)
104
C rename ttemp to dummy name
106
call stfrnm('ttemp.tbl','ttemp2.tbl',STAT)
108
C read in values to be saved
110
call tbtopn('ttemp2.tbl',2,DTID,STAT)
111
call tbiget(DTID,NCOLD,NROWD,NSC,ACOL,AROW,STAT)
114
call tbrrdr(DTID,II,4,COL,PAR,NULL,STAT)
116
TDATA(II,JJ) = PAR(JJ)
122
call tbtclo(DTID,STAT)
126
call stiget(IMAGE,10,0,1,2,NAXIS,NPIX,START,STEP,
127
& IDENT,CUNIT,PNTR,NO,STAT)
129
C for option W, open table with center positions and read them in
131
if (FOPT.EQ.'W') then
133
call tbtopn(INTAB,0,BTID,STAT)
134
call tbiget(BTID,NCOLB,NROWB,NSC,ACOL,AROW,STAT)
135
call tblser(BTID,'X',XCOL,STAT) !could be ':X' instead
138
call tberdr(BTID,II,XCOL,CENT(II),NULL,STAT)
145
call read1d(MADRID(PNTR),NPIX(1),DATA)
146
else if (NAXIS.eq.2.and.(NPIX(1).eq.1.or.NPIX(2).eq.1)) then
147
if (NPIX(1).eq.1) then
154
call read2d(MADRID(PNTR),NPIX,DATA,NDATA)
156
STRING = ' Input image is not a suitable type'
157
call sttput(STRING,STAT)
161
C determine pixel positions of centers
164
CPIX(II)=nint((CENT(II)-real(START(1)))/real(STEP(1)))+1
167
C get data values at centers
170
MAXVAL(II) = DATA(CPIX(II))
173
C construct new table rows
176
BDATA(II,1) = CENT(II)
177
BDATA(II,2) = MAXVAL(II)
178
BDATA(II,3) = float(CPIX(II))
184
NROWT = NROWD + NROWB
189
TABLE(II,JJ) = TDATA(II,JJ)
195
if (mod(II,3).eq.0) then
196
TABLE(II,JJ) = BDATA((II/3)-1,JJ)
199
TABLE(II,JJ) = TDATA(KK,JJ)
204
C for option S, interpret number in INTAB
206
else if (FOPT.eq.'S') then
208
read (INTAB,*) FWHM(1) !test this
210
C construct new table rows
215
SIDE(1) = TDATA(II,1) - (FWHM(1)/2)
216
SIDE(2) = SIDE(1) + FWHM(1)
217
YVAL = TDATA(II,2) / 2
220
BDATA(NROWB,1) = SIDE(JJ)
221
BDATA(NROWB,2) = YVAL
222
BDATA(NROWB,3) = anint((SIDE(JJ)-real(START(1)))
228
C construct new table
230
NROWT = NROWD + NROWB
235
TABLE(II,JJ) = TDATA(II,JJ)
242
if (mod(II,3).eq.0) then
244
TABLE(II,JJ) = TDATA(KK,JJ)
247
TABLE(II,JJ) = BDATA(MM,JJ)
252
C for option A, get FWHM from keyword
254
else if (FOPT.eq.'A') then
256
call stkrdr('FWHM',1,6,ACTVAL,FWHM,KUN,KNUL,STAT)
258
C construct new table rows
263
SIDE(1) = TDATA(II,1) - (FWHM(II-4)/2)
264
SIDE(2) = SIDE(1) + FWHM(II-4)
265
YVAL = TDATA(II,2) / 2
268
BDATA(NROWB,1) = SIDE(JJ)
269
BDATA(NROWB,2) = YVAL
270
BDATA(NROWB,3) = anint((SIDE(JJ)-real(START(1)))
276
C construct new table
278
NROWT = NROWD + NROWB
283
TABLE(II,JJ) = TDATA(II,JJ)
290
if (mod(II,3).eq.0) then
292
TABLE(II,JJ) = TDATA(KK,JJ)
295
TABLE(II,JJ) = BDATA(MM,JJ)
300
C invalid fit option used:
305
C write out error message
307
STRING = 'fit option '// FOPT //
308
+ ' incompatible with B input option'
309
call sttput(STRING,STAT)
311
C deposit status parameter in keyword
314
call stkwri('STATUS',PAR(1),1,1,KUN,STAT) !takes KNUL par also?
316
C put ttemp back where it was and exit
318
call stfrnm('ttemp2.tbl','ttemp.tbl',STAT)
324
C write the table out
326
call tbtini('ttemp',1,1,4,NROWT,TID,STAT)
327
call tbcini(TID,10,1,'G13.6',CUNIT,'X_AXIS',NN,STAT)
328
call tbcini(TID,10,1,'G13.6','COUNTS','Y_AXIS',NN,STAT)
329
call tbcini(TID,10,1,'I5','PIXEL','LINE_NO',NN,STAT)
330
call tbcini(TID,10,1,'I5','PIXEL','PIXEL_NO',NN,STAT)
334
PAR(JJ) = TABLE(II,JJ)
336
call tbrwrr(TID,II,4,COL,PAR,STAT)
339
call tbtclo(TID,STAT)
343
call STFDEL('ttemp2.tbl',STAT)