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
|
include <error.h>
include <imhdr.h>
include <fset.h>
include <smw.h>
# SLIST1D -- Lists header information from IIDS/IRS format header
# This is the original T_SLIST.
procedure t_slist1d ()
int root
int long_header
pointer sp, image, im, mw, sh, ptr
int i, nl, df, sm, qf, qd, bs, co
int btoi(), imtgetim(), imgeti()
bool clgetb()
pointer imtopenp(), immap(), smw_openim()
errchk immap, smw_openim, shdr_open
begin
call smark (sp)
call salloc (image, SZ_LINE, TY_CHAR)
# Parameters
root = imtopenp ("input")
call clgstr ("records", Memc[image], SZ_LINE)
call odr_openp (root, Memc[image])
long_header = btoi (clgetb ("long_header"))
# Initialize
call fseti (STDOUT, F_FLUSHNL, YES)
# Loop over all input images by subsets
while (imtgetim (root, Memc[image], SZ_FNAME) != EOF) {
# Open image
iferr {
im = NULL
mw = NULL
ptr = immap (Memc[image], READ_ONLY, 0); im = ptr
ptr = smw_openim (im); mw = ptr
call shdr_open (im, mw, 1, 1, INDEFI, SHHDR, sh)
} then {
if (mw != NULL) {
call smw_close (mw)
if (sh != NULL)
MW(sh) = NULL
}
if (im != NULL)
call imunmap (im)
call erract (EA_WARN)
next
}
nl = IM_LEN(im,2)
do i = 1, nl {
call shdr_open (im, mw, i, 1, INDEFI, SHHDR, sh)
if (long_header == YES) {
call printf ("[%s] %4dpts %s\n")
call pargstr (IMNAME(sh))
call pargi (SN(sh))
call pargstr (TITLE(sh))
if (OFLAG(sh) == 1) {
call printf ("oflag = OBJECT, beam_number = %d")
call pargi (BEAM(sh))
} else if (OFLAG (sh) == 0) {
call printf ("oflag = SKY, beam_number = %d")
call pargi (BEAM(sh))
}
call printf (",\n")
iferr (df = imgeti (im, "DF-FLAG"))
df = -1
iferr (sm = imgeti (im, "SM-FLAG"))
sm = -1
iferr (qf = imgeti (im, "QF-FLAG"))
qf = -1
iferr (qd = imgeti (im, "QD-FLAG"))
qd = -1
iferr (bs = imgeti (im, "BS-FLAG"))
bs = -1
iferr (co = imgeti (im, "CO-FLAG"))
co = -1
# Airmass may not be in header. It could be computed if
# if the observatory latitude were available.
call printf ("airmass = %5.3f,%25tW0 = %0.3f,")
call pargr (AM(sh))
call pargr (W0(sh))
call printf (" WPC = %0.5g, ITM = %.2f,\n")
call pargr (WP(sh))
call pargr (IT(sh))
call printf ("NP1 = %d, NP2 = %d,")
call pargi (NP1(sh))
call pargi (NP2(sh))
call printf (" UT = %0.1h, ST = %0.1h,\n")
call pargr (UT(sh))
call pargr (ST(sh))
call printf ("HA = %0.2h,")
call pargr (HA(sh))
call printf (" RA = %0.2h, DEC = %0.1h,\n")
call pargr (RA(sh))
call pargr (DEC(sh))
call printf (
"df = %d, sm = %d, qf = %d, dc = %d, qd = %d, ")
call pargi (df)
call pargi (sm)
call pargi (qf)
call pargi (DC(sh))
call pargi (qd)
call printf ("ex = %d, bs = %d, ca = %d, co = %d")
call pargi (EC(sh))
call pargi (bs)
call pargi (FC(sh))
call pargi (co)
call printf ("\n\n")
} else {
if (nl == 1) {
call printf ("[%s]:%s %4ds %4dpts %s\n")
call pargstr (IMNAME(sh))
if (OFLAG(sh) == 1)
call pargstr ("o")
else
call pargstr ("s")
call pargr (IT(sh))
call pargi (SN(sh))
call pargstr (TITLE(sh))
} else {
call printf ("[%s]:%s %6.2fs %4dpts %dspectra %s\n")
call pargstr (IMNAME(sh))
if (OFLAG(sh) == 1)
call pargstr ("o")
else
call pargstr ("s")
call pargr (IT(sh))
call pargi (SN(sh))
call pargi (nl)
call pargstr (TITLE(sh))
}
break
}
}
call smw_close (mw)
if (sh != NULL)
MW(sh) = NULL
call imunmap (im)
}
# Null out record string to avoid learn mode
call clpstr ("records", "")
# Free space
call shdr_close (sh)
call imtclose (root)
call sfree (sp)
end
|