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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
include "rvpackage.h"
include "rvflags.h"
include "rvcomdef.h"
include "rvfilter.h"
.help filtpars
.nf ___________________________________________________________________________
FILTPARS - Support routines for the 'filtpars' named external pset.
This file include routines for opening/closing the filter structure
as well as command handling. Command handling is limited to changing the
parameter values or resetting them to the default values. Routines included
here are as follows.
filt_open (rv)
filt_close (rv)
filt_get_pars (rv)
filt_parupdate (rv)
filt_unlearn (rv)
filt_show (rv, fd)
filt_colon (rv, cmdstr)
cmd_filttype (rv)
cmd_cuton (rv)
cmd_cutoff (rv)
cmd_fullon (rv)
cmd_fulloff (rv)
The 'cmd_' prefix indicates that the routine is called from a colon
command to either print the current value or set the new value for that
field. Other routines should be self-explanatory
.endhelp _____________________________________________________________________
# Default values for the FILTERPARS pset
define DEF_FILT_TYPE RAMP # Filter type
define DEF_CUTON 0 # Filter cuton component no.
define DEF_CUTOFF 0 # Filter cutoff component no.
define DEF_FULLON 0 # Filter fullon component no.
define DEF_FULLOFF 0 # Filter fulloff component no.
# FILT_OPEN - Open the Process parameters substructure. This is used to
# reduce the size of the already over-burdened main RV struct.
procedure filt_open (rv)
pointer rv #I RV struct pointer
pointer filt
begin
iferr (call calloc (filt, SZ_FILTSTRUCT, TY_STRUCT))
call error (0, "Error allocating sub-structure RV_FILTP.")
RV_FILTP(rv) = filt
# Initlialize the values
call filt_get_pars (rv) # set to defaults
end
# FILT_CLOSE - Close the process structure.
procedure filt_close (rv)
pointer rv #I RV struct pointer
begin
call mfree (RV_FILTP(rv), TY_STRUCT)
end
# FILT_GET_PARS - Read the filter pset into the struct.
procedure filt_get_pars (rv)
pointer rv #U RV struct pointer
pointer fp, clopset()
char buffer[SZ_FNAME]
int clgpseti(), cod_filttype()
errchk clopset
begin
fp = clopset ("filtpars")
RVF_CUTON(rv) = clgpseti (fp, "cuton")
RVF_CUTOFF(rv) = clgpseti (fp, "cutoff")
RVF_FULLON(rv) = clgpseti (fp, "fullon")
RVF_FULLOFF(rv) = clgpseti (fp, "fulloff")
call clgpset (fp, "f_type", buffer, SZ_LINE)
RVF_FILTTYPE(rv) = cod_filttype (buffer)
RVF_LASTKEY(rv) = 'p' # plot power spec. by default
call clcpset (fp)
end
# FILT_PARUPDATE - Update the parameter file with the current values in the
# filter structure.
procedure filt_parupdate (rv)
pointer rv #I RV struct pointer
pointer sp, bp
pointer fp, clopset()
begin
call smark (sp)
call salloc (bp, SZ_LINE, TY_CHAR)
# Update filter params
fp = clopset ("filtpars")
call clppseti (fp, "cuton", RVF_CUTON(rv))
call clppseti (fp, "cutoff", RVF_CUTOFF(rv))
call clppseti (fp, "fullon", RVF_FULLON(rv))
call clppseti (fp, "fulloff", RVF_FULLOFF(rv))
call nam_filttype (rv, Memc[bp])
call clppset (fp, "f_type", Memc[bp])
call clcpset (fp)
call sfree (sp)
end
# FILT_UNLEARN -- Reset all of the filter parameters to their default values.
procedure filt_unlearn (rv)
pointer rv #I RV struct pointer
begin
RVF_FILTTYPE(rv) = DEF_FILT_TYPE # RAMP
RVF_CUTON(rv) = DEF_CUTON # 0
RVF_CUTOFF(rv) = DEF_CUTOFF # 0
RVF_FULLON(rv) = DEF_FULLON # 0
RVF_FULLOFF(rv) = DEF_FULLOFF # 0
RVF_LASTKEY(rv) = 'f'
end
# FILT_SHOW - Show the current filter parameters.
procedure filt_show (rv, fd)
pointer rv #I RV struct pointer
pointer fd #I output file descriptor
pointer sp, bp
begin
if (fd == NULL)
return
call smark (sp)
call salloc (bp, SZ_LINE, TY_CHAR)
call fprintf (fd, "%6tFilterpars PSET Values\n")
call fprintf (fd, "%6t----------------------\n\n")
# Print the filter info
call fprintf (fd, "Cuton %25t= %-10d\n")
call pargi (RVF_CUTON(rv))
call fprintf (fd, "Cutoff %25t= %-10d\n")
call pargi (RVF_CUTOFF(rv))
call fprintf (fd, "Fullon %25t= %-10d\n")
call pargi (RVF_FULLON(rv))
call fprintf (fd, "Fulloff %25t= %-10d\n")
call pargi (RVF_FULLOFF(rv))
call nam_filttype (rv, Memc[bp])
call fprintf (fd, "Filter type %25t= '%-.10s'\n")
call pargstr (Memc[bp])
call fprintf (fd, "\n\n")
call sfree (sp)
end
# FILT_COLON -- Process the FILTERPARS task colon commands.
procedure filt_colon (rv, cmdstr)
pointer rv #I pointer to the RV structure
char cmdstr[SZ_LINE] #I command string
pointer sp, cmd, buf
int strdic()
begin
call smark (sp)
call salloc (cmd, SZ_LINE, TY_CHAR)
call salloc (buf, SZ_LINE, TY_CHAR)
call sscan (cmdstr)
call gargwrd (Memc[cmd], SZ_LINE)
# Unpack the keyword from the string and look it up in the
# dictionary. Switch on command and call the appropriate routines.
switch (strdic(Memc[cmd], Memc[cmd], SZ_FNAME, FILT_KEYWORDS)) {
case FILT_FILT_TYPE:
# Function type of filter
call cmd_filttype (rv)
case FILT_CUTON:
# Cuton frequency component
call cmd_cuton (rv)
case FILT_CUTOFF:
# Cutoff frequency component
call cmd_cutoff (rv)
case FILT_FULLON:
# Fullon frequency component
call cmd_fullon (rv)
case FILT_FULLOFF:
# Fulloff frequency component
call cmd_fulloff (rv)
}
call sfree (sp)
end
# CMD_CUTOFF - Set/Show the cutoff wavenumber for the filter.
procedure cmd_cutoff (rv)
pointer rv
int ival, nscan()
begin
call gargi (ival)
if (nscan() == 2) {
RVF_CUTOFF(rv) = ival
if (RV_AUTODRAW(rv) == YES && RV_FILTER(rv) != NONE)
RV_NEWGRAPH(rv) = YES
} else {
call printf ("filtpars.cutoff = %d")
call pargi (RVF_CUTOFF(rv))
}
end
# CMD_CUTON - Set/Show the cuton wavenumber for the filter.
procedure cmd_cuton (rv)
pointer rv
int ival, nscan()
begin
call gargi(ival)
if (nscan() == 2) {
RVF_CUTON(rv) = ival
if (RV_AUTODRAW(rv) == YES && RV_FILTER(rv) != NONE)
RV_NEWGRAPH(rv) = YES
} else {
call printf ("filtpars.cuton = %d")
call pargi (RVF_CUTON(rv))
}
end
# CMD_FILTTYPE - Set the type of filter to be used in FFT correlation.
procedure cmd_filttype (rv)
pointer rv
pointer sp, buf, bp
int cod_filttype()
begin
call smark (sp)
call salloc (buf, SZ_LINE, TY_CHAR)
call salloc (bp, SZ_LINE, TY_CHAR)
call gargstr (Memc[buf], SZ_FNAME)
if (Memc[buf] != EOS) {
RVF_FILTTYPE(rv) = cod_filttype (Memc[buf+1])
if (RV_AUTODRAW(rv) == YES && RV_FILTER(rv) != NONE)
RV_NEWGRAPH(rv) = YES
} else {
call nam_filttype (rv, Memc[bp])
call printf ("filtpars.filttype = '%s'")
call pargstr (Memc[bp])
}
call sfree (sp)
end
# CMD_FULLOFF - Set/Show the wavenumber at which the filter falls to zero.
procedure cmd_fulloff (rv)
pointer rv
int ival, nscan()
begin
call gargi (ival)
if (nscan() == 2) {
RVF_FULLOFF(rv) = ival
if (RV_AUTODRAW(rv) == YES && RV_FILTER(rv) != NONE)
RV_NEWGRAPH(rv) = YES
} else {
call printf ("filtpars.fulloff = %d")
call pargi (RVF_FULLOFF(rv))
}
end
# CMD_FULLON - Set/Show the wavenumber at which the filter reaches full value.
procedure cmd_fullon (rv)
pointer rv
int ival, nscan()
begin
call gargi (ival)
if (nscan() == 2) {
RVF_FULLON(rv) = ival
if (RV_AUTODRAW(rv) == YES && RV_FILTER(rv) != NONE)
RV_NEWGRAPH(rv) = YES
} else {
call printf ("filtpars.fullon = %d")
call pargi (RVF_FULLON(rv))
}
end
|