aboutsummaryrefslogtreecommitdiff
path: root/noao/rv/rvparam.x
blob: 57c80e4c67d9799e90703728f3bd73ddb50f828f (plain) (blame)
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
include <gset.h>
include <gio.h>
include "rvpackage.h"
include "rvflags.h"
include "rvsample.h"

# RV_PARAM - File containing procedures for updating, unlearning, and 
# displaying the task or associated pset values.  Currrently only the
# FILTERPARS, CONTINPARS, or RVKEYWORDS psets are supported, as is the
# parameter list for the FXCOR task.


# RV_SHOW -- Process the ":show" command.  Optional arguments to
# this command include 'contin|filter|keywords' to show the pset 
# parameters.  The default is to show the current task parameters.

procedure rv_show (rv, fd)

pointer	rv				#I pointer to the RV structure
pointer	fd				#I File descriptor

pointer	sp, cmd

begin
	call smark (sp)
	call salloc (cmd, SZ_LINE, TY_CHAR)

	# Get the command.
	call gargstr (Memc[cmd], SZ_LINE)
	if (Memc[cmd] == EOS) {
            call gdeactivate (RV_GP(rv), AW_CLEAR)
	    call rv_task_show (rv, fd)
            call greactivate (RV_GP(rv), AW_PAUSE)

	} else {
	    # Process the command.
	    switch (Memc[cmd+1]) {
	    case 'f':				# show 'filterpars' pset
                call gdeactivate (RV_GP(rv), AW_CLEAR)
	        call filt_show (rv, fd)
                call greactivate (RV_GP(rv), AW_PAUSE)
	    case 'k':				# show 'rvkeywords' pset
                call gdeactivate (RV_GP(rv), AW_CLEAR)
	        call keyw_show (rv, fd)
                call greactivate (RV_GP(rv), AW_PAUSE)
	    case 'c':				# show 'continpars' pset
                call gdeactivate (RV_GP(rv), AW_CLEAR)
	        call cont_show (rv, fd)
                call greactivate (RV_GP(rv), AW_PAUSE)
	    default:
		call printf (
		    "Choose one of 'contin|filter|keywords'.")
	    }
	}

	call sfree (sp)
end


# RV_TASK_SHOW - Show the current state of all task parameters.

procedure rv_task_show (rv, fd)

pointer	rv			#I RV struct pointer
pointer	fd			#I output fd (usually STDOUT)

pointer	sp, str, str2
bool	itob()
errchk	open

begin
	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)
	call salloc (str2, SZ_LINE, TY_CHAR)

	call fprintf (fd, "%21tFXCOR Current Parameter Settings:\n\n")

	# Print the Current Image Names
	call header_show (rv, fd)

	# Print some parameters
	call fprintf (fd,"\n")
	call fprintf (fd, "Apodize%20t= %f\n")
	    call pargr (RV_APODIZE(rv))
	call fprintf (fd, "Autowrite%20t= %b\n")
	    call pargb (itob(RV_AUTOWRITE(rv)))
	call fprintf (fd, "Autodraw%20t= %b\n")
	    call pargb (itob(RV_AUTODRAW(rv)))
	call fprintf (fd, "Background%20t= %f\n")
	    call pargr (RV_BACKGROUND(rv))
	call fprintf (fd, "Height%20t= %f\n")
	    call pargr (RV_FITHGHT(rv))
	call fprintf (fd, "Width%20t= %f\n")
	    call pargr (RV_FITWIDTH(rv))
	call fprintf (fd, "Imupdate%20t= %b\n")
	    call pargb (itob(RV_IMUPDATE(rv)))
	call fprintf (fd, "Minwidth%20t= %f\n")
	    call pargr (RV_MINWIDTH(rv))
	call fprintf (fd, "Maxwidth%20t= %f\n")
	    call pargr (RV_MAXWIDTH(rv))
	call fprintf (fd, "Peak%20t= %b\n")
	    call pargb (itob(RV_PEAK(rv)))
	call nam_verbose (rv, Memc[str2])
	call fprintf (fd, "Verbose%20t= `%s'\n")
	    call pargstr (Memc[str2])
	call fprintf (fd, "Weights%20t= %f\n")
	    call pargr (RV_WEIGHTS(rv))
	call fprintf (fd, "Window%20t= %f\n")
	    call pargr (RV_WINPAR(rv))
	call fprintf (fd, "Wincenter%20t= %f\n")
	    call pargr (RV_WINCENPAR(rv))

	call fprintf (fd,"\n")
	call rv_make_range_string (RV_OSAMPLE(rv), Memc[str])
	call fprintf (fd,"Object regions selected%25t= '%s'\n")
		call pargstr (Memc[str])
	call rv_make_range_string (RV_RSAMPLE(rv), Memc[str])
	call fprintf (fd,"Temp. regions selected%25t= '%s'\n\n\n")
		call pargstr (Memc[str])

	call sfree (sp)
end


# RV_UNLEARN -- Process the ":unlearn" command.  Optional arguments to
# this command include 'contin|filter|keywords' to reset the pset 
# parameters.  The default is to unlearn the current task parameters.

procedure rv_unlearn (rv)

pointer	rv				#I pointer to the RV structure

pointer	sp, cmd

begin
	call smark (sp)
	call salloc (cmd, SZ_LINE, TY_CHAR)

	# Get the command.
	call gargstr (Memc[cmd], SZ_LINE)
	if (Memc[cmd] == EOS)
	    call rv_task_unlearn (rv)

	else {
	    # Process the command.
	    switch (Memc[cmd+1]) {
	    case 'f':				# unlearn 'filterpars' pset
	        call filt_unlearn (rv)
	    case 'k':				# unlearn 'rvkeywords' pset
	        call keyw_unlearn (rv)
	    case 'c':				# unlearn 'continpars' pset
		call cont_unlearn (rv)
	    default:
   		call printf (
		    "Choose one of 'contin|filter|keywords'.")
	    }
	}

	call sfree (sp)
end


# RV_TASK_UNLEARN - Reset the parameter values to their defaults.

procedure rv_task_unlearn (rv)

pointer	rv			# RV struct pointer

begin
	RV_APODIZE(rv) = 0.2
	RV_AUTOWRITE(rv) = YES
	RV_AUTODRAW(rv) = YES
	RV_BACKGROUND(rv) = 0.0
	RV_CCFTYPE(rv) = OUTPUT_IMAGE
	RV_CONTINUUM(rv) = BOTH
	RV_FILTER(rv) = NONE
	RV_FITFUNC(rv) = GAUSSIAN
	RV_FITHGHT(rv) = 0.0
	RV_FITWIDTH(rv) = INDEF
	RV_IMUPDATE(rv) = NO
	RV_INTERACTIVE(rv) = YES
	RV_MINWIDTH(rv) = 3.
	RV_MAXWIDTH(rv) = 21.
	RV_PEAK(rv) = NO
	RV_REBIN(rv) = RB_SMALL
	ORCOUNT(rv) = ALL_SPECTRUM
	RRCOUNT(rv) = ALL_SPECTRUM
	RV_VERBOSE(rv) = OF_LONG
	RV_WEIGHTS(rv) = 1
	RV_WINDOW(rv) = 20
	RV_WINCENPAR(rv) = INDEFI
end


# RV_UPDATE -- Process the ":update" command.  Optional arguments to
# this command include 'contin|filter|keywords' to reset the pset 
# parameters.  The default is to update the current task parameters.

procedure rv_update (rv)

pointer	rv				#I pointer to the RV structure

pointer	sp, cmd

begin
	call smark (sp)
	call salloc (cmd, SZ_LINE, TY_CHAR)

	# Get the command.
	call gargstr (Memc[cmd], SZ_LINE)
	if (Memc[cmd] == EOS)
	    call rv_task_parupdate (rv)

	else {
	    # Process the command.
	    switch (Memc[cmd+1]) {
	    case 'f':				# update 'filterpars' pset
	        call filt_parupdate (rv)
	    case 'k':				# update 'rvkeywords' pset
	        call keyw_parupdate (rv)
	    case 'c':				# update 'continpars' pset
	        call cont_parupdate (rv)
	    default:
		call printf (
		    "Choose one of 'contin|filter|keywords'.")
	    }
	}

	call sfree (sp)
end


# RV_TASK_PARUPDATE - Update the parameter file with the current values in the
# structure.

procedure rv_task_parupdate (rv)

pointer	rv				#I RV struct pointer

pointer	sp, str, func, vb, rb
pointer	filt, cont, ap
bool	itob()

begin
	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)
	call salloc (cont, SZ_FNAME, TY_CHAR)
	call salloc (filt, SZ_FNAME, TY_CHAR)
	call salloc (func, SZ_FNAME, TY_CHAR)
	call salloc (ap, SZ_FNAME, TY_CHAR)
	call salloc (vb, SZ_FNAME, TY_CHAR)
	call salloc (rb, SZ_FNAME, TY_CHAR)

	iferr {
	    call clputr ("apodize", RV_APODIZE(rv))
	    call clputb ("autowrite", itob(RV_AUTOWRITE(rv)))
	    call clputb ("autodraw", itob(RV_AUTODRAW(rv)))
	    call clputr ("background", RV_BACKGROUND(rv))
	    call clputr ("height", RV_FITHGHT(rv))
	    call clputr ("width", RV_FITWIDTH(rv))
	    call clputb ("imupdate", itob(RV_IMUPDATE(rv)))
	    call clputr ("minwidth", RV_MINWIDTH(rv))
	    call clputr ("maxwidth", RV_MAXWIDTH(rv))
	    call clputb ("peak", itob(RV_PEAK(rv)))
	    call clputr ("weights", RV_WEIGHTS(rv))
	    call clputr ("window", RV_WINPAR(rv))
	    call clputr ("wincenter", RV_WINCENPAR(rv))

	    call rv_make_range_string (RV_OSAMPLE(rv), Memc[str])
	    call clpstr ("osample", Memc[str])
	    call rv_make_range_string (RV_RSAMPLE(rv), Memc[str])
	    call clpstr ("rsample", Memc[str])

	    call nam_verbose (rv, Memc[vb])
	    call clpstr ("verbose", Memc[vb])

	    call nam_fitfunc (rv, Memc[func])
	    call clpstr ("function", "gaussian")   

	    call nam_which (RV_CONTINUUM(rv), Memc[cont])
	    call clpstr ("continuum", Memc[cont])

	    call nam_rebin (rv, Memc[rb])
	    call clpstr ("rebin", Memc[rb])

	    call nam_which (RV_FILTER(rv), Memc[filt])
	    call clpstr ("filter", Memc[filt])

	    call nam_fitfunc (rv, Memc[func])
	    call clpstr ("function", Memc[func])

	    if (RV_CCFTYPE(rv) == OUTPUT_IMAGE)
	        call clpstr ("ccftype", "image")
	    else
	        call clpstr ("ccftype", "text")

	} then {
	    call sfree (sp)
	    call error (0, "Error updating parameters.")
	}

	call sfree (sp)
end


# HEADER_SHOW - show the current state of all parameters in the common
# header.

procedure header_show (rv, fd)

pointer	rv			#I RV struct pointer
int	fd			#I output file descriptor (usually STDOUT)

bool	streq()

begin
	# Print the Current Image Names
	call fprintf (fd,"Current Object Image%25t= '%.10s'\n")
		call pargstr (IMAGE(rv))
	call fprintf (fd,"Reference Image%25t= '%.10s'\n")
		call pargstr (RIMAGE(rv))
	call fprintf (fd,"Spool root Name%25t= '%.10s'\n")
		if (streq(SPOOL(rv),""))
		    call pargstr ("          ")
		else
		    call pargstr (SPOOL(rv))    
	call fprintf (fd,"Fitting Function%25t= %s\n")
	    	if (RV_FITFUNC(rv) == GAUSSIAN)
		    call pargstr ("'gaussian'")
	    	else if (RV_FITFUNC(rv) == LORENTZIAN)
		    call pargstr ("'lorentzian'")
	    	else	
		    call pargstr ("'parabola'")
end