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
|
include "sensfunc.h"
# SF_COMPOSITE -- Create a composite standard structure.
# The composite star is the last of the standard stars.
# When the composite star is created the other stars are turned off.
# The function toggles.
procedure sf_composite (stds, nstds, cv)
pointer stds[nstds] # Standard star data
int nstds # Number of standard stars
pointer cv # Sensitivity pointer
int i, j, k, n, nwaves
pointer std, waves, sens, fit, wts, iwts, x, y, z
errchk malloc, realloc, xt_sort3
begin
# If data is already composite toggle back to original data.
# Delete data points if composite point is deleted.
std = stds[nstds]
if (STD_FLAG(std) == SF_INCLUDE) {
do i = 1, nstds - 2 {
if (STD_FLAG(stds[i]) == SF_EXCLUDE)
next
STD_FLAG(stds[i]) = SF_INCLUDE
}
STD_FLAG(std) = SF_EXCLUDE
n = STD_NWAVES(std)
x = STD_WAVES(std)
z = STD_WTS(std)
do i = 1, n {
if (Memr[z] == 0.) {
do j = 1, nstds - 2 {
if (STD_FLAG(stds[j]) == SF_EXCLUDE)
next
nwaves = STD_NWAVES(stds[j])
waves = STD_WAVES(stds[j])
wts = STD_WTS(stds[j])
do k = 1, nwaves {
if (Memr[waves] == Memr[x])
Memr[wts] = 0.
waves = waves + 1
wts = wts + 1
}
}
}
x = x + 1
z = z + 1
}
call printf ("Individual star data")
return
}
# Initialize
if (STD_WAVES(std) != NULL) {
call mfree (STD_WAVES(std), TY_REAL)
call mfree (STD_SENS(std), TY_REAL)
call mfree (STD_WTS(std), TY_REAL)
call mfree (STD_IWTS(std), TY_REAL)
call mfree (STD_X(std), TY_REAL)
call mfree (STD_Y(std), TY_REAL)
}
# To bin the data we collect all the data and then sort by wavelength.
nwaves = 0
do i = 1, nstds - 2
if (STD_FLAG(stds[i]) == SF_INCLUDE)
nwaves = nwaves + STD_NWAVES(stds[i])
call malloc (waves, nwaves, TY_REAL)
call malloc (sens, nwaves, TY_REAL)
call malloc (wts, nwaves, TY_REAL)
nwaves = 0
do i = 1, nstds - 2 {
if (STD_FLAG(stds[i]) != SF_INCLUDE)
next
n = STD_NWAVES(stds[i])
x = STD_WAVES(stds[i])
y = STD_SENS(stds[i])
z = STD_WTS(stds[i])
do j = 1, n {
if (Memr[z] != 0.) {
Memr[waves+nwaves] = Memr[x]
Memr[sens+nwaves] = Memr[y]
Memr[wts+nwaves] = Memr[z]
nwaves = nwaves + 1
}
x = x + 1
y = y + 1
z = z + 1
}
STD_FLAG(stds[i]) = SF_DELETE
STD_BEAM(std) = STD_BEAM(stds[i])
STD_WSTART(std) = STD_WSTART(stds[i])
STD_WEND(std) = STD_WEND(stds[i])
}
# STD_NWAVES(stds[nstds-1]) = 0
call xt_sort3 (Memr[waves], Memr[sens], Memr[wts], nwaves)
# Go through the wavelength sorted data and composite all points
# with the same wavelength.
n = 0
Memr[sens] = Memr[wts] * Memr[sens]
do i = 1, nwaves-1 {
if (Memr[waves+i] == Memr[waves+n]) {
Memr[sens+n] = Memr[sens+n] + Memr[wts+i] * Memr[sens+i]
Memr[wts+n] = Memr[wts+n] + Memr[wts+i]
} else {
n = n + 1
Memr[waves+n] = Memr[waves+i]
Memr[sens+n] = Memr[wts+i] * Memr[sens+i]
Memr[wts+n] = Memr[wts+i]
}
}
nwaves = n + 1
do i = 0, nwaves-1
Memr[sens+i] = Memr[sens+i] / Memr[wts+i]
# Store the composite data in the standard star structure.
call realloc (waves, nwaves, TY_REAL)
call realloc (sens, nwaves, TY_REAL)
call realloc (wts, nwaves, TY_REAL)
call malloc (iwts, nwaves, TY_REAL)
call malloc (fit, nwaves, TY_REAL)
call malloc (x, nwaves, TY_REAL)
call malloc (y, nwaves, TY_REAL)
call amovr (Memr[wts], Memr[iwts], nwaves)
call cvvector (cv, Memr[waves], Memr[fit], nwaves)
STD_FLAG(std) = SF_INCLUDE
STD_NWAVES(std) = nwaves
STD_WAVES(std) = waves
STD_SENS(std) = sens
STD_FIT(std) = fit
STD_WTS(std) = wts
STD_IWTS(std) = iwts
STD_X(std) = x
STD_Y(std) = y
call printf ("Composite star data")
end
|