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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
include <time.h>
include <tbset.h>
include "../lib/daophotdef.h"
include "../lib/apseldef.h"
include "../lib/psfdef.h"
# DP_WNEISTARS -- Identify the neighbour stars of the psf stars and write them
# out in groups.
procedure dp_wneistars (dao, im, psfgr)
pointer dao # pointer to the daophot structure
pointer im # the input image descriptor
int psfgr # the output group file descriptor
bool newfile
int top_star, psf_star, nei1, nei2
pointer psf
int dp_neistars()
begin
psf = DP_PSF(dao)
newfile = true
top_star = DP_PNUM(psf) + 1
do psf_star = 1, DP_PNUM(psf) {
if (dp_neistars (dao, psf_star, top_star, nei1, nei2) <= 0)
;
call dp_pwrtgrp (dao, im, psfgr, psf_star, nei1, nei2, newfile)
if (newfile)
newfile = false
}
end
# DP_NEISTARS -- Identify the neighbours and friends of the neighbours for
# an individual PSF star.
int procedure dp_neistars (dao, psf_star, top_star, nei1, nei2)
pointer dao # pointer to the daophot structure
int psf_star # the psf star in question
int top_star # pointer to the current top_star
int nei1, nei2 # pointer to to the list of neighbours
int j, nei_star
pointer apsel
real rsq1, rsq2, rsq
begin
# Define some pointers
apsel = DP_APSEL(dao)
# These are thhe values used by daophot ii. I have decided to keep
# the old values because I have kept the old grouping algorithm.
#rsq1 = (1.5 * DP_PSFRAD(dao) + 2.0 * DP_FITRAD(dao) + 1.0) ** 2
#rsq2 = (2.0 * DP_FITRAD(dao) + 1.0) ** 2
rsq1 = (DP_PSFRAD(dao) + 2.0 * DP_FITRAD(dao) + 1.0) ** 2
rsq2 = (2.0 * DP_FITRAD(dao)) ** 2
# Find the neighbour stars for a given psf star. This step is the
# same as the daophot ii step although I am using a smaller critical
# radius.
nei1 = top_star
for (j = top_star; j <= DP_APNUM(apsel); j = j + 1) {
rsq = (Memr[DP_APXCEN(apsel)+j-1] -
Memr[DP_APSEL(apsel)+psf_star-1]) ** 2 +
(Memr[DP_APYCEN(apsel)+j-1] -
Memr[DP_APYCEN(apsel)+psf_star-1]) ** 2
if (rsq > rsq1)
next
call dp_5swap (j, top_star, Memi[DP_APID(apsel)],
Memr[DP_APXCEN(apsel)], Memr[DP_APYCEN(apsel)],
Memr[DP_APMAG(apsel)], Memr[DP_APMSKY(apsel)])
top_star = top_star +1
}
nei2 = top_star - 1
# Find the friends of the neighbor stars. I do this on a per psf
# star basis. I do not find friends of all the neighbor stars
# only the neighbour stars for a particular psf star. This is
# because I found the daophot ii algorithm could produce too
# may odd stars.
do nei_star = nei1, nei2 {
for (j = top_star; j <= DP_APNUM(apsel); j = j + 1) {
rsq = (Memr[DP_APXCEN(apsel)+j-1] -
Memr[DP_APSEL(apsel)+nei_star-1]) ** 2 +
(Memr[DP_APYCEN(apsel)+j-1] -
Memr[DP_APYCEN(apsel)+nei_star-1]) ** 2
if (rsq > rsq2)
next
call dp_5swap (j, top_star, Memi[DP_APID(apsel)],
Memr[DP_APXCEN(apsel)], Memr[DP_APYCEN(apsel)],
Memr[DP_APMAG(apsel)], Memr[DP_APMSKY(apsel)])
top_star = top_star +1
}
}
nei2 = top_star - 1
return (nei2 - nei1 + 1)
end
# DP_PWRTGRP -- Add a group to the PSF output group file.
procedure dp_pwrtgrp (dao, im, psfgr, psf_star, nei1_star, nei2_star, new_table)
pointer dao # the pointer to the daophot structure
pointer im # the input image descriptor
int psfgr # the group file descriptor
int psf_star # the psf star index
int nei1_star, nei2_star # the first and last neighbour star indices
bool new_table # should a new table be created
int group
begin
# Chexk to see if the PSF group file is open.
if (psfgr == NULL)
return
# Create the table.
if (new_table) {
# Initialize.
group = 1
# Make a new group.
if (DP_TEXT(dao) == YES)
call dp_pxnewgrp (dao, im, psfgr, psf_star, nei1_star,
nei2_star, group)
else
call dp_ptnewgrp (dao, im, psfgr, psf_star, nei1_star,
nei2_star, group)
} else {
# Increment.
group = group + 1
# Add to the file.
if (DP_TEXT(dao) == YES)
call dp_pxaddgrp (dao, im, psfgr, psf_star, nei1_star,
nei2_star, group)
else
call dp_ptaddgrp (dao, im, psfgr, psf_star, nei1_star,
nei2_star, group)
}
end
define NCOLUMN 5
# DP_WPLIST -- Write the list of psf stars to the output psf star list.
procedure dp_wplist (dao, im, opst)
pointer dao # pointer to the daophot structure
pointer im # the input image descriptor
int opst # the output psf star list descriptor
pointer apsel, psf, sp, ocolpoint, tx, ty
int dp_stati()
bool itob()
begin
# Get some daophot pointers.
apsel = DP_APSEL(dao)
psf = DP_PSF(dao)
# Allocate some working memory.
call smark (sp)
call salloc (ocolpoint, NCOLUMN, TY_POINTER)
call salloc (tx, DP_PNUM(psf), TY_REAL)
call salloc (ty, DP_PNUM(psf), TY_REAL)
# Initialize the output file.
if (dp_stati (dao, TEXT) == YES) {
call dp_pxgrppars (dao, opst)
call dp_xpbanner (opst)
} else {
call dp_tpdefcol (opst, Memi[ocolpoint])
call dp_ptgrppars (dao, opst)
}
# Write out the stars.
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)], Memr[DP_APYCEN(apsel)],
Memr[tx], Memr[ty], DP_PNUM(psf))
call dp_wpstars (opst, Memi[ocolpoint], itob (dp_stati (dao, TEXT)),
Memi[DP_APID(apsel)], Memr[tx], Memr[ty], Memr[DP_APMAG(apsel)],
Memr[DP_APMSKY(apsel)], DP_PNUM(psf))
# Free memory.
call sfree (sp)
end
define PGR_NAMESTR "#N%4tID%10tGROUP%16tXCENTER%26tYCENTER%36tMAG%48t\
MSKY%80t\\\n"
define PGR_UNITSTR "#U%4t##%10t##%16tpixels%26tpixels%36tmagnitudes%48t\
counts%80t\\\n"
define PGR_FORMATSTR "#F%4t%%-9d%10t%%-6d%16t%%-10.3f%26t%%-10.3f%36t\
%%-12.3f%48t%%-15.7g%80t \n"
define PGR_DATASTR "%-9d%10t%-6d%16t%-10.3f%26t%-10.3f%36t%-12.3f%48t\
%-15.7g%80t \n"
# DP_PXNEWGRP -- Create a new PSF output group text file and write the
# first group to it.
procedure dp_pxnewgrp (dao, im, tp, psf_star, nei1_star, nei2_star, group)
pointer dao # pointer to the daophot structure.
pointer im # pointer to the input image
int tp # the output file descriptor
int psf_star # the psf star index
int nei1_star, nei2_star # the first and last neighbour star indices
int group # current group
real tx, ty
pointer apsel
int i
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Define some pointers.
apsel = DP_APSEL(dao)
# Write out the header parameters.
call dp_pxgrppars (dao, tp)
# Set up the column definitions.
call fprintf (tp, "#\n")
call fprintf (tp, PGR_NAMESTR)
call fprintf (tp, PGR_UNITSTR)
call fprintf (tp, PGR_FORMATSTR)
call fprintf (tp, "#\n")
# Write out the psf star.
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+psf_star-1],
Memr[DP_APYCEN(apsel)+psf_star-1], tx, ty, 1)
call fprintf (tp, PGR_DATASTR)
call pargi (Memi[DP_APID(apsel)+psf_star-1])
call pargi (group)
call pargr (tx)
call pargr (ty)
call pargr (Memr[DP_APMAG(apsel)+psf_star-1])
call pargr (Memr[DP_APMSKY(apsel)+psf_star-1])
# Write out the neighbour stars.
do i = nei1_star, nei2_star {
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+i-1],
Memr[DP_APYCEN(apsel)+i-1], tx, ty, 1)
call fprintf (tp, PGR_DATASTR)
call pargi (Memi[DP_APID(apsel)+i-1])
call pargi (group)
call pargr (tx)
call pargr (ty)
call pargr (Memr[DP_APMAG(apsel)+i-1])
call pargr (Memr[DP_APMSKY(apsel)+i-1])
}
end
# DP_PTNEWGRP -- Create a new PSF output group ST table and add to a new
# group to it.
procedure dp_ptnewgrp (dao, im, tp, psf_star, nei1_star, nei2_star, group)
pointer dao # pointer to the daophot structure.
pointer im # the input image descriptor
pointer tp # pointer to table
int psf_star # the psf star index
int nei1_star, nei2_star # the first and last psf star indices
int group # current group
real tx, ty
pointer sp, colnames, colunits, colformat, coldtype, collen, colpoint
pointer apsel
int i, j, row
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Define some pointers.
apsel = DP_APSEL(dao)
# Allocate space for table definition.
call smark (sp)
call salloc (colpoint, PSF_NOUTCOLS, TY_INT)
call salloc (colnames, PSF_NOUTCOLS * (SZ_COLNAME + 1), TY_CHAR)
call salloc (colunits, PSF_NOUTCOLS * (SZ_COLUNITS + 1), TY_CHAR)
call salloc (colformat, PSF_NOUTCOLS * (SZ_COLFMT + 1), TY_CHAR)
call salloc (coldtype, PSF_NOUTCOLS, TY_INT)
call salloc (collen, PSF_NOUTCOLS, TY_INT)
# Set up the column definitions.
call strcpy (ID, Memc[colnames], SZ_COLNAME)
call strcpy (GROUP, Memc[colnames+SZ_COLNAME+1], SZ_COLNAME)
call strcpy (XCENTER, Memc[colnames+2*SZ_COLNAME+2], SZ_COLNAME)
call strcpy (YCENTER, Memc[colnames+3*SZ_COLNAME+3], SZ_COLNAME)
call strcpy (MAG, Memc[colnames+4*SZ_COLNAME+4], SZ_COLNAME)
call strcpy (SKY, Memc[colnames+5*SZ_COLNAME+5], SZ_COLNAME)
# Set up the format definitions.
call strcpy ("%6d", Memc[colformat], SZ_COLFMT)
call strcpy ("%6d", Memc[colformat+SZ_COLFMT+1], SZ_COLFMT)
call strcpy ("%10.2f", Memc[colformat+2*SZ_COLFMT+2], SZ_COLFMT)
call strcpy ("%10.2f", Memc[colformat+3*SZ_COLFMT+3], SZ_COLFMT)
call strcpy ("%12.3f", Memc[colformat+4*SZ_COLFMT+4], SZ_COLFMT)
call strcpy ("%15.7g", Memc[colformat+5*SZ_COLFMT+5], SZ_COLFMT)
# Define the column units.
call strcpy ("NUMBER", Memc[colunits], SZ_COLUNITS)
call strcpy ("NUMBER", Memc[colunits+SZ_COLUNITS+1], SZ_COLUNITS)
call strcpy ("PIXELS", Memc[colunits+2*SZ_COLUNITS+2], SZ_COLUNITS)
call strcpy ("PIXELS", Memc[colunits+3*SZ_COLUNITS+3], SZ_COLUNITS)
call strcpy ("MAGNITUDES", Memc[colunits+4*SZ_COLUNITS+4], SZ_COLUNITS)
call strcpy ("COUNTS", Memc[colunits+5*SZ_COLUNITS+5], SZ_COLUNITS)
# Define the datatypes of the columns.
Memi[coldtype] = TY_INT
Memi[coldtype+1] = TY_INT
Memi[coldtype+2] = TY_REAL
Memi[coldtype+3] = TY_REAL
Memi[coldtype+4] = TY_REAL
Memi[coldtype+5] = TY_REAL
# Initialize the column length parameter.
do i = 1, PSF_NOUTCOLS {
j = i - 1
Memi[collen+j] = 1
}
# Define the table.
call tbcdef (tp, Memi[colpoint], Memc[colnames], Memc[colunits],
Memc[colformat], Memi[coldtype], Memi[collen], PSF_NOUTCOLS)
# Create the table.
call tbtcre (tp)
# Write out the psf star.
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+psf_star-1],
Memr[DP_APYCEN(apsel)+psf_star-1], tx, ty, 1)
call tbrpti (tp, Memi[colpoint], Memi[DP_APID(apsel)+psf_star-1], 1, 1)
call tbrpti (tp, Memi[colpoint+1], group, 1, 1)
call tbrptr (tp, Memi[colpoint+2], tx, 1, 1)
call tbrptr (tp, Memi[colpoint+3], ty, 1, 1)
call tbrptr (tp, Memi[colpoint+4], Memr[DP_APMAG(apsel)+psf_star-1],
1, 1)
call tbrptr (tp, Memi[colpoint+5], Memr[DP_APMSKY(apsel)+psf_star-1],
1, 1)
# Now write out the group.
row = 2
do i = nei1_star, nei2_star {
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+i-1],
Memr[DP_APYCEN(apsel)+i-1], tx, ty, 1)
call tbrpti (tp, Memi[colpoint], Memi[DP_APID(apsel)+i-1], 1, row)
call tbrpti (tp, Memi[colpoint+1], group, 1, row)
call tbrptr (tp, Memi[colpoint+2], tx, 1, row)
call tbrptr (tp, Memi[colpoint+3], ty, 1, row)
call tbrptr (tp, Memi[colpoint+4], Memr[DP_APMAG(apsel)+i-1],
1, row)
call tbrptr (tp, Memi[colpoint+5], Memr[DP_APMSKY(apsel)+i-1],
1, row)
row = row + 1
}
# Add the header parameters to the table.
call dp_ptgrppars (dao, tp)
call sfree (sp)
end
# DP_PTGRPPARS -- Add parameters to the header of the output PSF group ST
# table.
procedure dp_ptgrppars (dao, tp)
pointer dao # pointer to the daophot structure
pointer tp # pointer to the table
pointer sp, outstr, date, time
int envfind()
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Allocate workin space.
call smark (sp)
call salloc (outstr, SZ_LINE, TY_CHAR)
call salloc (date, SZ_DATE, TY_CHAR)
call salloc (time, SZ_DATE, TY_CHAR)
# Write the task and date identifiers.
if (envfind ("version", Memc[outstr], SZ_LINE) <= 0)
call strcpy ("NOAO/IRAF", Memc[outstr], SZ_LINE)
call dp_rmwhite (Memc[outstr], Memc[outstr], SZ_LINE)
call tbhadt (tp, "IRAF", Memc[outstr])
if (envfind ("userid", Memc[outstr], SZ_LINE) > 0)
call tbhadt (tp, "USER", Memc[outstr])
call gethost (Memc[outstr], SZ_LINE)
call tbhadt (tp, "HOST", Memc[outstr])
call dp_date (Memc[date], Memc[time], SZ_DATE)
call tbhadt (tp, "DATE", Memc[date])
call tbhadt (tp, "TIME", Memc[time])
# Define the package and task.
call tbhadt (tp, "PACKAGE", "daophot")
call tbhadt (tp, "TASK", "psf")
# Define the input and output files.
call dp_imroot (DP_INIMAGE(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "IMAGE", Memc[outstr])
call dp_froot (DP_INPHOTFILE(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "PHOTFILE", Memc[outstr])
if (DP_COORDS(dao) == EOS)
call tbhadt (tp, "PSTFILE", "\"\"")
else {
call dp_froot (DP_COORDS(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "PSTFILE", Memc[outstr])
}
call dp_imroot (DP_PSFIMAGE(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "PSFIMAGE", DP_PSFIMAGE(dao))
call dp_froot (DP_OUTREJFILE(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "OPSTFILE", Memc[outstr])
call dp_froot (DP_OUTPHOTFILE(dao), Memc[outstr], SZ_LINE)
call tbhadt (tp, "GRPSFILE", Memc[outstr])
# Data dependent parameters.
call tbhadr (tp, "SCALE", DP_SCALE(dao))
# Observing parameters.
call tbhadt (tp, "OTIME", DP_OTIME(dao))
call tbhadt (tp, "IFILTER", DP_IFILTER(dao))
call tbhadr (tp, "XAIRMASS", DP_XAIRMASS(dao))
# Grouping parameters.
call tbhadr (tp, "PSFRAD", DP_SPSFRAD(dao))
call tbhadr (tp, "FITRAD", DP_SFITRAD(dao))
call sfree(sp)
end
# DP_PXGRPPARS -- Add parameters to the header of the output PSF group text
# file.
procedure dp_pxgrppars (dao, tp)
pointer dao # pointer to the daophot structure
int tp # the output file descriptor
pointer sp, outstr, date, time
int envfind()
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Allocate workin space.
call smark (sp)
call salloc (outstr, SZ_LINE, TY_CHAR)
call salloc (date, SZ_DATE, TY_CHAR)
call salloc (time, SZ_DATE, TY_CHAR)
# Write the task and date identifiers.
if (envfind ("version", Memc[outstr], SZ_LINE) <= 0)
call strcpy ("NOAO/IRAF", Memc[outstr], SZ_LINE)
call dp_rmwhite (Memc[outstr], Memc[outstr], SZ_LINE)
call dp_sparam (tp, "IRAF", Memc[outstr], "version", "")
if (envfind ("userid", Memc[outstr], SZ_LINE) > 0)
call dp_sparam (tp, "USER", Memc[outstr], "name", "")
call gethost (Memc[outstr], SZ_LINE)
call dp_sparam (tp, "HOST", Memc[outstr], "computer", "")
call dp_date (Memc[date], Memc[time], SZ_DATE)
call dp_sparam (tp, "DATE", Memc[date], "yyyy-mm-dd", "")
call dp_sparam (tp, "TIME", Memc[time], "hh:mm:ss", "")
# Define the package and task.
call dp_sparam (tp, "PACKAGE", "daophot", "name", "")
call dp_sparam (tp, "TASK", "psf", "name", "")
# Define the input and output files.
call dp_imroot (DP_INIMAGE(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "IMAGE", Memc[outstr], "imagename", "")
call dp_froot (DP_INPHOTFILE(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "PHOTFILE", Memc[outstr], "filename", "")
if (DP_COORDS(dao) == EOS)
call dp_sparam (tp, "PSTFILE", "\"\"", "filename", "")
else {
call dp_froot (DP_COORDS(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "PSTFILE", Memc[outstr], "filename", "")
}
call dp_imroot (DP_PSFIMAGE(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "PSFIMAGE", Memc[outstr], "imagename", "")
call dp_froot (DP_OUTPHOTFILE(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "GRPSFILE", Memc[outstr], "filename", "")
call dp_froot (DP_OUTREJFILE(dao), Memc[outstr], SZ_LINE)
call dp_sparam (tp, "OPSTFILE", Memc[outstr], "filename", "")
# Define the data dependent parameters.
call dp_rparam (tp, "SCALE", DP_SCALE(dao), "units/pix", "")
# Observing parameters.
call dp_sparam (tp, "OTIME", DP_OTIME(dao), "timeunit", "")
call dp_sparam (tp, "IFILTER", DP_IFILTER(dao), "filter", "")
call dp_rparam (tp, "XAIRMASS", DP_XAIRMASS(dao), "number", "")
# Grouping parameters.
call dp_rparam (tp, "PSFRAD", DP_SPSFRAD(dao), "scaleunit", "")
call dp_rparam (tp, "FITRAD", DP_SFITRAD(dao), "scaleunit", "")
call sfree(sp)
end
# DP_PXADDGRP -- Add a new group to the existing PSF output group text file.
procedure dp_pxaddgrp (dao, im, tp, psf_star, nei1_star, nei2_star, group)
pointer dao # pointer to daophot structure
pointer im # the input image descriptor
int tp # the output file descriptor
int psf_star # the psf star index
int nei1_star, nei2_star # the first and last neighbour star indices
int group # current group
real tx, ty
pointer apsel
int i
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Get some daophot pointers.
apsel = DP_APSEL(dao)
# Write out the psf star.
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+psf_star-1],
Memr[DP_APYCEN(apsel)+psf_star-1], tx, ty, 1)
call fprintf (tp, PGR_DATASTR)
call pargi (Memi[DP_APID(apsel)+psf_star-1])
call pargi (group)
call pargr (tx)
call pargr (ty)
call pargr (Memr[DP_APMAG(apsel)+psf_star-1])
call pargr (Memr[DP_APMSKY(apsel)+psf_star-1])
# Now write out the group.
do i = nei1_star, nei2_star {
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+i-1],
Memr[DP_APYCEN(apsel)+i-1], tx, ty, 1)
call fprintf (tp, PGR_DATASTR)
call pargi (Memi[DP_APID(apsel)+i-1])
call pargi (group)
call pargr (tx)
call pargr (ty)
call pargr (Memr[DP_APMAG(apsel)+i-1])
call pargr (Memr[DP_APMSKY(apsel)+i-1])
}
end
# DP_PTADDGRP -- Add a new group to the existing PSF output group ST table.
procedure dp_ptaddgrp (dao, im, tp, psf_star, nei1_star, nei2_star, group)
pointer dao # pointer to daophot structure
pointer im # the input image descriptor
pointer tp # pointer to output table
int psf_star # the psf star index
int nei1_star, nei2_star # the first and last neighbor star indices
int group # current group
real tx, ty
pointer apsel, sp, colpoint
int i, nrows
int tbpsta()
begin
# Check to see if the PSF group file is open.
if (tp == NULL)
return
# Allocate space for the column pointers.
call smark (sp)
call salloc (colpoint, PSF_NOUTCOLS, TY_INT)
# Get some daophot pointers.
apsel = DP_APSEL(dao)
# Find the number of rows in the table and add on at the end.
nrows = tbpsta (tp, TBL_NROWS)
# Write out the psf star
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+psf_star-1],
Memr[DP_APYCEN(apsel)+psf_star-1], tx, ty, 1)
nrows = nrows + 1
call tbrpti (tp, Memi[colpoint], Memi[DP_APID(apsel)+psf_star-1],
1, nrows)
call tbrpti (tp, Memi[colpoint+1], group, 1, nrows)
call tbrptr (tp, Memi[colpoint+2], tx, 1, nrows)
call tbrptr (tp, Memi[colpoint+3], ty, 1, nrows)
call tbrptr (tp, Memi[colpoint+4], Memr[DP_APMAG(apsel)+psf_star-1],
1, nrows)
call tbrptr (tp, Memi[colpoint+5], Memr[DP_APMSKY(apsel)+psf_star-1],
1, nrows)
# Now write out the group.
do i = nei1_star, nei2_star {
nrows = nrows + 1
call dp_wout (dao, im, Memr[DP_APXCEN(apsel)+i-1],
Memr[DP_APYCEN(apsel)+i-1], tx, ty, 1)
call tbrpti (tp, Memi[colpoint], Memi[DP_APID(apsel)+i-1], 1, nrows)
call tbrpti (tp, Memi[colpoint+1], group, 1, nrows)
call tbrptr (tp, Memi[colpoint+2], tx, 1, nrows)
call tbrptr (tp, Memi[colpoint+3], ty, 1, nrows)
call tbrptr (tp, Memi[colpoint+4], Memr[DP_APMAG(apsel)+i-1], 1,
nrows)
call tbrptr (tp, Memi[colpoint+5], Memr[DP_APMSKY(apsel)+i-1], 1,
nrows)
}
call sfree (sp)
end
|