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
|
include <smw.h>
define CTYPES "|LAMBDA|FREQ|WAVELENGTH|VELO|VELO-LSR|VELO-HEL|VELO-OBS|"
# SMW_DAXIS -- Set physical dispersion axis and summing factors.
# A default value of zero for the dispersion axis will cause the dispersion
# axis to be sought in the image header and, if not found, from the CL
# "dispaxis" parameter. A default value of zero for the summing factors will
# cause them to be queried from the CL "nsum" parameter. A default value of
# INDEFI in either parameter will leave the current default unchanged.
#
# When this procedure is called with an SMW and IMIO pointer the SMW
# pointer is updated to desired default dispersion axis and summing
# parameters.
procedure smw_daxis (smw, im, daxisp, nsum1, nsum2)
pointer smw #I SMW pointer
pointer im #I IMIO pointer
int daxisp #I Default dispersion axis
int nsum1, nsum2 #I Default summing factors
int i, da, ns[2]
int imgeti(), clgeti(), clscan(), nscan(), nowhite(), strdic()
pointer sp, key, val
data da/0/, ns/0,0/
errchk clgeti
begin
# Set defaults.
# A value of 0 will use the image DISPAXIS or query the CL and
# a value of INDEFI will leave the current default unchanged.
if (!IS_INDEFI (daxisp))
da = daxisp
if (!IS_INDEFI (nsum1))
ns[1] = nsum1
if (!IS_INDEFI (nsum2))
ns[2] = nsum2
if (smw == NULL)
return
# This procedure is specific to the NDSPEC format.
if (SMW_FORMAT(smw) != SMW_ND)
return
# Set dispersion axis.
if (da == 0) {
if (im == NULL)
SMW_PAXIS(smw,1) = clgeti ("dispaxis")
else {
iferr (SMW_PAXIS(smw,1) = imgeti (im, "DISPAXIS")) {
SMW_PAXIS(smw,1) = clgeti ("dispaxis")
call smark (sp)
call salloc (key, 8, TY_CHAR)
call salloc (val, SZ_FNAME, TY_CHAR)
do i = 1, 7 {
call sprintf (Memc[key], 8, "CTYPE%d")
call pargi (i)
iferr (call imgstr (im, Memc[key], Memc[val], SZ_FNAME))
break
if (nowhite (Memc[val], Memc[val], SZ_FNAME) > 0) {
call strupr (Memc[val])
if (strdic(Memc[val],Memc[val],SZ_FNAME,CTYPES)>0) {
SMW_PAXIS(smw,1) = i
break
}
}
}
call sfree (sp)
}
if (SMW_PAXIS(smw,1) < 1 || SMW_PAXIS(smw,1) > 7) {
i = SMW_PAXIS(smw,1)
SMW_PAXIS(smw,1) = clgeti ("dispaxis")
call eprintf (
"WARNING: Image header dispersion axis %d invalid. Using axis %d.\n")
call pargi (i)
call pargi (SMW_PAXIS(smw,1))
}
}
} else
SMW_PAXIS(smw,1) = da
# Set summing parameters.
if (ns[1] == 0 || ns[2] == 0) {
if (clscan("nsum") == EOF)
call error (1, "smw_daxis: Error in 'nsum' parameter")
call gargi (i)
if (ns[1] == 0) {
if (nscan() == 1)
SMW_NSUM(smw,1) = max (1, i)
else
call error (1, "smw_daxis: Error in 'nsum' parameter")
} else
SMW_NSUM(smw,1) = ns[1]
call gargi (i)
if (ns[2] == 0) {
if (nscan() == 2)
SMW_NSUM(smw,2) = max (1, i)
else
SMW_NSUM(smw,2) = SMW_NSUM(smw,1)
} else
SMW_NSUM(smw,2) = ns[2]
} else {
SMW_NSUM(smw,1) = ns[1]
SMW_NSUM(smw,2) = ns[2]
}
end
|