aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/daophot/peak/dprrphot.x
blob: 36aed88f528d0fb387be130ee46594ee7c0031de (plain) (blame)
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
include	"../lib/apseldef.h"

# DP_TPKINIT -- Procedure to initialize for reading the "standard" fields from
# a photometry table. The "standard" fields being ID, X, Y, MAG, ERR, and SKY

procedure dp_tpkinit (tp, colpoint)

pointer	tp			# the table descriptor
pointer	colpoint[ARB]		# the column descriptor

begin
	# Get the results one by one
	# First the ID
	call tbcfnd (tp, ID, colpoint[1], 1)
	if (colpoint[1] == NULL) {
	    call eprintf ("Column %s not found\n")
	        call pargstr (ID)
	}

	# Then the position
	call tbcfnd (tp, XCENTER, colpoint[2], 1)
	if (colpoint[2] == NULL) {
	    call eprintf ("Column %s not found\n")
	        call pargstr (XCENTER)
	}

	call tbcfnd (tp, YCENTER, colpoint[3], 1)
	if (colpoint[3] == NULL) {
	    call eprintf ("Column %s not found\n")
	        call pargstr (YCENTER)
	}

	# Now the Magnitude
	call tbcfnd (tp, MAG, colpoint[4], 1)
	if (colpoint[4] == NULL)		# No column
	    call tbcfnd (tp, APMAG, colpoint[4], 1)
	if (colpoint[4] == NULL) {
	    call eprintf ("Column %s not found\n")
	    call pargstr (APMAG)
	}

	# The sky
	call tbcfnd (tp, SKY, colpoint[5], 1)
	if (colpoint[5] == NULL)
	    call tbcfnd (tp, SKY, colpoint[5], 1)
	if (colpoint[5] == NULL) {
	    call eprintf ("Column %s not found\n")
	        call pargstr (SKY)
	}
end


# DP_RRPHOT -- Fetch the photometry for a single star from either a
# table or a text photometry file.

int procedure dp_rrphot (tp, key, fields, indices, id, x, y, sky, mag,
	instar, nrow)

int	tp		# the input file descriptor
pointer	key		# pointer to text apphot structure
char	fields[ARB]	# character fields
int	indices[ARB]	# columns pointers
int	id		# star id
real	x		# x center value
real	y		# y center value
real	sky		# sky value
real	mag		# magnitude
int	instar		# current record
int	nrow		# maximum number of rows for ST table

bool	nullflag
int	nrec
int	dp_apsel()

begin
	# If nrow is 0 the file file is a text file otherwise it is a table.

	if (nrow == 0) {

	    nrec = dp_apsel (key, tp, fields, indices, id, x, y, sky, mag)
	    if (nrec != EOF)
		instar = instar + 1

	} else if ((instar + 1) <= nrow) {

	    instar = instar + 1
	    call tbrgti (tp, indices[1], id, nullflag, 1, instar)
	    call tbrgtr (tp, indices[2], x, nullflag, 1, instar)
	    call tbrgtr (tp, indices[3], y, nullflag, 1, instar)
	    call tbrgtr (tp, indices[4], mag, nullflag, 1, instar)
	    call tbrgtr (tp, indices[5], sky, nullflag, 1, instar)
	    nrec = instar

	} else
	    nrec = EOF

	return (nrec)
end