aboutsummaryrefslogtreecommitdiff
path: root/noao/astcat/src/asttest.cl
blob: 2329217264cbe283a7b34720318cb45275744646 (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
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
# ASTTEST - Self testing procedure for the ASTCAT package.

procedure asttest (rootname)

string	rootname	{prompt="Root name of the output test files"}
string	astlogfile	{"", prompt="Name of the output log file"}

struct	*catlist
struct	*svlist

begin
	# Declare local variables.
	string	troot, tastlog, tcatlist, tcatalog, tcatfile
	string	tsvlist, tsurvey, timage, ttemp1
	int tfirst, tlast, tindex

	# Check that the user truly wants to proceed.
	ttemp1 = ""
	print ("")
	print ("ASTTEST initializes the ASTCAT task parameters")
	print ("Type 'q' or 'Q' to quit, any other key to proceed")
	if (scan (ttemp1) != EOF) {
	    if (ttemp1 == "q" || ttemp1 == "Q") {
		print ("Terminating the ASTTEST task")
		bye
	    }
	}
	print ("")

	# Define the plot file name.

	troot = rootname
	tastlog = astlogfile
	if (tastlog == "") {
	    tastlog = troot // ".log"
	}

	# Check for the existence of the test files.

	if (access (tastlog)) {
	    error (0, "Error: The log file already exists on disk")
	}

	# Create some temporary files.

	tcatlist = mktemp (troot)
	tsvlist = mktemp (troot)

	# Initialize the ASTCAT package.

	print ("Initialize the ASTCAT package", >> tastlog)
	print ("", >> tastlog)
	print ("")
	print ("Initialize the ASTCAT package")
	print ("")

	astcat.catalogs = "usno2@noao"
	astcat.catdb = "astcat$lib/catdb.dat"
	astcat.imsurveys = "dss2@cadc"
	astcat.imdb = "astcat$lib/imdb.dat"

	# Unlearning tasks and psets. Ran into a problem with doing
	# unlearn on astcat which I will have to work around.

	# unlearn ("astcat")
	unlearn ("acatpars")
	unlearn ("aclist")
	unlearn ("adumpcat")
	unlearn ("adumpim")
	unlearn ("afiltcat")
	unlearn ("afiltpars")
	unlearn ("agetcat")
	unlearn ("agetim")
	unlearn ("ahedit")
	unlearn ("aimfind")
	unlearn ("aimpars")
	unlearn ("aregpars")
	unlearn ("aslist")
	unlearn ("awcspars")

	# Do the tests.

	# Test the ACLIST task.

	print ("", >> tastlog)
	print ("Testing the ACLIST task", >> tastlog)
	print ("Testing the ACLIST task")
	print ("", >> tastlog)

	aclist ("*", verbose+, catdb=")_.catdb", >> tastlog)
	aclist ("*", verbose-, catdb=")_.catdb", > tcatlist)
	print ("", >> tastlog)

	# Test the ADUMPCAT task.

	print ("", >> tastlog)
	print ("Testing the ADUMPCAT task", >> tastlog)
	print ("Testing the ADUMPCAT task")
	print ("", >> tastlog)

	catlist = tcatlist
	while (fscan (catlist, tcatalog) != EOF) {
	    print ("", >> tastlog)
	    print (tcatalog, >> tastlog)
	    print ("", >> tastlog)
	    print ("    ", tcatalog)
	    if (tcatalog == "tmass@ipac") {
		adumpcat (tcatalog, "STDOUT", ra="00:00:00.0", dec="00:00:00",
		    size="0.17", catdb=")_.catdb", >> tastlog)
	    } else {
		adumpcat (tcatalog, "STDOUT", ra="00:00:00.0", dec="00:00:00",
		    size="10.0", catdb=")_.catdb", >> tastlog)
	    }
	    print ("", >> tastlog)
	}

	# Test the AGETCAT and AFILTCAT tasks.

	print ("", >> tastlog)
	print ("Testing the AGETCAT and AFILTCAT tasks", >> tastlog)
	print ("Testing the AGETCAT and AFILTCAT tasks")
	print ("", >> tastlog)

	catlist = tcatlist 
	while (fscan (catlist, tcatalog) != EOF) {
	    print ("", >> tastlog)
	    print (tcatalog, >> tastlog)
	    print ("", >> tastlog)
	    print ("    ", tcatalog)
	    tfirst = 1
	    tlast = strlen (tcatalog)
	    tindex = stridx ("@", tcatalog)
	    tcatfile = substr (tcatalog, tfirst, tindex - 1) // "." //
		substr (tcatalog, tindex + 1, tlast) // ".cat"
	    if (access (tcatfile)) {
		delete (tcatfile, verify-)
	    }
	    agetcat ("pars", tcatfile, rcra="00:00:00.00", rcdec="+00:00:00.0",
	        rrawidth=20.0, rdecwidth=20.0, catalogs=tcatalog, standard+,
		filter-, update-, verbose+, catdb=")_.catdb", >> tastlog)
	    print ("", >> tastlog)
	    type (tcatfile, map_cc+, device="terminal", >> tastlog)
	    print ("", >> tastlog)
	    afiltcat (tcatfile, tcatfile, catalogs="filename@noao", standard+,
	        filter+, fsort="mag1", update-, verbose+, catdb=")_.catdb",
		>> tastlog)
	    print ("", >> tastlog)
	    type (tcatfile, map_cc+, device="terminal", >> tastlog)
	    print ("", >> tastlog)
	    delete (tcatfile, verify-)
	}

	# Test the ASLIST task.

	print ("", >> tastlog)
	print ("Testing the ASLIST task", >> tastlog)
	print ("Testing the ASLIST task")
	print ("", >> tastlog)

	aslist ("*", verbose+, imdb=")_.imdb", >> tastlog)
	aslist ("*", verbose-, imdb=")_.imdb", > tsvlist)
	print ("", >> tastlog)

	# Test the ADUMPIM task.

	print ("", >> tastlog)
	print ("Testing the ADUMPIM task", >> tastlog)
	print ("Testing the ADUMPIM task")
	print ("", >> tastlog)

	svlist = tsvlist
	while (fscan (svlist, tsurvey) != EOF) {
	    print ("", >> tastlog)
	    print (tsurvey, >> tastlog)
	    print ("", >> tastlog)
	    print ("    ", tsurvey)
	    tfirst = 1
	    tlast = strlen (tsurvey)
	    tindex = stridx ("@", tsurvey)
	    timage = substr (tsurvey, tfirst, tindex - 1) // "." //
		substr (tsurvey, tindex + 1, tlast) // ".fits"
	    if (imaccess (timage)) {
	        imdelete (timage, verify-)
	    }
	    adumpim (tsurvey, timage, ra="14:28:07.0", dec="+34:55:00",
		    size="10.0", imdb=")_.imdb", >> tastlog)
	    printf ("    ")
	    imheader (timage, longheader-, userfields+)
	    print ("", >> tastlog)
	    imheader (timage, longheader+, userfields+, >> tastlog)
	    print ("", >> tastlog)
	    imdelete (timage, verify-)
	}

	# Test the AGETIM and AHEDIT tasks.

	print ("", >> tastlog)
	print ("Testing the AGETIM and AHEDIT tasks", >> tastlog)
	print ("Testing the AGETIM and AHEDIT tasks")
	print ("", >> tastlog)

	svlist = tsvlist
	while (fscan (svlist, tsurvey) != EOF) {
	    print ("", >> tastlog)
	    print (tsurvey, >> tastlog)
	    print ("", >> tastlog)
	    tfirst = 1
	    tlast = strlen (tsurvey)
	    tindex = stridx ("@", tsurvey)
	    timage = substr (tsurvey, tfirst, tindex - 1) // "." //
		substr (tsurvey, tindex + 1, tlast) // ".fits"
	    if (imaccess (timage)) {
	        imdelete (timage, verify-)
	    }
	    agetim ("pars", timage, rcra="14:28:07.00", rcdec="+34:55:00.0",
	        rrawidth=10.0, rdecwidth=10.0, imsurveys=tsurvey, wcsedit-,
		hdredit-, update-, verbose+, imdb=")_.imdb", >> tastlog)
	    printf ("    ")
	    imheader (timage, longheader-, userfields+)
	    print ("", >> tastlog)
	    imheader (timage, longheader+, userfields+, >> tastlog)
	    print ("", >> tastlog)
	    ahedit (timage, tsurvey, hupdate+, wcsedit+, wcs="none", hdredit+,
	        update-, verbose+, imdb=")_.imdb", >> tastlog)
	    print ("", >> tastlog)
	    imheader (timage, longheader+, userfields+, >> tastlog)
	    #imdelete (timage, verify-)
	}

	# Test the AIMFIND task.

	print ("", >> tastlog)
	print ("Testing the AIMFIND task", >> tastlog)
	print ("Testing the AIMFIND task")
	print ("", >> tastlog)

	# Test the aimfind task using the USNO2 survey

	svlist = tsvlist
	while (fscan (svlist, tsurvey) != EOF) {
	    tfirst = 1
	    tlast = strlen (tsurvey)
	    tindex = stridx ("@", tsurvey)
	    timage = substr (tsurvey, tfirst, tindex - 1) // "." //
		substr (tsurvey, tindex + 1, tlast) // ".fits"
	    tcatfile = substr (tsurvey, tfirst, tindex - 1) // "." //
		substr (tsurvey, tindex + 1, tlast) // ".cat"
	    if (access (tcatfile)) {
		delete (tcatfile, verify-)
	    }
	    aimfind (timage, tcatfile, imfile="", catalogs="usno2@noao",
	        standard+, filter-, append-, update-, verbose+,
		catdb=")_.catdb", >> tastlog)
	}

	# Reinitialize the astcat package.

	# unlearn ("astcat")
	unlearn ("acatpars")
	unlearn ("aclist")
	unlearn ("adumpcat")
	unlearn ("adumpim")
	unlearn ("afiltcat")
	unlearn ("afiltpars")
	unlearn ("agetcat")
	unlearn ("agetim")
	unlearn ("ahedit")
	unlearn ("aimfind")
	unlearn ("aimpars")
	unlearn ("aregpars")
	unlearn ("aslist")
	unlearn ("awcspars")

	# Delete some temporary files.

	delete (tsvlist, verify-)
	delete (tcatlist, verify-)
	svlist = ""
	catlist = ""

        print ("", >> tastlog)
        print ("ASTCAT package tests completed", >> tastlog)
        print ("", >> tastlog)
        print ("")
        print ("ASTCAT package tests completed")
        print ("")

	bye
end