1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
include <error.h>
include "../lib/apphot.h"
# AP_APCOLON -- Process colon commands for setting the top level apphot package
# parameters.
procedure ap_apcolon (ap, im, cl, out, stid, ltid, cmdstr, newimage,
newcenterbuf, newcenter, newskybuf, newsky, newbuf, newfit)
pointer ap # pointer to the apphot structure
pointer im # pointer to the iraf image
int cl # coordinate file descriptor
int out # output file descriptor
int stid # output file sequence number
int ltid # coordinate file sequence number
char cmdstr[ARB] # command string
int newimage # new image ?
int newcenterbuf, newcenter # new centering parameters ?
int newskybuf, newsky # new sky fitting parameters ?
int newbuf, newfit # new photometry parameters ?
bool bval
int ncmd, ip
pointer sp, cmd, str
real rval
bool streq(), itob()
int strdic(), nscan(), btoi(), apstati(), ctowrd(), open()
pointer immap()
real apstatr()
errchk immmap, open
begin
# Allocate working space.
call smark (sp)
call salloc (cmd, SZ_LINE, TY_CHAR)
call salloc (str, SZ_LINE, TY_CHAR)
# Get the command.
ip = 1
call sscan (cmdstr)
call gargwrd (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call sfree (sp)
return
}
# Process the command.
ncmd = strdic (Memc[cmd], Memc[cmd], SZ_LINE, APCMDS)
switch (ncmd) {
case APCMD_FWHMPSF:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_FWHMPSF)
call pargr (apstatr (ap, FWHMPSF))
call pargstr (UN_ASCALEUNIT)
} else {
call apsetr (ap, FWHMPSF, rval)
if (stid > 1)
call ap_rparam (out, KY_FWHMPSF, rval, UN_ASCALEUNIT,
"full width half max of psf")
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
case APCMD_SCALE:
call gargr (rval)
if (nscan () == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_SCALE)
call pargr (1.0 / apstatr (ap, SCALE))
call pargstr (UN_AUNITS)
} else if (rval > 0.0) {
call apsetr (ap, SCALE, (1.0 / rval))
if (stid > 1)
call ap_rparam (out, KY_SCALE, (1.0 / rval), UN_AUNITS,
"scale in units / pixel")
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
case APCMD_EMISSION:
call gargb (bval)
if (nscan() == 1) {
call printf ("%s = %b\n")
call pargstr (KY_POSITIVE)
call pargb (itob (apstati (ap, POSITIVE)))
} else {
call apseti (ap, POSITIVE, btoi (bval))
if (stid > 1)
call ap_bparam (out, KY_POSITIVE, bval, UN_ASWITCH,
"emission feature")
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
case APCMD_FILTER:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, FILTER, Memc[str], SZ_LINE)
call printf ("%s = %s\n")
call pargstr (KY_FILTER)
call pargstr (Memc[str])
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, FILTER, Memc[str])
if (im != NULL)
call ap_filter (im, ap)
if (stid > 1)
call ap_sparam (out, KY_FILTER, Memc[str], UN_AKEYWORD,
"filter keyword")
}
case APCMD_FILTERID:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, FILTERID, Memc[str], SZ_LINE)
call printf ("%s = %s\n")
call pargstr (KY_FILTERID)
call pargstr (Memc[str])
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, FILTERID, Memc[str])
}
case APCMD_OBSTIME:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, OBSTIME, Memc[str], SZ_LINE)
call printf ("%s = %s\n")
call pargstr (KY_OBSTIME)
call pargstr (Memc[str])
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, OBSTIME, Memc[str])
if (im != NULL)
call ap_otime (im, ap)
if (stid > 1)
call ap_sparam (out, KY_OBSTIME, Memc[str], UN_AKEYWORD,
"obstime keyword")
}
case APCMD_OTIME:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, OTIME, Memc[str], SZ_LINE)
call printf ("%s = %s %s\n")
call pargstr (KY_OTIME)
call pargstr (Memc[str])
call pargstr (UN_ATIMEUNIT)
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, OTIME, Memc[str])
}
case APCMD_AIRMASS:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, AIRMASS, Memc[str], SZ_LINE)
call printf ("%s = %s\n")
call pargstr (KY_AIRMASS)
call pargstr (Memc[str])
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, AIRMASS, Memc[str])
if (im != NULL)
call ap_airmass (im, ap)
if (stid > 1)
call ap_sparam (out, KY_AIRMASS, Memc[str], UN_AKEYWORD,
"airmass keyword")
}
case APCMD_XAIRMASS:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_XAIRMASS)
call pargr (apstatr (ap, XAIRMASS))
call pargstr (UN_ANUMBER)
} else {
call apsetr (ap, XAIRMASS, rval)
#if (stid > 1)
#call ap_rparam (out, KY_XAIRMASS, rval, UN_ANUMBER,
#"airmass")
}
case APCMD_EXPOSURE:
call gargstr (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, EXPOSURE, Memc[str], SZ_LINE)
call printf ("%s = %s\n")
call pargstr (KY_EXPOSURE)
call pargstr (Memc[str])
} else {
if (ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE) <= 0)
Memc[str] = EOS
call apsets (ap, EXPOSURE, Memc[str])
if (im != NULL)
call ap_itime (im, ap)
if (stid > 1)
call ap_sparam (out, KY_EXPOSURE, Memc[str], UN_AKEYWORD,
"exposure time keyword")
newfit = YES
}
case APCMD_ITIME:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_ITIME)
call pargr (apstatr (ap, ITIME))
call pargstr (UN_ATIMEUNIT)
} else {
call apsetr (ap, ITIME, rval)
#if (stid > 1)
#call ap_rparam (out, KY_ITIME, rval, UN_ATIMEUNIT,
#"exposure time")
newfit = YES
}
case APCMD_DATAMIN:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_DATAMIN)
call pargr (apstatr (ap, DATAMIN))
call pargstr (UN_ACOUNTS)
} else {
call apsetr (ap, DATAMIN, rval)
if (stid > 1)
call ap_rparam (out, KY_DATAMIN, rval, UN_ACOUNTS,
"minimim good data value")
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
case APCMD_DATAMAX:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_DATAMAX)
call pargr (apstatr (ap, DATAMAX))
call pargstr (UN_ACOUNTS)
} else {
call apsetr (ap, DATAMAX, rval)
if (stid > 1)
call ap_rparam (out, KY_DATAMAX, rval, UN_ACOUNTS,
"maximum good data value")
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
case APCMD_IMAGE:
call gargwrd (Memc[cmd], SZ_LINE)
call apstats (ap, IMNAME, Memc[str], SZ_FNAME)
if (Memc[cmd] == EOS || streq (memc[cmd], Memc[str])) {
call printf ("%s: %s\n")
call pargstr (KY_IMNAME)
call pargstr (Memc[str])
} else {
if (im != NULL) {
call imunmap (im)
im = NULL
}
iferr {
im = immap (Memc[cmd], READ_ONLY, 0)
} then {
call erract (EA_WARN)
im = immap (Memc[str], READ_ONLY, 0)
} else {
call apimkeys (ap, im, Memc[cmd])
newimage = YES
newcenterbuf = YES; newcenter = YES
newskybuf = YES; newsky = YES
newbuf = YES; newfit = YES
}
}
case APCMD_COORDS:
call gargwrd (Memc[cmd], SZ_LINE)
call apstats (ap, CLNAME, Memc[str], SZ_FNAME)
if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
call printf ("%s: %s\n")
call pargstr (KY_CLNAME)
call pargstr (Memc[str])
} else {
if (cl != NULL) {
call close( cl)
cl = NULL
}
iferr {
cl = open (Memc[cmd], READ_ONLY, TEXT_FILE)
} then {
cl = NULL
call erract (EA_WARN)
call apsets (ap, CLNAME, "")
call apsets (ap, CLROOT, "")
call printf ("Coordinate file is undefined.\n")
} else {
call apsets (ap, CLNAME, Memc[cmd])
call apfroot (Memc[cmd], Memc[str], SZ_FNAME)
call apsets (ap, CLROOT, Memc[str])
ltid = 0
}
}
case APCMD_OUTPUT:
call gargwrd (Memc[cmd], SZ_LINE)
call apstats (ap, OUTNAME, Memc[str], SZ_FNAME)
if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
call printf ("%s: %s\n")
call pargstr (KY_OUTNAME)
call pargstr (Memc[str])
} else {
if (out != NULL) {
call close (out)
out = NULL
if (stid <= 1)
call delete (Memc[str])
}
iferr {
out = open (Memc[cmd], NEW_FILE, TEXT_FILE)
} then {
call erract (EA_WARN)
call printf ("Reopening output file: %s\n")
call pargstr (Memc[str])
if (Memc[str] != EOS)
out = open (Memc[str], APPEND, TEXT_FILE)
else
out = NULL
} else {
call apsets (ap, OUTNAME, Memc[cmd])
stid = 1
}
}
default:
call printf ("Unknown or ambiguous colon command\7\n")
}
call sfree (sp)
end
|