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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
include <gset.h>
include "rvpackage.h"
include "rvflags.h"
include "rvcomdef.h"
include "rvkeywords.h"
include "rvsample.h"
# RVUTIL.X -- Catch-all file that contains various and sundry utility routines
# used throughout the package.
# DEX - Raise 'cv' to a power of ten (10)
double procedure dex (cv)
real cv
double ln10, dx
begin
ln10 = 2.30258509299404d0
if ((cv*ln10) > 512) {
call rv_errmsg ("dex(): cv = %f")
call pargr (cv)
call flush (STDERR)
call error (0, "Floating overflow would have been tripped.")
}
dx = exp (cv * ln10)
return (dx)
end
# RV_AVGPIX - Find average pixel value in an array
real procedure rv_avgpix (data, npts)
real data[npts] #I data array
int npts #I No. points in array
real avg
double sum
int i
begin
sum = 0.0
do i = 1, npts
sum = sum + double (data[i])
avg = real (sum / double (npts))
return ( avg )
end
# RV_CUT - Mark a regions of the spectrum to be used in the correlation.
# Appends to the current regions string
procedure rv_cut (rv, x, sx, ex)
pointer rv #I RV struct pointer
real x #I Current cursor x position
real sx #O Start x position
real ex #O End x position
double dex()
real sregion, eregion, yp
begin
sregion = x # get endpoints
call rv_getpts (rv, eregion, yp, 1)
if (RV_PIXCORR(rv) == NO && RV_DCFLAG(rv) != -1) {
call rv_fixx (sregion, eregion, real(dex(RV_GLOB_W1(rv))),
real(dex(RV_GLOB_W2(rv))))
} else {
call rv_fixx (sregion, eregion, RV_GLOB_W1(rv), RV_GLOB_W2(rv))
}
sx = sregion
ex = eregion
end
# RV_FILL_BLANKS - Given an input string, substitue blanks with an underscore.
procedure rv_fill_blanks (in, out, maxch)
char in[maxch], out[maxch]
int maxch
int i
begin
i = 1
while (in[i] != EOS && i != maxch) {
if (in[i] == ' ')
out[i] = '_'
else
out[i] = in[i]
i = i + 1
}
out[i] = EOS
end
# RV_FIXX - Check for bounds on x's.
procedure rv_fixx (x1, x2, lx1, rx2)
real x1 #U 'left' x cursor
real x2 #U 'right' x cursor
real lx1 #I min allowed x point
real rx2 #I max allowed x point
real temp
begin
if (x2 < x1) { # Swap 'em
temp = min (x2, rx2)
x2 = max (x1, lx1)
x1 = temp
}
end
# RV_GETPTS - Read cursor to get another point.
procedure rv_getpts (rv, x, y, owcs)
pointer rv #I RV struct pointer
real x, y #I Cursor coords
int owcs #I Output wcs of coords
int wcs, key, stat
char command[SZ_FNAME]
int clgcur()
begin
call printf ("again: ")
stat = clgcur ("cursor", x, y, wcs, key, command, SZ_LINE)
if (owcs != wcs)
call gctran (RV_GP(rv), x, y, x, y, wcs, owcs)
call printf (" \n")
end
# RV_GETSHIFT - Find an extreme in the data array of type indicated and
# return the index in the array.
int procedure rv_getshift (data, npts, type)
real data[npts] #I data array
int npts #I No. points in array
int type #I type of extreme to find
int i, imax, imin
real max, min
begin
if (type == MAXIMUM) {
max = data[1]
imax = 1
do i = 2,npts {
if (data[i] > max) {
max = data[i]
imax = i
}
}
return (imax)
} else {
min = data[1]
imin = 1
do i = 2,npts {
if (data[i] < min) {
min = data[i]
imin = i
}
}
return (imin)
}
end
# RV_MAXPIX - Find maximum pixel value in an array
real procedure rv_maxpix (data, npts)
real data[npts] #I data array
int npts #I No. points in array
real max
int i
begin
max = data[1]
do i = 2,npts
if (data[i] > max)
max = data[i]
return (max)
end
# RV_MINPIX - Find minimum pixel value in an array
real procedure rv_minpix (data, npts)
real data[npts] #I data array
int npts #I No. points in array
real min
int i
begin
min = data[1]
do i = 2,npts
if (data[i] < min)
min = data[i]
return (min)
end
# RV_PAUSE - Print a string and await any key for an action.
procedure rv_pause (str)
char str[ARB]
real x, y
int wcs, key, stat
char command[SZ_FNAME]
int clgcur()
begin
call printf ("%s")
call pargstr (str)
call flush (STDOUT)
stat = clgcur ("cursor", x, y, wcs, key, command, SZ_FNAME)
if ('I' == key)
call error (0, "Quitting")
return
end
# RV_PRSHIFT - Use the cursor to print the difference in pixels.
procedure rv_prshift (rv, xpos)
pointer rv #I RV struct pointer
real xpos #I 1st x position
real xpos2, y, shift, pix_shift
double rv_shift2vel()
begin
call rv_getpts(rv, xpos2, y, 1)
shift = xpos2 - xpos
pix_shift = (log10(xpos2) - log10(xpos)) / RV_OWPC(rv)
call rv_mode_prompt (rv)
if (RV_DCFLAG(rv) != -1) {
call printf (" Difference = %.2f Km/sec (~%d pix) (~%.3f A)\n")
call pargd (rv_shift2vel(rv,pix_shift))
call pargi (int(pix_shift))
call pargr (shift)
} else {
call printf (" Difference = %.2f pixels.\n")
call pargr (pix_shift)
}
end
|