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
|
include <imhdr.h>
include "ms.h"
# MSPLOT -- Plot image and model values.
#
# The output list format is column, image line, data value, model value.
# This task differs from t_new_image primarily in that there is no profile
# interpolation. The model is evaluated only at the sample lines. It
# is used to check the results of the model fitting tasks.
procedure msplot ()
char image[SZ_FNAME] # Image
int line # Image line to plot
int naverage # Number of image lines to average
real lower # Lower limit of profile model
real upper # Upper limit of profile model
int sample
pointer ms, im
pointer sp, data, model
int clgeti(), get_sample_line
real clgetr()
pointer msmap(), immap()
begin
# Get the task parameters.
call clgstr ("image", image, SZ_FNAME)
line = clgeti ("line")
naverage = clgeti ("naverage")
lower = clgetr ("lower")
upper = clgetr ("upper")
# Access the database and image.
ms = msmap (image, READ_ONLY, 0)
im = immap (image, READ_ONLY, 0)
# Allocate memory for the data and model.
call smark (sp)
call salloc (data, IM_LEN(im, 1), TY_REAL)
call salloc (model, IM_LEN(im, 1), TY_REAL)
sample = get_sample_line (ms, line)
line = LINE(ms, sample)
call msgimage (im, line, naverage, Memr[data])
call gauss5_model (ms, sample, lower, upper, Memr[model])
call ms_graph (Memr[data], Memr[model], IM_LEN(im, 1))
call sfree (sp)
call msunmap (ms)
call imunmap (im)
end
include <gset.h>
# MS_GRAPH -- For the selected line get the data line and compute a model line.
# Graph the data and model values.
procedure ms_graph (data, model, npts)
real data[npts] # Image data
real model[npts] # Model data
int npts # Number of data points
char str[SZ_LINE]
real x1, x2
pointer gp, gt
real wx, wy # Cursor position
int wcs, key # WCS and cursor key
int gt_gcur()
pointer gopen(), gt_init()
begin
call clgstr ("graphics", str, SZ_LINE)
gp = gopen (str, NEW_FILE, STDGRAPH)
gt = gt_init ()
x1 = 1
x2 = npts
call gswind (gp, x1, x2, INDEF, INDEF)
call gascale (gp, data, npts, 2)
call grscale (gp, model, npts, 2)
call gt_swind (gp, gt)
call gt_labax (gp, gt)
call gseti (gp, G_PLTYPE, 1)
call gvline (gp, data, npts, x1, x2)
call gseti (gp, G_PLTYPE, 2)
call gvline (gp, model, npts, x1, x2)
while (gt_gcur ("cursor", wx, wy, wcs, key, str, SZ_LINE) != EOF)
;
call gclose (gp)
call gt_free (gt)
end
|