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 <mach.h>
include <imhdr.h>
include <fset.h>
include "vt.h"
define WDSBRSTR 50
# READSS1 -- Read a type 1 sector scan from tape and format into 3 iraf images.
# Type one sector scans consist of three images packed into 32 bits per
# pixel. The three images are 1. velocity (12 bits) 2. select (12 bits) and
# 3. continuum intensity (8 bits). The images are only 256 pixels high as
# opposed to 512 pixels high for the other scans.
procedure readss1 (inputfd, filenumber, brief, select, bright, velocity, hs)
int inputfd # file descriptor for input (usually tape)
int filenumber # file number on tape
bool brief # short output file names
bool select # flag to make select image
bool bright # flag to make bright image
bool velocity # flag to make velocity image
int hs # header data structure pointer
char velimage[SZ_FNAME] # Velocity image
char selimage[SZ_FNAME] # Select image
char britimage[SZ_FNAME] # Brightness image
short u[SWTH_HIGH], dat
int date, hour, minute, seconds, i, j, num, lrs
pointer velim, selim, britim, velsrp, selsrp, britsrp
int read()
pointer immap(), impl2s()
errchk immap, impl2s
begin
# Calculate the time. Assemble the output image names.
hour = int(VT_HTIME(hs)/3600)
minute = int((VT_HTIME(hs) - hour * 3600)/60)
seconds = int(VT_HTIME(hs) - hour * 3600 - minute * 60)
if (brief) {
call sprintf (velimage[1], SZ_FNAME, "v%03d")
call pargi (filenumber)
call sprintf (selimage[1], SZ_FNAME, "s%03d")
call pargi (filenumber)
call sprintf (britimage[1], SZ_FNAME, "b%03d")
call pargi (filenumber)
} else {
call sprintf (velimage[1], SZ_FNAME, "v%02d_%02d%02d_%03d")
call pargi (VT_HDAY(hs)) # day of month
call pargi (hour)
call pargi (minute)
call pargi (filenumber)
call sprintf (selimage[1], SZ_FNAME, "s%02d_%02d%02d_%03d")
call pargi (VT_HDAY(hs)) # day of month
call pargi (hour)
call pargi (minute)
call pargi (filenumber)
call sprintf (britimage[1], SZ_FNAME, "b%02d_%02d%02d_%03d")
call pargi (VT_HDAY(hs)) # day of month
call pargi (hour)
call pargi (minute)
call pargi (filenumber)
}
if (select) {
selim = immap (selimage, NEW_IMAGE, 0)
IM_NDIM(selim) = 2
IM_LEN(selim,1) = SWTH_HIGH/2
IM_LEN(selim,2) = VT_HNUMCOLS(hs)
IM_PIXTYPE(selim) = TY_SHORT
call imaddi (selim, "obs_time", VT_HTIME(hs))
date = VT_HMONTH(hs) * 10000 + VT_HDAY(hs) * 100 + VT_HYEAR(hs)
call imaddi (selim, "obs_date", date )
call imaddi (selim, "wv_lngth", VT_HWVLNGTH(hs))
call imaddi (selim, "obs_type", VT_HOBSTYPE(hs))
call imaddi (selim, "av_intns", VT_HAVINTENS(hs))
call imaddi (selim, "num_cols", VT_HNUMCOLS(hs))
call imaddi (selim, "intg/pix", VT_HINTGPIX(hs))
call imaddi (selim, "rep_time", VT_HREPTIME(hs))
}
if (bright) {
britim = immap (britimage, NEW_IMAGE, 0)
IM_NDIM(britim) = 2
IM_LEN(britim,1) = SWTH_HIGH/2
IM_LEN(britim,2) = VT_HNUMCOLS(hs)
IM_PIXTYPE(britim) = TY_SHORT
call imaddi (britim, "obs_time", VT_HTIME(hs))
date = VT_HMONTH(hs) * 10000 + VT_HDAY(hs) * 100 + VT_HYEAR(hs)
call imaddi (britim, "obs_date", date )
call imaddi (britim, "wv_lngth", VT_HWVLNGTH(hs))
call imaddi (britim, "obs_type", VT_HOBSTYPE(hs))
call imaddi (britim, "av_intns", VT_HAVINTENS(hs))
call imaddi (britim, "num_cols", VT_HNUMCOLS(hs))
call imaddi (britim, "intg/pix", VT_HINTGPIX(hs))
call imaddi (britim, "rep_time", VT_HREPTIME(hs))
}
if (velocity) {
velim = immap (velimage, NEW_IMAGE, 0)
IM_NDIM(velim) = 2
IM_LEN(velim,1) = SWTH_HIGH/2
IM_LEN(velim,2) = VT_HNUMCOLS(hs)
IM_PIXTYPE(velim) = TY_SHORT
call imaddi (velim, "obs_time", VT_HTIME(hs))
date = VT_HMONTH(hs) * 10000 + VT_HDAY(hs) * 100 + VT_HYEAR(hs)
call imaddi (velim, "obs_date", date )
call imaddi (velim, "wv_lngth", VT_HWVLNGTH(hs))
call imaddi (velim, "obs_type", VT_HOBSTYPE(hs))
call imaddi (velim, "av_intns", VT_HAVINTENS(hs))
call imaddi (velim, "num_cols", VT_HNUMCOLS(hs))
call imaddi (velim, "intg/pix", VT_HINTGPIX(hs))
call imaddi (velim, "rep_time", VT_HREPTIME(hs))
}
do j = 1, VT_HNUMCOLS(hs) {
if (select)
selsrp = impl2s (selim, j)
if (bright)
britsrp = impl2s (britim, j)
if (velocity)
velsrp = impl2s (velim, j)
iferr (num = read (inputfd, u, SWTH_HIGH*SZB_SHORT/SZB_CHAR)) {
call fseti (inputfd, F_VALIDATE, lrs*SZB_SHORT/SZB_CHAR)
call eprintf ("Error on tape read.\n")
num = read (inputfd, u, SWTH_HIGH*SZB_SHORT/SZB_CHAR)
}
lrs = num
if (num < SWTH_HIGH*SZB_SHORT/SZB_CHAR)
call error (0, "eof encountered when reading file")
if (BYTE_SWAP2 == YES)
call bswap2 (u, 1, u, 1, SWTH_HIGH * SZB_SHORT)
# Unpack the data into the three arrays.
do i = 257, 512 {
if (select) {
dat = u[i]/16
if (u[i] < 0)
dat = dat - 1
Mems[selsrp+i-257] = dat
}
if (bright)
Mems[britsrp+i-257] = and(int(u[i]),17B)*16
}
do i = 1, 256 {
if (velocity) {
dat = u[i]/16
if (u[i] < 0)
dat = dat - 1
Mems[velsrp+i-1] = dat
}
if (bright)
Mems[britsrp+i-1] = Mems[britsrp+i-1]+and(int(u[i]),17B)
}
}
# Unmap images.
if (select)
call imunmap (selim)
if (velocity)
call imunmap (velim)
if (bright)
call imunmap (britim)
end
|