aboutsummaryrefslogtreecommitdiff
path: root/noao/nproto/ace/reviewproto.cl
blob: 2af722de54d0140307c674c6bc2777104f700a4a (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
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
# REVIEWPROTO

procedure reviewproto (catalog)

string	catalog			{prompt="Catalog"}
bool	nooverlay = yes		{prompt="Display image without overlays"}
bool	overlay = yes		{prompt="Display image with overlays"}
bool	comparison = yes	{prompt="Display comparison image"}
file	compimage = ""		{prompt="Comparison image"}
int	box = 200		{prompt="Box size (pixels)"}
string	ocolors = "green"	{prompt="Object mask color"}
string	lcolor = "red"		{prompt="Label color"}

struct	*fd

begin
	file	cat, im, mask, coords, compim, temp
	int	naxis1, naxis2, icolor, frame, nframe, x1, x2, y1, y2
	real	r, d, x, y, xt, yt
	bool	pause
	string	key, imsec
	struct	title

	coords = mktemp ("tmp$iraf")
	temp = mktemp ("tmp$iraf")

	# Get query parameters.
	cat = catalog

	# Get header and coordinates.
	tdump (cat, cdfile="", pfile=temp, datafile=coords,
	    columns="ra,dec", rows="", pwidth=80)
	match ("IMAGE", temp, stop-) | scan (im, im, im)
	match ("MASK", temp, stop-) | scan (mask, mask, mask)
	delete (temp, verify-)

	# Set image size.
	sections (im, option="root") | scan (im)
	hselect (im, "naxis1,naxis2", yes) | scan (naxis1, naxis2)

	# Set comparison.
	sections (compimage, option="root") | scan (compim)

	# Translate color specification.
	match (lcolor, "ace$colors.dat", stop-) | scan (lcolor, icolor)
	if (nscan() != 2)
	    icolor = 200

	# Number of frames.
	nframe = 0
	if (nooverlay)
	    nframe = nframe + 1
	if (overlay)
	    nframe = nframe + 1
	if (comparison && compim != "")
	    nframe = nframe + 1

	# Loop through the list of catalog coordinates.
	pause = NO
	fd = coords
	while (fscan (fd, r, d) != EOF) {
	    if (nscan() < 2)
		next
	    if (r == INDEF ||d == INDEF)
		next

	    # Pause with cursor read if there is more than one coordinate.
	    if (pause) {
		printf ("q to quit any other key to continue...\n")
		if (fscan (imcur, x, y, i, key) == EOF)
		    break
		if (key == 'q')
		    break
		pause = NO
	    }

	    # Display.
	    frame = nframe

	    if (comparison && compim != "") {
		# Convert world coordinate to image section.
		print (r, d) | wcsctran ("STDIN", "STDOUT", compim, "world",
		    "logical", columns="1 2", units="native native",
		    formats="", min_sigdigit=9, verbose=no) | scan (x, y)
		x = nint (x); y = nint (y)
		x1 = max (1, nint (x-box/2.))
		x2 = min (naxis1, nint (x+box/2.))
		y1 = max (1, nint (y-box/2.))
		y2 = min (naxis2, nint (y+box/2.))
		if (x2 > x1 && y2 > y1) {
		    # Display section.
		    printf ("%s[%d:%d,%d:%d]\n", compim, x1, x2, y1, y2) |
			scan (imsec)
		    acedisplay (imsec, frame, bpmask="", bpdisplay="none",
			bpcolors="red", overlay="", ocolors=ocolors,
			erase=yes, border_erase=no, select_frame=yes,
			repeat=no, fill=no, zscale=yes, contrast=0.25,
			zrange=yes, zmask="", nsample=1000, xcenter=0.5,
			ycenter=0.5, xsize=1., ysize=1., xmag=2., ymag=2.,
			order=0, z1=0., z2=0., ztrans="linear", lutfile="",
			>> "dev$null")

		    # Mark.
		    printf ("%g %g\n", x, y, >> temp)
		    tvmark (frame, temp, logfile="", autolog=no,
			outimage="", deletions="", commands="",
			mark="circle", radii="10", lengths="0",
			font="raster", color=icolor, label=no,
			number=no, nxoffset=0, nyoffset=0, pointsize=1,
			txsize=1, tolerance=1.5, interactive=no)
		    delete (temp, verify-)

		    # Label.
		    xt = x1 + 10
		    yt = y2 + 10
		    printf ("%g %g '%.2H %.1h'\n", xt, yt, r, d, >> temp)
		    tvmark (frame, temp, logfile="", autolog=no,
			outimage="", deletions="", commands="",
			mark="none", radii="0", lengths="0",
			font="raster", color=icolor, label=yes,
			number=no, nxoffset=0, nyoffset=0, pointsize=1,
			txsize=2, tolerance=1.5, interactive=no)
		    delete (temp, verify-)
		}
		frame = frame - 1
	    }

	    # Convert world coordinate to image section.
	    print (r, d) | wcsctran ("STDIN", "STDOUT", im, "world",
		"logical", columns="1 2", units="native native",
		formats="", min_sigdigit=9, verbose=no) | scan (x, y)
	    x = nint (x); y = nint (y)
	    x1 = max (1, nint (x-box/2.))
	    x2 = min (naxis1, nint (x+box/2.))
	    y1 = max (1, nint (y-box/2.))
	    y2 = min (naxis2, nint (y+box/2.))
	    if (x2 <= x1 || y2 <= y1)
		next

	    # Display.
	    if (overlay) {
		printf ("%s[%d:%d,%d:%d]\n", im, x1, x2, y1, y2) | scan (imsec)
		acedisplay (imsec, frame, bpmask="", bpdisplay="none",
		    bpcolors="red", overlay=mask, ocolors=ocolors,
		    erase=yes, border_erase=no, select_frame=yes,
		    repeat=no, fill=no, zscale=yes, contrast=0.25,
		    zrange=yes, zmask="", nsample=1000, xcenter=0.5,
		    ycenter=0.5, xsize=1., ysize=1., xmag=2., ymag=2.,
		    order=0, z1=0., z2=0., ztrans="linear", lutfile="",
		    >> "dev$null")

		# Mark
		printf ("%g %g\n", x, y, >> temp)
		tvmark (frame, temp, logfile="", autolog=no,
		    outimage="", deletions="", commands="",
		    mark="circle", radii="10", lengths="0",
		    font="raster", color=icolor, label=no,
		    number=no, nxoffset=0, nyoffset=0, pointsize=1,
		    txsize=1, tolerance=1.5, interactive=no)
		delete (temp, verify-)

		xt = x1 + 10
		yt = y2 + 10
		printf ("%g %g '%.2H %.1h'\n", xt, yt, r, d, >> temp)
		tvmark (frame, temp, logfile="", autolog=no,
		    outimage="", deletions="", commands="",
		    mark="none", radii="0", lengths="0",
		    font="raster", color=icolor, label=yes,
		    number=no, nxoffset=0, nyoffset=0, pointsize=1,
		    txsize=2, tolerance=1.5, interactive=no)
		delete (temp, verify-)

		frame = frame - 1
	    }

	    # Display.
	    if (nooverlay) {
		printf ("%s[%d:%d,%d:%d]\n", im, x1, x2, y1, y2) | scan (imsec)
		acedisplay (imsec, frame, bpmask="", bpdisplay="none",
		    bpcolors="red", overlay="", ocolors=ocolors,
		    erase=yes, border_erase=no, select_frame=yes,
		    repeat=no, fill=no, zscale=yes, contrast=0.25,
		    zrange=yes, zmask="", nsample=1000, xcenter=0.5,
		    ycenter=0.5, xsize=1., ysize=1., xmag=2., ymag=2.,
		    order=0, z1=0., z2=0., ztrans="linear", lutfile="",
		    >> "dev$null")

		# Mark
		printf ("%g %g\n", x, y, >> temp)
		tvmark (frame, temp, logfile="", autolog=no,
		    outimage="", deletions="", commands="",
		    mark="circle", radii="10", lengths="0",
		    font="raster", color=icolor, label=no,
		    number=no, nxoffset=0, nyoffset=0, pointsize=1,
		    txsize=1, tolerance=1.5, interactive=no)
		delete (temp, verify-)

		xt = x1 + 10
		yt = y2 + 10
		printf ("%g %g '%.2H %.1h'\n", xt, yt, r, d, >> temp)
		tvmark (frame, temp, logfile="", autolog=no,
		    outimage="", deletions="", commands="",
		    mark="none", radii="0", lengths="0",
		    font="raster", color=icolor, label=yes,
		    number=no, nxoffset=0, nyoffset=0, pointsize=1,
		    txsize=2, tolerance=1.5, interactive=no)
		delete (temp, verify-)

		frame = frame - 1
	    }

	    pause = YES
	}
	fd = ""; delete (coords, verify-)
end