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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
include "../lib/daophotdef.h"
include "../lib/apseldef.h"
include "../lib/psfdef.h"
# DP_PFSWAP -- Swap two stars in the PSF star list.
procedure dp_pfswap (dao, star1, star2)
pointer dao # pointer to the daophot structure
int star1 # index of first star to be swapped
int star2 # index of second star to be swapped
pointer apsel, psf
begin
apsel = DP_APSEL(dao)
psf = DP_PSF(dao)
call dp_10swap (star1, star2, Memi[DP_APID(apsel)],
Memr[DP_APXCEN(apsel)], Memr[DP_APYCEN(apsel)],
Memr[DP_APMAG(apsel)], Memr[DP_APMSKY(apsel)], Memr[DP_PXCEN(psf)],
Memr[DP_PYCEN(psf)], Memr[DP_PH(psf)], Memr[DP_PMAG(psf)],
Memi[DP_PSAT(psf)])
end
# DP_PFREORDER -- Move a star in the PSF star list to the end of the
# list.
procedure dp_pfreorder (dao, star, nstars)
pointer dao # pointer to the daophot structure
int star # index of star to be deleted
int nstars # index of second star to be swapped
pointer apsel, psf
begin
apsel = DP_APSEL(dao)
psf = DP_PSF(dao)
call dp_10reorder (star, Memi[DP_APID(apsel)], Memr[DP_APXCEN(apsel)],
Memr[DP_APYCEN(apsel)], Memr[DP_APMAG(apsel)],
Memr[DP_APMSKY(apsel)], Memr[DP_PXCEN(psf)], Memr[DP_PYCEN(psf)],
Memr[DP_PH(psf)], Memr[DP_PMAG(psf)], Memi[DP_PSAT(psf)], nstars)
end
# DP_APLSWAP -- Swap two stars in the daophot photometry substructure.
procedure dp_aplswap (dao, star1, star2)
pointer dao # pointer to the daophot structure
int star1 # index of first star to be swapped
int star2 # index of second star to be swapped
pointer apsel
begin
apsel = DP_APSEL(dao)
call dp_5swap (star1, star2, Memi[DP_APID(apsel)],
Memr[DP_APXCEN(apsel)], Memr[DP_APYCEN(apsel)],
Memr[DP_APMAG(apsel)], Memr[DP_APMSKY(apsel)])
end
# DP_XYHPSF -- Compute the initial x, y, and height of the current PSF star.
procedure dp_xyhpsf (dao, star, mag, saturated)
pointer dao # pointer to the daophot structure
int star # star for which x, y, h is to be computed
real mag # magnitude of proposed psf star
int saturated # is the star saturated
pointer apsel, psf, psffit
real dhdxc, dhdyc, junk
real dp_profile()
begin
apsel = DP_APSEL(dao)
psf = DP_PSF(dao)
psffit = DP_PSFFIT(dao)
Memr[DP_PXCEN(psf)+star-1] = Memr[DP_APXCEN(apsel)+star-1]
Memr[DP_PYCEN(psf)+star-1] = Memr[DP_APYCEN(apsel)+star-1]
if (saturated == YES)
Memr[DP_PH(psf)+star-1] = INDEFR
else
Memr[DP_PH(psf)+star-1] = (DP_CUR_PSFGMAX(psf) -
Memr[DP_APMSKY(apsel)+star-1]) /
dp_profile (DP_PSFUNCTION(psffit),
0.0, 0.0, Memr[DP_PSFPARS(psffit)], dhdxc, dhdyc, junk, 0)
Memr[DP_PMAG(psf)+star-1] = mag
Memi[DP_PSAT(psf)+star-1] = saturated
end
# DP_LISTPSF -- List the PSF stars.
procedure dp_listpsf (dao, im)
pointer dao # pointer to the daophot structure
pointer im # the input image descriptor
real x, y
pointer apsel, psf
int i
begin
apsel = DP_APSEL(dao)
psf = DP_PSF(dao)
call printf ("\nCurrent PSF star list\n")
do i = 1, DP_PNUM(psf) {
call dp_ltov (im, Memr[DP_APXCEN(apsel)+i-1],
Memr[DP_APYCEN(apsel)+i-1], x, y, 1)
call printf (
" Star: %4d X: %7.2f Y: %7.2f Mag: %7.2f Sky: %10.1f\n")
call pargi (Memi[DP_APID(apsel)+i-1])
call pargr (x)
call pargr (y)
call pargr (Memr[DP_APMAG(apsel)+i-1])
call pargr (Memr[DP_APMSKY(apsel)+i-1])
}
call printf ("\n")
end
# DP_LISTPARS -- List the analytic PSF parameters.
procedure dp_listpars (dao)
pointer dao # pointer to the daophot structure
pointer psffit
begin
psffit = DP_PSFFIT(dao)
call printf ("\nAnalytic PSF fit \n")
call printf (
" Function: %s X: %g Y: %g Height: %g Psfmag: %g\n")
call pargstr (DP_FUNCTION(dao))
call pargr (DP_PSFX(psffit))
call pargr (DP_PSFY(psffit))
call pargr (DP_PSFHEIGHT(psffit))
call pargr (DP_PSFMAG(psffit))
switch (DP_PSFUNCTION(psffit)) {
case FCTN_GAUSS:
call printf (" Par1: %g Par2: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
case FCTN_MOFFAT15:
call printf (
" Par1: %g Par2: %g XYterm: %g Moffat: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
call pargr (Memr[DP_PSFPARS(psffit)+2])
call pargr (1.5)
case FCTN_PENNY1:
call printf (" Par1: %g Par2: %g Par3: %g Par4: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
call pargr (Memr[DP_PSFPARS(psffit)+2])
call pargr (Memr[DP_PSFPARS(psffit)+3])
case FCTN_MOFFAT25:
call printf (
" Par1: %g Par2: %g XYterm: %g Moffat: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
call pargr (Memr[DP_PSFPARS(psffit)+2])
call pargr (2.5)
case FCTN_PENNY2:
call printf (
" Par1: %g Par2: %g Par3: %g Par4: %g Par5: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
call pargr (Memr[DP_PSFPARS(psffit)+2])
call pargr (Memr[DP_PSFPARS(psffit)+3])
call pargr (Memr[DP_PSFPARS(psffit)+4])
case FCTN_LORENTZ:
call printf (" Par1: %g Par2: %g Par3: %g\n")
call pargr (Memr[DP_PSFPARS(psffit)])
call pargr (Memr[DP_PSFPARS(psffit)+1])
call pargr (Memr[DP_PSFPARS(psffit)+2])
}
end
# DP_PSHOW -- Print photometry for the given star
procedure dp_pshow (dao, im, istar)
pointer dao # pointer to the main daophot descriptor
pointer im # the input image descriptor
int istar # star to be printed
real x, y
pointer apsel
begin
apsel = DP_APSEL(dao)
call dp_ltov (im, Memr[DP_APXCEN(apsel)+istar-1],
Memr[DP_APYCEN(apsel)+istar-1], x, y, 1)
call printf (
"Star: %4d X: %7.2f Y: %7.2f Mag: %7.2f Sky: %10.1f\n")
call pargi (Memi[DP_APID(apsel)+istar-1])
call pargr (x)
call pargr (y)
call pargr (Memr[DP_APMAG(apsel)+istar-1])
call pargr (Memr[DP_APMSKY(apsel)+istar-1])
end
# DP_10REORDER -- Move a PSF star to the end of the list.
procedure dp_10reorder (star, id, x, y, mag, sky, xfit, yfit, hfit, pmag,
sat, nstars)
int star # star to be moved to the end of the list
int id[ARB] # the ids of the stars
real x[ARB] # the x positions of the stars
real y[ARB] # the y positions of the stars
real mag[ARB] # the magnitudes of the stars
real sky[ARB] # the sky values of the stars
real xfit[ARB] # the current x fit array
real yfit[ARB] # the current y fit array
real hfit[ARB] # the current height of the stars
real pmag[ARB] # the psf star list magnitude
int sat[ARB] # are the star saturated
int nstars # number of stars in the list
int i, ihold, sfhold
real xhold, yhold, mhold, shold, xfhold, yfhold, hfhold, mfhold
begin
ihold = id[star]
xhold = x[star]
yhold = y[star]
mhold = mag[star]
shold = sky[star]
xfhold = xfit[star]
yfhold = yfit[star]
hfhold = hfit[star]
mfhold = pmag[star]
sfhold = sat[star]
do i = star + 1, nstars {
id[i-1] = id[i]
x[i-1] = x[i]
y[i-1] = y[i]
mag[i-1] = mag[i]
sky[i-1] = sky[i]
xfit[i-1] = xfit[i]
yfit[i-1] = yfit[i]
hfit[i-1] = hfit[i]
pmag[i-1] = pmag[i]
sat[i-1] = sat[i]
}
id[nstars] = ihold
x[nstars] = xhold
y[nstars] = yhold
mag[nstars] = mhold
sky[nstars] = shold
xfit[nstars] = xfhold
yfit[nstars] = yfhold
hfit[nstars] = hfhold
pmag[nstars] = mfhold
sat[nstars] = sfhold
end
# DP_5SWAP -- Exchange the position of two stars in the APPHOT photometry
# results.
procedure dp_5swap (star1, star2, id, x, y, mag, sky)
int star1, star2 # the indices of the two stars to exchange
int id[ARB] # the ids of the stars
real x[ARB] # the x postions of the stars
real y[ARB] # the y positions of the stars
real mag[ARB] # the magnitudes of the stars
real sky[ARB] # the sky values of the stars
int ihold
real xhold, yhold, mhold, shold
begin
ihold = id[star1]
xhold = x[star1]
yhold = y[star1]
mhold = mag[star1]
shold = sky[star1]
id[star1] = id[star2]
x[star1] = x[star2]
y[star1] = y[star2]
mag[star1] = mag[star2]
sky[star1] = sky[star2]
id[star2] = ihold
x[star2] = xhold
y[star2] = yhold
mag[star2] = mhold
sky[star2] = shold
end
# DP_10SWAP -- Exchange the position of two stars in the APPHOT photometry
# and PSF fitting results.
procedure dp_10swap (star1, star2, id, x, y, mag, sky, xfit, yfit, hfit, pmag,
sat)
int star1, star2 # the indices of the two stars to exchange
int id[ARB] # the ids of the stars
real x[ARB] # the x postions of the stars
real y[ARB] # the y positions of the stars
real mag[ARB] # the magnitudes of the stars
real sky[ARB] # the sky values of the stars
real xfit[ARB] # the current x fit array
real yfit[ARB] # the current y fit array
real hfit[ARB] # the current height of the stars
real pmag[ARB] # the psf star list magnitudes
int sat[ARB] # are the star saturated
int ihold, sfhold
real xhold, yhold, mhold, shold, xfhold, yfhold, hfhold, mfhold
begin
ihold = id[star1]
xhold = x[star1]
yhold = y[star1]
mhold = mag[star1]
shold = sky[star1]
xfhold = xfit[star1]
yfhold = yfit[star1]
hfhold = hfit[star1]
mfhold = pmag[star1]
sfhold = sat[star1]
id[star1] = id[star2]
x[star1] = x[star2]
y[star1] = y[star2]
mag[star1] = mag[star2]
sky[star1] = sky[star2]
xfit[star1] = xfit[star2]
yfit[star1] = yfit[star2]
hfit[star1] = hfit[star2]
pmag[star1] = pmag[star2]
sat[star1] = sat[star2]
id[star2] = ihold
x[star2] = xhold
y[star2] = yhold
mag[star2] = mhold
sky[star2] = shold
xfit[star2] = xfhold
yfit[star2] = yfhold
hfit[star2] = hfhold
pmag[star2] = mfhold
sat[star2] = sfhold
end
# DP_ISSAT -- Is the candidate PSF star saturated ?
int procedure dp_issat (dao, starno)
pointer dao # pointer to the daophot structure
int starno # the star index number
pointer psf
begin
psf = DP_PSF(dao)
if (Memi[DP_PSAT(psf)+starno-1] == YES)
return (YES)
else
return (NO)
end
|