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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
include "../lib/apphot.h"
include "../lib/noise.h"
include "../lib/fitsky.h"
include "../lib/display.h"
# APSKYCOLON -- Procedure to process the fitsky colon commands.
procedure apskycolon (ap, im, cl, out, stid, ltid, cmdstr, newimage,
newskybuf, newsky)
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 # coord list sequence number
char cmdstr[ARB] # command string
int newimage # new image ?
int newskybuf # new sky buffer ?
int newsky # new sky fit ?
int junk
pointer sp, incmd, outcmd
int strdic()
begin
# Get the command.
call smark (sp)
call salloc (incmd, SZ_LINE, TY_CHAR)
call salloc (outcmd, SZ_LINE, TY_CHAR)
call sscan (cmdstr)
call gargwrd (Memc[incmd], SZ_LINE)
if (Memc[incmd] == EOS) {
call sfree (sp)
return
}
# Process the command.
if (strdic (Memc[incmd], Memc[outcmd], SZ_LINE, SCMDS) != 0)
call apscolon (ap, out, stid, cmdstr, newskybuf, newsky)
else if (strdic (Memc[incmd], Memc[outcmd], SZ_LINE, APCMDS) != 0)
call ap_apcolon (ap, im, cl, out, stid, ltid, cmdstr,
newimage, junk, junk, newskybuf, newsky, junk, junk)
else if (strdic (Memc[incmd], Memc[outcmd], SZ_LINE, NCMDS) != 0)
call apnscolon (ap, im, out, stid, cmdstr, junk, junk,
newskybuf, newsky, junk, junk)
else
call ap_simcolon (ap, cmdstr)
call sfree (sp)
end
# APSCOLON -- Procedure to examine and edit the sky fitting parameters.
procedure apscolon (ap, out, stid, cmdstr, newbuf, newfit)
pointer ap # pointer to the apphot structure
int out # output file descriptor
int stid # output file number
char cmdstr # command string
int newbuf # new sky buffer
int newfit # new sky fit
bool bval
int ncmd, ival, stat
pointer sp, cmd
real rval
bool itob()
int nscan(), strdic(), btoi(), apstati()
real apstatr()
begin
# Get the command
call smark (sp)
call salloc (cmd, SZ_LINE, TY_CHAR)
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, SCMDS)
switch (ncmd) {
case SCMD_ANNULUS:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_ANNULUS)
call pargr (apstatr (ap, ANNULUS))
call pargstr (UN_SSCALEUNIT)
} else {
call apsetr (ap, ANNULUS, rval)
if (stid > 1)
call ap_rparam (out, KY_ANNULUS, rval, UN_SSCALEUNIT,
"inner radius of sky annulus")
newbuf = YES
newfit = YES
}
case SCMD_DANNULUS:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_DANNULUS)
call pargr (apstatr (ap, DANNULUS))
call pargstr (UN_SSCALEUNIT)
} else {
call apsetr (ap, DANNULUS, rval)
if (stid > 1)
call ap_rparam (out, KY_DANNULUS, rval, UN_SSCALEUNIT,
"width of the sky annulus")
newbuf = YES
newfit = YES
}
case SCMD_SALGORITHM:
call gargwrd (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call apstats (ap, SSTRING, Memc[cmd], SZ_FNAME)
call printf ("%s = %s\n")
call pargstr (KY_SSTRING)
call pargstr (Memc[cmd])
} else {
stat = strdic (Memc[cmd], Memc[cmd], SZ_LINE, SFUNCS)
if (stat > 0) {
call apseti (ap, SKYFUNCTION, stat)
call apsets (ap, SSTRING, Memc[cmd])
if (stid > 1)
call ap_sparam (out, KY_SSTRING, Memc[cmd],
UN_SALGORITHM, "sky fitting algorithm")
newfit = YES
}
}
case SCMD_KHIST:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_K1)
call pargr (apstatr (ap, K1))
call pargstr (UN_SSIGMA)
} else {
call apsetr (ap, K1, rval)
if (stid > 1)
call ap_rparam (out, KY_K1, rval, UN_SSIGMA,
"half width of sky histogram")
newfit = YES
}
case SCMD_SLOREJECT:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_SLOREJECT)
call pargr (apstatr (ap, SLOREJECT))
call pargstr (UN_SSIGMA)
} else {
call apsetr (ap, SLOREJECT, rval)
if (stid > 1)
call ap_rparam (out, KY_SLOREJECT, rval, UN_SSIGMA,
"lower k-sigma rejection criterion")
newfit = YES
}
case SCMD_SHIREJECT:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_SHIREJECT)
call pargr (apstatr (ap, SHIREJECT))
call pargstr (UN_SSIGMA)
} else {
call apsetr (ap, SHIREJECT, rval)
if (stid > 1)
call ap_rparam (out, KY_SHIREJECT, rval, UN_SSIGMA,
"upper k-sigma rejection criterion")
newfit = YES
}
case SCMD_SLOCLIP:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_SLOCLIP)
call pargr (apstatr (ap, SLOCLIP))
call pargstr (UN_SPERCENT)
} else {
call apsetr (ap, SLOCLIP, rval)
if (stid > 1)
call ap_rparam (out, KY_SLOCLIP, rval, UN_SPERCENT,
"lower k-sigma rejection criterion")
newfit = YES
}
case SCMD_SHICLIP:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_SHICLIP)
call pargr (apstatr (ap, SHICLIP))
call pargstr (UN_SPERCENT)
} else {
call apsetr (ap, SHICLIP, rval)
if (stid > 1)
call ap_rparam (out, KY_SHICLIP, rval, UN_SPERCENT,
"lower k-sigma rejection criterion")
newfit = YES
}
case SCMD_SMAXITER:
call gargi (ival)
if (nscan () == 1) {
call printf ("%s = %d\n")
call pargstr (KY_SMAXITER)
call pargi (apstati (ap, SMAXITER))
} else {
call apseti (ap, SMAXITER, ival)
if (stid > 1)
call ap_iparam (out, KY_SMAXITER, ival, UN_SNUMBER,
"maximum number of iterations")
newfit = YES
}
case SCMD_BINSIZE:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_BINSIZE)
call pargr (apstatr (ap, BINSIZE))
call pargstr (UN_SSIGMA)
} else {
call apsetr (ap, BINSIZE, rval)
if (stid > 1)
call ap_rparam (out, KY_BINSIZE, rval, UN_SSIGMA,
"width of the sky histogram bin")
newfit = YES
}
case SCMD_SMOOTH:
call gargb (bval)
if (nscan () == 1) {
call printf ("%s = %b\n")
call pargstr (KY_SMOOTH)
call pargb (itob (apstati (ap, SMOOTH)))
} else {
call apseti (ap, SMOOTH, btoi (bval))
if (stid > 1)
call ap_bparam (out, KY_SMOOTH, bval, UN_SSWITCH,
"Lucy smooth the histogram")
newfit = YES
}
case SCMD_RGROW:
call gargr (rval)
if (nscan() == 1) {
call printf ("%s = %g %s\n")
call pargstr (KY_RGROW)
call pargr (apstatr (ap, RGROW))
call pargstr (UN_SSCALEUNIT)
} else {
call apsetr (ap, RGROW, rval)
if (stid > 1)
call ap_rparam (out, KY_RGROW, rval, UN_SSCALEUNIT,
"region growing radius")
newfit = YES
}
case SCMD_SNREJECT:
call gargi (ival)
if (nscan () == 1) {
call printf ("%s = %d\n")
call pargstr (KY_SNREJECT)
call pargi (apstati (ap, SNREJECT))
} else {
call apseti (ap, SNREJECT, ival)
if (stid > 1)
call ap_iparam (out, KY_SNREJECT, ival, UN_SNUMBER,
"maximum number of rejection cycles")
newfit = YES
}
case SCMD_SKYVALUE:
call gargr (rval)
if (nscan () == 1) {
call printf ("%s = %g\n")
call pargstr (KY_SKY_BACKGROUND)
call pargr (apstatr (ap, SKY_BACKGROUND))
call pargstr (UN_SCOUNTS)
} else {
call apsetr (ap, SKY_BACKGROUND, rval)
if (stid > 1)
call ap_rparam (out, KY_SKY_BACKGROUND, rval,
UN_SCOUNTS, "user supplied sky value")
newfit = YES
}
case SCMD_MKSKY:
call gargb (bval)
if (nscan () == 1) {
call printf ("%s = %b\n")
call pargstr (KY_MKSKY)
call pargb (itob (apstati (ap, MKSKY)))
} else {
call apseti (ap, MKSKY, btoi (bval))
}
default:
# do nothing gracefully
call printf ("Unrecognized command\7\n")
}
call sfree (sp)
end
# AP_SIMCOLON -- Procedure to process fitsky commands which alter parameters
# other than the sky fitting parameters themselves.
procedure ap_simcolon (ap, cmdstr)
pointer ap # pointer to the apphot structure
char cmdstr[ARB] # command string
bool bval
int ncmd
pointer sp, cmd
bool itob()
int strdic(), nscan(), apstati(), btoi()
begin
call smark (sp)
call salloc (cmd, SZ_LINE, TY_CHAR)
# Get the command.
call sscan (cmdstr)
call gargwrd (Memc[cmd], SZ_LINE)
if (Memc[cmd] == EOS) {
call sfree (sp)
return
}
# Process the commands.
ncmd = strdic (Memc[cmd], Memc[cmd], SZ_LINE, MISC)
switch (ncmd) {
case ACMD_SHOW:
call gargwrd (Memc[cmd], SZ_LINE)
ncmd = strdic (Memc[cmd], Memc[cmd], SZ_LINE, SSHOWARGS)
switch (ncmd) {
case SCMD_DATA:
call printf ("\n")
call ap_nshow (ap)
call printf ("\n")
case SCMD_SKY:
call printf ("\n")
call ap_spshow (ap)
call printf ("\n")
default:
call printf ("\n")
call ap_sshow (ap)
call printf ("\n")
}
case ACMD_RADPLOTS:
call gargb (bval)
if (nscan () == 1) {
call printf ("%s = %b\n")
call pargstr (KY_RADPLOTS)
call pargb (itob (apstati (ap, RADPLOTS)))
} else {
call apseti (ap, RADPLOTS, btoi (bval))
}
default:
call printf ("Unknown or ambiguous colon command\7\n")
}
call sfree (sp)
end
|