aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/ecidentify/ecgraph.x
blob: 9eaeaa5f4a61523426fe78541dd3e28975e169a1 (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
include	<gset.h>
include	<pkg/gtools.h>
include	"ecidentify.h"

# EC_GRAPH -- Graph image vector in which features are to be ecentified.

procedure ec_graph (ec, gtype)

pointer	ec		# ID pointer
int	gtype		# Graph type

begin
	switch (gtype) {
	case 1:
	    if (IS_INDEFI (EC_AP(ec)))
		call ec_graph3(ec)
	    else
	        call ec_graph1 (ec)
	case 2:
	    call ec_graph2 (ec)
	default:
	    call ec_graph1 (ec)
	}
end


procedure ec_graph1 (ec)

pointer	ec				# ID pointer

int	i
real	xmin, xmax, ymin, ymax, dy
pointer	sp, str, x, y

begin
	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)
	call salloc (x, EC_NPTS(ec), TY_REAL)
	y = EC_IMLINE(ec)

	call sprintf (Memc[str], SZ_LINE,
	    "Aperture %d, Image line %d, Order %d")
	    call pargi (EC_AP(ec))
	    call pargi (EC_LINE(ec))
	    call pargi (EC_ORDER(ec))
	call gt_sets (EC_GT(ec), GTPARAMS, Memc[str])
	call achtdr (FITDATA(ec,1), Memr[x], EC_NPTS(ec))

	call gclear (EC_GP(ec))
	xmin = min (Memr[x], Memr[x+EC_NPTS(ec)-1])
	xmax = max (Memr[x], Memr[x+EC_NPTS(ec)-1])
	call alimr (Memr[y], EC_NPTS(ec), ymin, ymax)
	dy = ymax - ymin
	call gswind (EC_GP(ec), xmin, xmax, ymin - .2 * dy, ymax + .2 * dy)
	call gt_swind (EC_GP(ec), EC_GT(ec))
	call gt_labax (EC_GP(ec), EC_GT(ec))
	call gt_plot (EC_GP(ec), EC_GT(ec), Memr[x], Memr[y], EC_NPTS(ec))

	do i = 1, EC_NFEATURES(ec)
	    if (APN(ec,i) == EC_AP(ec))
	        call ec_mark (ec, i)

	call sfree (sp)
end


# EC_GRAPH2 -- Make review graph for current feature.

procedure ec_graph2 (ec)

pointer	ec				# ID pointer

int	i, j, k
real	xmin, xmax, ymin, ymax, dy
pointer	sp, str, x, y

begin
	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)
	call salloc (x, EC_NPTS(ec), TY_REAL)
	y = EC_IMLINE(ec)

	call sprintf (Memc[str], SZ_LINE, "Order %d")
	    call pargi (EC_AP(ec))
	call gt_sets (EC_GT(ec), GTPARAMS, Memc[str])
	call achtdr (FITDATA(ec,1), Memr[x], EC_NPTS(ec))

	xmin = real (FIT(ec,EC_CURRENT(ec))) - EC_ZWIDTH(ec) / 2.
	xmax = real (FIT(ec,EC_CURRENT(ec))) + EC_ZWIDTH(ec) / 2.

	i = 0
	do k = 1, EC_NPTS(ec) {
	    if ((Memr[x+k-1] < xmin) || (Memr[x+k-1] > xmax))
		next
	    if (i == 0)
		i = k
	    j = k
	}
	k = j - i + 1

	call alimr (Memr[y+i-1], k, ymin, ymax)
	dy = ymax - ymin

	call gclear (EC_GP(ec))
	call gswind (EC_GP(ec), xmin, xmax, ymin - .2 * dy, ymax + .2 * dy)
	call gt_labax (EC_GP(ec), EC_GT(ec))
	call gt_plot (EC_GP(ec), EC_GT(ec), Memr[x], Memr[y], EC_NPTS(ec))

	do i = 1, EC_NFEATURES(ec)
	    if (APN(ec,i) == EC_AP(ec))
	        call ec_mark (ec, i)

	call sfree (sp)
end


procedure ec_graph3 (ec)

pointer	ec				# ID pointer

int	i, npts
real	xmin, xmax, ymin, ymax, dy
pointer	sp, str, x, y

begin
	npts = EC_NPTS(ec) * EC_NLINES(ec)

	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)
	call salloc (x, npts, TY_REAL)
	y = EC_IMLINE(ec)

	call sprintf (Memc[str], SZ_LINE, "All orders")
	call gt_sets (EC_GT(ec), GTPARAMS, Memc[str])
	call achtdr (Memd[EC_FITDATA(ec)], Memr[x], npts)

	call gclear (EC_GP(ec))
	xmin = min (Memr[x], Memr[x+npts-1])
	xmax = max (Memr[x], Memr[x+npts-1])
	call alimr (Memr[y], npts, ymin, ymax)
	dy = ymax - ymin
	call gswind (EC_GP(ec), xmin, xmax, ymin - .2 * dy, ymax + .2 * dy)
	call gt_swind (EC_GP(ec), EC_GT(ec))
	call gt_labax (EC_GP(ec), EC_GT(ec))
	do i = 1, EC_NLINES(ec) {
	    call gt_plot (EC_GP(ec), EC_GT(ec), Memr[x], Memr[y], EC_NPTS(ec))
	    x = x + EC_NPTS(ec)
	    y = y + EC_NPTS(ec)
	}

	do i = 1, EC_NFEATURES(ec)
	    call ec_mark (ec, i)

	call sfree (sp)
end