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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <imhdr.h>
include "../icombine.h"
$for (sird)
# IC_SIGMA -- Compute the sigma image line.
# The estimated sigma includes a correction for the finite population.
# Weights are used if desired.
procedure ic_sigma$t (d, m, n, wts, w, npts, average, sigma)
pointer d[ARB] # Data pointers
pointer m[ARB] # Image ID pointers
int n[npts] # Number of points
real wts[ARB] # Weights
pointer w[ARB] # Weight data pointers
int npts # Number of output points per line
$if (datatype == sil)
real average[npts] # Average
real sigma[npts] # Sigma line (returned)
$else
PIXEL average[npts] # Average
PIXEL sigma[npts] # Sigma line (returned)
$endif
int i, j, k, n1
real wt, sigcor, sumwt
$if (datatype == sil)
real a, sum
$else
PIXEL a, sum
$endif
include "../icombine.com"
begin
if (dflag == D_ALL && w[1] == NULL) {
n1 = n[1]
if (dowts) {
if (n1 > 1)
sigcor = real (n1) / real (n1 - 1)
else
sigcor = 1.
do i = 1, npts {
k = i - 1
a = average[i]
wt = wts[Memi[m[1]+k]]
sum = (Mem$t[d[1]+k] - a) ** 2 * wt
do j = 2, n1 {
wt = wts[Memi[m[j]+k]]
sum = sum + (Mem$t[d[j]+k] - a) ** 2 * wt
}
sigma[i] = sqrt (sum * sigcor)
}
} else {
if (n1 > 1)
sigcor = 1. / real (n1 - 1)
else
sigcor = 1.
do i = 1, npts {
k = i - 1
a = average[i]
sum = (Mem$t[d[1]+k] - a) ** 2
do j = 2, n1
sum = sum + (Mem$t[d[j]+k] - a) ** 2
sigma[i] = sqrt (sum * sigcor)
}
}
} else if (dflag == D_NONE) {
do i = 1, npts
sigma[i] = blank
} else {
if (dowts) {
if (w[1] == NULL) {
do i = 1, npts {
n1 = n[i]
if (n1 > 0) {
k = i - 1
if (n1 > 1)
sigcor = real (n1) / real (n1 -1)
else
sigcor = 1
a = average[i]
wt = wts[Memi[m[1]+k]]
sum = (Mem$t[d[1]+k] - a) ** 2 * wt
sumwt = wt
do j = 2, n1 {
wt = wts[Memi[m[j]+k]]
sum = sum + (Mem$t[d[j]+k] - a) ** 2 * wt
sumwt = sumwt + wt
}
if (sumwt > 0)
sigma[i] = sqrt (sum / sumwt * sigcor)
else {
sum = (Mem$t[d[1]+k] - a) ** 2
do j = 2, n1
sum = sum + (Mem$t[d[j]+k] - a) ** 2
sigma[i] = sqrt (sum / n1 * sigcor)
}
} else
sigma[i] = blank
}
} else {
do i = 1, npts {
n1 = n[i]
if (n1 > 0) {
k = i - 1
if (n1 > 1)
sigcor = real (n1) / real (n1 -1)
else
sigcor = 1
a = average[i]
wt = Memr[w[Memi[m[1]+k]]+k]
sum = (Mem$t[d[1]+k] - a) ** 2 * wt
sumwt = wt
do j = 2, n1 {
wt = Memr[w[Memi[m[j]+k]]+k]
sum = sum + (Mem$t[d[j]+k] - a) ** 2 * wt
sumwt = sumwt + wt
}
if (sumwt > 0)
sigma[i] = sqrt (sum / sumwt * sigcor)
else {
sum = (Mem$t[d[1]+k] - a) ** 2
do j = 2, n1
sum = sum + (Mem$t[d[j]+k] - a) ** 2
sigma[i] = sqrt (sum / n1 * sigcor)
}
} else
sigma[i] = blank
}
}
} else {
do i = 1, npts {
n1 = n[i]
if (n1 > 0) {
k = i - 1
if (n1 > 1)
sigcor = 1. / real (n1 - 1)
else
sigcor = 1.
a = average[i]
sum = (Mem$t[d[1]+k] - a) ** 2
do j = 2, n1
sum = sum + (Mem$t[d[j]+k] - a) ** 2
sigma[i] = sqrt (sum * sigcor)
} else
sigma[i] = blank
}
}
}
end
$endfor
|