aboutsummaryrefslogtreecommitdiff
path: root/noao/mtlocal/r2df/r2dfrd.x
blob: 80a492e92bea689dc30e2b50bbdcafe99c750b03 (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
include <error.h>
include <imhdr.h>
include	"r2df.h"

# R2DFRD -- Convert a 2D-FRUTTI file into an IRAF imagefile.
# An EOT is signalled by returning EOF.

int procedure r2dfrd (camfile, iraffile)

char	camfile[ARB]
char	iraffile[ARB]

int	stat
pointer	cam_fd, im
int	r2dfrhdr()
pointer mtopen(), immap()
errchk	salloc, r2dfrhdr, mtopen, close, immap, delete
errchk	r2dfrim
include	"r2df.com"

begin
	# Open input 2D-FRUTTI file.  If an error occurs on open file
	# is at EOT.

	cam_fd = mtopen (camfile, READ_ONLY, 0)

	# Print long or short header.

	if (long_header == YES || short_header == YES) {
	    if (make_image == YES) {
	        call printf ("File: %s  ")
		    call pargstr (iraffile)
	    } else {
		call printf ("File: %s  ")
		    call pargstr (camfile)
	    }
	    if (long_header == YES)
		call printf ("\n")
	 }

	 # Create IRAF image header.  If only a header listing is desired
	 # then a temporary image header is created and later deleted.

	 if (make_image == NO)
	     call strcpy ("dev$null", iraffile, SZ_FNAME)
	 im = immap (iraffile, NEW_IMAGE, LEN_USER_AREA)

	 # Read the header. EOT is signalled by an EOF status from fits_read_
	 # header. Create an IRAF image if desired

	 iferr {
	    stat = r2dfrhdr (cam_fd, im)
	    if (stat == EOF)
		call printf ("End of data\n")
	    else {
	        if (make_image == YES)
	            call r2dfrim (cam_fd, im)
	    }
	} then
	    call erract (EA_WARN)

	# Close files and clean up.

	call imunmap (im)
	if (stat == EOF || make_image == NO)
	    call imdelete (iraffile)
	if (long_header == YES)
	    call printf ("\n")
	call close (cam_fd)

	return (stat)
end