aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/odcombine/srcwt/ichdr.x
blob: 2d19c5bd98b6f5e6e6b2bd3f5f9be2faaf0fbb11 (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
include	<imset.h>


# IC_HDR -- Set output header.

procedure ic_hdr (in, out, nimages)

pointer	in[nimages]		#I Input images
pointer	out[ARB]		#I Output images
int	nimages			#I Number of images

int	i, imgnfn()
pointer	sp, key, str, list, imofnlu()

begin
	call smark (sp)
	call salloc (key, SZ_LINE, TY_CHAR)
	call salloc (str, SZ_FNAME, TY_CHAR)

	# Set new PROCID.
	call xt_procid (out)

	# Set input PROCIDs.
	if (nimages < 100) {
	    list = imofnlu (out, "PROCID[0-9][0-9]")
	    while (imgnfn (list, Memc[key], SZ_LINE) != EOF)
		call imdelf (out, Memc[key])
	    call imcfnl (list)
	    do i = 1, nimages {
		call sprintf (Memc[key], 8, "PROCID%02d")
		    call pargi (i)
		iferr (call imgstr (in[i], "PROCID", Memc[str], SZ_LINE)) {
		    iferr (call imgstr (in[i], "OBSID", Memc[str], SZ_LINE))
			Memc[str] = EOS
		}
		if (Memc[str] != EOS)
		    call imastr (out, Memc[key], Memc[str])
	    }

	    # Set input image names.
	    list = imofnlu (out, "IMCMB[0-9][0-9][0-9]")
	    while (imgnfn (list, Memc[key], SZ_LINE) != EOF)
		call imdelf (out, Memc[key])
	    call imcfnl (list)
	    do i = 1, nimages {
		iferr (call imgstr (in[i], "ICFNAME", Memc[str], SZ_LINE))
		    call imstats (in[i], IM_IMAGENAME, Memc[str], SZ_LINE)
		call sprintf (Memc[key], SZ_LINE, "IMCMB%03d")
		    call pargi (i)
		call imastr (out, Memc[key], Memc[str])
	    }
	}

	call sfree (sp)
end