aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/immatch/src/psfmatch/rgptools.x
blob: df36c166e3bf0bf6bfb94de217715e50d1892f67 (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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
include "psfmatch.h"

#  RG_PINIT -- Initialize the main psfmatch data structure. 

procedure rg_pinit (pm, cfunc)

pointer	pm		#O pointer to psfmatch structure
int	cfunc		#I mode of computing the convolution function

begin
	call malloc (pm, LEN_PSFSTRUCT, TY_STRUCT)

	# Initialize the pointers.
	PM_RC1(pm) = NULL
	PM_RC2(pm) = NULL
	PM_RL1(pm) = NULL
	PM_RL2(pm) = NULL
	PM_RZERO(pm) = NULL
	PM_RXSLOPE(pm) = NULL
	PM_RYSLOPE(pm) = NULL
	PM_NREGIONS(pm) = 0
	PM_CNREGION(pm) = 1
		
	# Define the background fitting parameters.
	PM_CENTER(pm) = DEF_CENTER
	PM_BACKGRD(pm) = DEF_BACKGRD
	PM_BVALUER(pm) = 0.0
	PM_BVALUE(pm) = 0.0
	call strcpy ("median", PM_BSTRING(pm), SZ_FNAME)
	PM_LOREJECT(pm) = DEF_LOREJECT
	PM_HIREJECT(pm) = DEF_HIREJECT
	PM_APODIZE(pm) = 0.0

	PM_UFLUXRATIO(pm) = DEF_UFLUXRATIO
	PM_FILTER(pm) = DEF_FILTER
	call strcpy ("replace", PM_FSTRING(pm), SZ_FNAME)
	PM_SXINNER(pm) = DEF_SXINNER
	PM_SXOUTER(pm) = DEF_SXOUTER
	PM_SYINNER(pm) = DEF_SYINNER
	PM_SYOUTER(pm) = DEF_SYOUTER
	PM_RADSYM(pm) = DEF_RADSYM
	PM_THRESHOLD(pm) = DEF_THRESHOLD

	PM_NORMFACTOR(pm) = DEF_NORMFACTOR

	PM_CONVOLUTION(pm) = cfunc
	switch (cfunc) {
	case PM_CONIMAGE:
	    PM_CONVOLUTION(pm) = PM_CONIMAGE
	    call strcpy ("image", PM_CSTRING(pm), SZ_FNAME)
	case PM_CONPSF:
	    PM_CONVOLUTION(pm) = PM_CONPSF
	    call strcpy ("psf", PM_CSTRING(pm), SZ_FNAME)
	case PM_CONKERNEL:
	    PM_CONVOLUTION(pm) = PM_CONKERNEL
	    call strcpy ("kernel", PM_CSTRING(pm), SZ_FNAME)
	default:
	    PM_CONVOLUTION(pm) = PM_CONIMAGE
	    call strcpy ("image", PM_CSTRING(pm), SZ_FNAME)
	}
	PM_DNX(pm) = DEF_DNX
	PM_DNY(pm) = DEF_DNY
	PM_PNX(pm) = DEF_PNX
	PM_PNY(pm) = DEF_PNY
	PM_KNX(pm) = 0
	PM_KNY(pm) = 0
	PM_POWER(pm) = DEF_POWER

	PM_REFFFT(pm) = NULL
	PM_IMFFT(pm) = NULL
	PM_FFT(pm) = NULL
	PM_CONV(pm) = NULL
	PM_ASFFT(pm) = NULL
	PM_NXFFT(pm) = 0
	PM_NYFFT(pm) = 0

	# Initialize the strings.
	PM_IMAGE(pm) = EOS
	PM_REFIMAGE(pm) = EOS
	PM_PSFDATA(pm) = EOS
	PM_PSFIMAGE(pm) = EOS
	PM_OBJLIST(pm) = EOS
	PM_KERNEL(pm) = EOS
	PM_OUTIMAGE(pm) = EOS

	# Initialize the buffers.
	call rg_prinit (pm)
end


#  RG_PRINIT -- Initialize the regions definition portion of the psf matching
# code fitting structure. 

procedure rg_prinit (pm)

pointer	pm		#I pointer to psfmatch structure

begin
	call rg_prfree (pm)

	PM_NREGIONS(pm) = 0
	PM_CNREGION(pm) = 1

	call malloc (PM_RC1(pm), MAX_NREGIONS, TY_INT)
	call malloc (PM_RC2(pm), MAX_NREGIONS, TY_INT)
	call malloc (PM_RL1(pm), MAX_NREGIONS, TY_INT)
	call malloc (PM_RL2(pm), MAX_NREGIONS, TY_INT)
	call malloc (PM_RZERO(pm), MAX_NREGIONS, TY_REAL)
	call malloc (PM_RXSLOPE(pm), MAX_NREGIONS, TY_REAL)
	call malloc (PM_RYSLOPE(pm), MAX_NREGIONS, TY_REAL)

	call amovki (INDEFI, Memi[PM_RC1(pm)], MAX_NREGIONS)
	call amovki (INDEFI, Memi[PM_RC2(pm)], MAX_NREGIONS)
	call amovki (INDEFI, Memi[PM_RL1(pm)], MAX_NREGIONS)
	call amovki (INDEFI, Memi[PM_RL2(pm)], MAX_NREGIONS)
	call amovkr (INDEFR, Memr[PM_RZERO(pm)], MAX_NREGIONS)
	call amovkr (INDEFR, Memr[PM_RXSLOPE(pm)], MAX_NREGIONS)
	call amovkr (INDEFR, Memr[PM_RYSLOPE(pm)], MAX_NREGIONS)
end


# RG_PINDEFR -- Re-initialize the background and answers regions portion of
# the psf-matching structure.

procedure rg_pindefr (pm)

pointer	pm		#I pointer to the psfmatch structure

int	nregions
int	rg_pstati ()

begin
	nregions = rg_pstati (pm, NREGIONS)

	if (nregions > 0) {
	    call amovkr (INDEFR, Memr[PM_RZERO(pm)], nregions)
	    call amovkr (INDEFR, Memr[PM_RXSLOPE(pm)], nregions)
	    call amovkr (INDEFR, Memr[PM_RYSLOPE(pm)], nregions)
	}
end


#  RG_PREALLOC -- Reallocate the regions buffers and initialize if necessary.

procedure rg_prealloc (pm, nregions)

pointer	pm		#I pointer to psfmatch structure
int	nregions	#I number of regions

int	nr
int	rg_pstati()

begin
	nr = rg_pstati (pm, NREGIONS)

	call realloc (PM_RC1(pm), nregions, TY_INT)
	call realloc (PM_RC2(pm), nregions, TY_INT)
	call realloc (PM_RL1(pm), nregions, TY_INT)
	call realloc (PM_RL2(pm), nregions, TY_INT)
	call realloc (PM_RZERO(pm), nregions, TY_REAL)
	call realloc (PM_RXSLOPE(pm), nregions, TY_REAL)
	call realloc (PM_RYSLOPE(pm), nregions, TY_REAL)

	call amovki (INDEFI, Memi[PM_RC1(pm)+nr], nregions - nr)
	call amovki (INDEFI, Memi[PM_RC2(pm)+nr], nregions - nr)
	call amovki (INDEFI, Memi[PM_RL1(pm)+nr], nregions - nr)
	call amovki (INDEFI, Memi[PM_RL2(pm)+nr], nregions - nr)
	call amovkr (INDEFR, Memr[PM_RZERO(pm)+nr], nregions - nr)
	call amovkr (INDEFR, Memr[PM_RXSLOPE(pm)+nr], nregions - nr)
	call amovkr (INDEFR, Memr[PM_RYSLOPE(pm)+nr], nregions - nr)
	#call amovkr (INDEFR, Memr[PM_XSHIFTS(pm)+nr], nregions - nr)
	#call amovkr (INDEFR, Memr[PM_YSHIFTS(pm)+nr], nregions - nr)
end


# RG_PRFREE -- Free the regions portion of the psfmatch structure.

procedure rg_prfree (pm)

pointer	pm		#I/O pointer to psfmatch structure

begin
	call rg_pseti (pm, NREGIONS, 0)
	if (PM_RC1(pm) != NULL)
	    call mfree (PM_RC1(pm), TY_INT)
	PM_RC1(pm) = NULL
	if (PM_RC2(pm) != NULL)
	    call mfree (PM_RC2(pm), TY_INT)
	PM_RC2(pm) = NULL
	if (PM_RL1(pm) != NULL)
	    call mfree (PM_RL1(pm), TY_INT)
	PM_RL1(pm) = NULL
	if (PM_RL2(pm) != NULL)
	    call mfree (PM_RL2(pm), TY_INT)
	PM_RL2(pm) = NULL
	if (PM_RZERO(pm) != NULL)
	    call mfree (PM_RZERO(pm), TY_REAL)
	PM_RZERO(pm) = NULL
	if (PM_RXSLOPE(pm) != NULL)
	    call mfree (PM_RXSLOPE(pm), TY_REAL)
	PM_RXSLOPE(pm) = NULL
	if (PM_RYSLOPE(pm) != NULL)
	    call mfree (PM_RYSLOPE(pm), TY_REAL)
	PM_RYSLOPE(pm) = NULL
end


# RG_PFREE -- Free the psfmatch structure.

procedure rg_pfree (pm)

pointer	pm		#I pointer to psfmatch structure

begin
	# Free the region descriptors
	call rg_prfree (pm)

	if (PM_REFFFT(pm) != NULL)
	    call mfree (PM_REFFFT(pm), TY_REAL)
	if (PM_IMFFT(pm) != NULL)
	    call mfree (PM_IMFFT(pm), TY_REAL)
	if (PM_FFT(pm) != NULL)
	    call mfree (PM_FFT(pm), TY_REAL)
	if (PM_CONV(pm) != NULL)
	    call mfree (PM_CONV(pm), TY_REAL)
	if (PM_ASFFT(pm) != NULL)
	    call mfree (PM_ASFFT(pm), TY_REAL)

	call mfree (pm, TY_STRUCT)
end


# RG_PSTATI -- Fetch the value of a psfmatch task integer parameter.

int procedure rg_pstati (pm, param)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched

begin
	switch (param) {
	case NREGIONS:
	    return (PM_NREGIONS(pm))
	case CNREGION:
	    return (PM_CNREGION(pm))
	case CENTER:
	    return (PM_CENTER(pm))
	case BACKGRD:
	    return (PM_BACKGRD(pm))
	case CONVOLUTION:
	    return (PM_CONVOLUTION(pm))
	case DNX:
	    return (PM_DNX(pm))
	case DNY:
	    return (PM_DNY(pm))
	case PNX:
	    return (PM_PNX(pm))
	case PNY:
	    return (PM_PNY(pm))
	case KNX:
	    return (PM_KNX(pm))
	case KNY:
	    return (PM_KNY(pm))
	case POWER:
	    return (PM_POWER(pm))

	case FILTER:
	    return (PM_FILTER(pm))
	case RADSYM:
	    return (PM_RADSYM(pm))

	case NXFFT:
	    return (PM_NXFFT(pm))
	case NYFFT:
	    return (PM_NYFFT(pm))

	default:
	    call error (0, "RG_PSTATI: Unknown integer parameter.")
	}
end


# RG_PSTATP -- Fetch the value of a psfmatch task pointer parameter.

pointer procedure rg_pstatp (pm, param)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched

begin
	switch (param) {
	case RC1:
	    return (PM_RC1(pm))
	case RC2:
	    return (PM_RC2(pm))
	case RL1:
	    return (PM_RL1(pm))
	case RL2:
	    return (PM_RL2(pm))
	case RZERO:
	    return (PM_RZERO(pm))
	case RXSLOPE:
	    return (PM_RXSLOPE(pm))
	case RYSLOPE:
	    return (PM_RYSLOPE(pm))
	case REFFFT:
	    return (PM_REFFFT(pm))
	case IMFFT:
	    return (PM_IMFFT(pm))
	case FFT:
	    return (PM_FFT(pm))
	case CONV:
	    return (PM_CONV(pm))
	case ASFFT:
	    return (PM_ASFFT(pm))
	default:
	    call error (0, "RG_PSTATP: Unknown pointer parameter.")
	}
end


# RG_PSTATR -- Fetch the value of a psfmath task real parameter.

real procedure rg_pstatr (pm, param)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched

begin
	switch (param) {
	case BVALUER:
	    return (PM_BVALUER(pm))
	case BVALUE:
	    return (PM_BVALUE(pm))
	case APODIZE:
	    return (PM_APODIZE(pm))
	case LOREJECT:
	    return (PM_LOREJECT(pm))
	case HIREJECT:
	    return (PM_HIREJECT(pm))
	case UFLUXRATIO:
	    return (PM_UFLUXRATIO(pm))
	case FLUXRATIO:
	    return (PM_FLUXRATIO(pm))
	case SXINNER:
	    return (PM_SXINNER(pm))
	case SXOUTER:
	    return (PM_SXOUTER(pm))
	case SYINNER:
	    return (PM_SYINNER(pm))
	case SYOUTER:
	    return (PM_SYOUTER(pm))
	case THRESHOLD:
	    return (PM_THRESHOLD(pm))
	case NORMFACTOR:
	    return (PM_NORMFACTOR(pm))
	default:
	    call error (0, "RG_PSTATR: Unknown real parameter.")
	}
end


# RG_PSTATS -- Fetch the value of a psfmatch string string parameter.

procedure rg_pstats (pm, param, str, maxch)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched
char	str[ARB]	# output string
int	maxch		# maximum number of characters

begin
	switch (param) {
	case BSTRING:
	    call strcpy (PM_BSTRING(pm), str, maxch)
	case CSTRING:
	    call strcpy (PM_CSTRING(pm), str, maxch)
	case FSTRING:
	    call strcpy (PM_FSTRING(pm), str, maxch)
	case IMAGE:
	    call strcpy (PM_IMAGE(pm), str, maxch)
	case REFIMAGE:
	    call strcpy (PM_REFIMAGE(pm), str, maxch)
	case PSFDATA:
	    call strcpy (PM_PSFDATA(pm), str, maxch)
	case PSFIMAGE:
	    call strcpy (PM_PSFIMAGE(pm), str, maxch)
	case OBJLIST:
	    call strcpy (PM_OBJLIST(pm), str, maxch)
	case KERNEL:
	    call strcpy (PM_KERNEL(pm), str, maxch)
	case OUTIMAGE:
	    call strcpy (PM_OUTIMAGE(pm), str, maxch)
	default:
	    call error (0, "RG_PSTATS: Unknown string parameter.")
	}
end


# RG_PSETI -- Set the value of a psfmatch task integer parameter.

procedure rg_pseti (pm, param, value)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched
int	value		# value of the integer parameter

begin
	switch (param) {
	case NREGIONS:
	    PM_NREGIONS(pm) = value
	case CNREGION:
	    PM_CNREGION(pm) = value
	case CENTER:
	    PM_CENTER(pm) = value
	case BACKGRD:
	    PM_BACKGRD(pm) = value
	    switch (value) {
	    case PM_BNONE:
		call strcpy ("none", PM_BSTRING(pm), SZ_FNAME)
	    case PM_BMEAN:
		call strcpy ("mean", PM_BSTRING(pm), SZ_FNAME)
	    case PM_BMEDIAN:
		call strcpy ("median", PM_BSTRING(pm), SZ_FNAME)
	    case PM_BSLOPE:
		call strcpy ("plane", PM_BSTRING(pm), SZ_FNAME)
	    case PM_BNUMBER:
		;
	    default:
		call strcpy ("none", PM_BSTRING(pm), SZ_FNAME)
	    }
	case CONVOLUTION:
	    PM_CONVOLUTION(pm) = value
	    switch (value) {
	    case PM_CONIMAGE:
		call strcpy ("image", PM_CSTRING(pm), SZ_FNAME)
	    case PM_CONPSF:
		call strcpy ("psf", PM_CSTRING(pm), SZ_FNAME)
	    case PM_CONKERNEL:
		call strcpy ("kernel", PM_CSTRING(pm), SZ_FNAME)
	    default:
		call strcpy ("image", PM_CSTRING(pm), SZ_FNAME)
	    }
	case DNX:
	    PM_DNX(pm) = value
	case DNY:
	    PM_DNY(pm) = value
	case PNX:
	    PM_PNX(pm) = value
	case PNY:
	    PM_PNY(pm) = value
	case KNX:
	    PM_KNX(pm) = value
	case KNY:
	    PM_KNY(pm) = value
	case POWER:
	    PM_POWER(pm) = value
	case RADSYM:
	    PM_RADSYM(pm) = value
	case NXFFT:
	    PM_NXFFT(pm) = value
	case NYFFT:
	    PM_NYFFT(pm) = value
	case FILTER:
	    PM_FILTER(pm) = value
	    switch (value) {
	    case PM_FNONE:
		call strcpy ("none", PM_FSTRING(pm), SZ_FNAME)
	    case PM_FCOSBELL:
		call strcpy ("cosbell", PM_FSTRING(pm), SZ_FNAME)
	    case PM_FREPLACE:
		call strcpy ("replace", PM_FSTRING(pm), SZ_FNAME)
	    case PM_FMODEL:
		call strcpy ("model", PM_FSTRING(pm), SZ_FNAME)
	    default:
		call strcpy ("none", PM_FSTRING(pm), SZ_FNAME)
	    }
	default:
	    call error (0, "RG_PSETI: Unknown integer parameter.")
	}
end


# RG_PSETP -- Set the value of a psfmatch task  pointer parameter.

procedure rg_psetp (pm, param, value)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched
pointer value		# value of the pointer parameter

begin
	switch (param) {
	case RC1:
	    PM_RC1(pm) = value
	case RC2:
	    PM_RC2(pm) = value
	case RL1:
	    PM_RL1(pm) = value
	case RL2:
	    PM_RL2(pm) = value
	case RZERO:
	    PM_RZERO(pm) = value
	case RXSLOPE:
	    PM_RXSLOPE(pm) = value
	case RYSLOPE:
	    PM_RYSLOPE(pm) = value
	case REFFFT:
	    PM_REFFFT(pm) = value
	case IMFFT:
	    PM_IMFFT(pm) = value
	case FFT:
	    PM_FFT(pm) = value
	case CONV:
	    PM_CONV(pm) = value
	case ASFFT:
	    PM_ASFFT(pm) = value

	default:
	    call error (0, "RG_PSETP: Unknown pointer parameter.")
	}
end


# RG_PSETR -- Set the value of a psfmatch task real parameter.

procedure rg_psetr (pm, param, value)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched
real	value		# real parameter

begin
	switch (param) {
	case BVALUER:
	    PM_BVALUER(pm) = value
	case BVALUE:
	    PM_BVALUE(pm) = value
	case LOREJECT:
	    PM_LOREJECT(pm) = value
	case HIREJECT:
	    PM_HIREJECT(pm) = value
	case APODIZE:
	    PM_APODIZE(pm) = value
	case UFLUXRATIO:
	    PM_UFLUXRATIO(pm) = value
	case FLUXRATIO:
	    PM_FLUXRATIO(pm) = value
	case SXINNER:
	    PM_SXINNER(pm) = value
	case SXOUTER:
	    PM_SXOUTER(pm) = value
	case SYINNER:
	    PM_SYINNER(pm) = value
	case SYOUTER:
	    PM_SYOUTER(pm) = value
	case THRESHOLD:
	    PM_THRESHOLD(pm) = value
	case NORMFACTOR:
	    PM_NORMFACTOR(pm) = value
	default:
	    call error (0, "RG_PSETR: Unknown real parameter.")
	}
end


# RG_PSETS -- Procedure to set the value of a string parameter.

procedure rg_psets (pm, param, str)

pointer	pm		# pointer to psfmatch structure
int	param		# parameter to be fetched
char	str[ARB]	# output string

int	index, ip
pointer	sp, temp
real	rval
int	strdic(), fnldir(), ctor()

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

	switch (param) {
	case BSTRING:
	    ip = 1
 	    index = strdic (str, str, SZ_LINE, PM_BTYPES)
            if (index > 0) {
                call strcpy (str, PM_BSTRING(pm), SZ_FNAME)
                call rg_pseti (pm, BACKGRD, index)
            } else if (ctor (str, ip, rval) > 0) {
		call rg_psetr (pm, BVALUE, rval)
		if (ctor (str, ip, rval) > 0) {
		    call rg_psetr (pm, BVALUER, rval)
                    call strcpy (str, PM_BSTRING(pm), SZ_FNAME)
                    call rg_pseti (pm, BACKGRD, PM_NUMBER)
		} else {
		    call rg_psetr (pm, BVALUE, 0.0)
		    call rg_psetr (pm, BVALUER, 0.0)
		}
	    }
	case CSTRING:
 	    index = strdic (str, str, SZ_LINE, PM_CTYPES)
            if (index > 0) {
                call strcpy (str, PM_CSTRING(pm), SZ_FNAME)
                call rg_pseti (pm, CONVOLUTION, index)
            }
	case FSTRING:
 	    index = strdic (str, str, SZ_LINE, PM_FTYPES)
            if (index > 0) {
                call strcpy (str, PM_FSTRING(pm), SZ_FNAME)
                call rg_pseti (pm, FILTER, index)
            }
	case IMAGE:
	    call imgcluster (str, Memc[temp], SZ_FNAME)
	    index = fnldir (Memc[temp], PM_IMAGE(pm), SZ_FNAME)
	    call strcpy (Memc[temp+index], PM_IMAGE(pm), SZ_FNAME)
	case REFIMAGE:
	    call imgcluster (str, Memc[temp], SZ_FNAME)
	    index = fnldir (Memc[temp], PM_REFIMAGE(pm), SZ_FNAME)
	    call strcpy (Memc[temp+index], PM_REFIMAGE(pm), SZ_FNAME)
	case PSFDATA:
	    call strcpy (str, PM_PSFDATA(pm), SZ_FNAME)
	case PSFIMAGE:
	    call imgcluster (str, Memc[temp], SZ_FNAME)
	    index = fnldir (Memc[temp], PM_PSFIMAGE(pm), SZ_FNAME)
	    call strcpy (Memc[temp+index], PM_PSFIMAGE(pm), SZ_FNAME)
	case OBJLIST:
	    call strcpy (str, PM_OBJLIST(pm), SZ_FNAME)
	case KERNEL:
	    call imgcluster (str, Memc[temp], SZ_FNAME)
	    index = fnldir (Memc[temp], PM_KERNEL(pm), SZ_FNAME)
	    call strcpy (Memc[temp+index], PM_KERNEL(pm), SZ_FNAME)
	case OUTIMAGE:
	    call strcpy (str, PM_OUTIMAGE(pm), SZ_FNAME)
	default:
	    call error (0, "RG_PSETS: Unknown string parameter.")
	}

	call sfree (sp)
end