aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/src/fibers/getspec.cl
blob: 84ce9a1c2d6fc09b19c173f87d6f2eb9ee366aba (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
# GETSPEC -- Get spectra which are processed but are not extracted.
# Strip the imtype extension.

procedure getspec (images, output)

string	images			{prompt="List of images"}
file	output			{prompt="Output file of images"}
bool	ccdproc			{prompt="Add CCDPROC keyword and continue?",
				 mode="q"}
struct	*fd

begin
	string	imtype, temp, image, system=""
	int	n, n1

	imtype = "." // envget ("imtype")
	n = stridx (",", imtype)
	if (n > 0)
	    imtype = substr (imtype, 1, n-1)
	n1 = strlen (imtype)

	# Initialize files
	set clobber=yes
	sleep (> output)
	set clobber=no

	temp = mktemp ("tmp$iraf")
	sections (images, option="fullname", > temp)
	fd = temp
	while (fscan (fd, image) != EOF) {
	    hselect (image, "ccdproc", yes) | scan (system)
	    if (nscan() == 0) {
		printf ("%s: CCDPROC keyword not found.\n", image)
		printf ("  Either run CCDPROC or add CCDPROC keyword with HEDIT.\n")
		if (!ccdproc)
		    error (1, "Exit")
		hedit (image, "ccdproc", "DONE", add=yes, update=yes,
		    verify=no, show=no)
	    }
	    hselect (image, "wat0_001", yes) | scanf ("system=%s", system)
	    if (system=="equispec" || system=="multispec")
		next
	    n = strlen (image)
	    if (n > n1 && substr (image, n-n1+1, n) == imtype)
		image = substr (image, 1, n-n1)
	    print (image, >> output)
	}
	fd = ""; delete (temp, verify=no)
end