aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/apextract/apupdate.x
blob: d3344b5f22a5848d8bb6dbaa862503abe1e4974e (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
include <gset.h>
include	"apertures.h"

# AP_UPDATE -- Update an aperture.

procedure ap_update (gp, ap, line, apid, apbeam, center, low, high)

pointer	gp		# GIO pointer
pointer	ap		# Aperture pointer
int	line		# Dispersion line
int	apid		# New aperture ID
int	apbeam		# New aperture beam
real	center		# New center at dispersion line
real	low		# New lower limit
real	high		# New upper limit

real	ap_cveval(), ic_getr()

begin
	# Check for bad values.
	if (IS_INDEFR(center) || IS_INDEFR(low) || IS_INDEFR(high))
	    call error (1, "INDEF not allowed")

	# Erase the current aperture.
	call gseti (gp, G_PLTYPE, 0)
	call ap_gmark (gp, line, ap, 1)

	# Update the aperture.
	AP_ID(ap) = apid
	AP_BEAM(ap) = apbeam
	AP_CEN(ap, AP_AXIS(ap)) = center - ap_cveval (AP_CV(ap), real (line))
        AP_LOW(ap, AP_AXIS(ap)) = min (low, high)
        AP_HIGH(ap, AP_AXIS(ap)) = max (low, high)
	if (AP_IC(ap) != NULL) {
	    call ic_putr (AP_IC(ap), "xmin",
		min (low, high, ic_getr (AP_IC(ap), "xmin")))
	    call ic_putr (AP_IC(ap), "xmax",
		max (low, high, ic_getr (AP_IC(ap), "xmax")))
	}

	# Mark the new aperture.
	call gseti (gp, G_PLTYPE, 1)
	call ap_gmark (gp, line, ap, 1)
end