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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <pkg/gtools.h>
include "icfit.h"
include "names.h"
# ICG_PARAMS -- Set parameter string.
procedure icg_params$t (ic, cv, x, y, wts, npts, gt)
pointer ic # ICFIT pointer
pointer cv # Curfit pointer
PIXEL x[ARB] # Ordinates
PIXEL y[ARB] # Abscissas
PIXEL wts[ARB] # Weights
int npts # Number of data points
pointer gt # GTOOLS pointer
int i, n, deleted
PIXEL rms
pointer sp, fit, wts1, str, params
PIXEL ic_rms$t()
begin
call smark (sp)
n = IC_NFIT(ic)
deleted = 0
rms = INDEF
if (n == npts) {
# Allocate memory for the fit.
call salloc (fit, n, TY_PIXEL)
call salloc (wts1, n, TY_PIXEL)
# Eliminate rejected points and count deleted points.
call amov$t (wts, Mem$t[wts1], n)
if (IC_NREJECT(ic) > 0) {
do i = 1, npts {
if (Memi[IC_REJPTS(ic)+i-1] == YES)
Mem$t[wts1+i-1] = 0.
}
}
deleted = 0
do i = 1, n {
if (wts[i] == 0.)
deleted = deleted + 1
}
# Set the fit and compute the RMS error.
if (IC_FITERROR(ic) == NO) {
call $tcvvector (cv, x, Mem$t[fit], n)
rms = ic_rms$t (x, y, Mem$t[fit], Mem$t[wts1], n)
} else
rms = INDEF
} else if (n > 0) {
# Allocate memory for the fit.
call salloc (fit, n, TY_PIXEL)
call salloc (wts1, n, TY_PIXEL)
# Eliminate rejected points and count deleted points.
call amov$t (Mem$t[IC_WTSFIT(ic)], Mem$t[wts1], n)
if (IC_NREJECT(ic) > 0) {
do i = 1, npts {
if (Memi[IC_REJPTS(ic)+i-1] == YES)
Mem$t[wts1+i-1] = 0.
}
}
deleted = 0
do i = 1, n {
if (wts[i] == 0.)
deleted = deleted + 1
}
# Set the fit and compute the rms error.
if (IC_FITERROR(ic) == NO) {
call $tcvvector (cv, Mem$t[IC_XFIT(ic)], Mem$t[fit], n)
rms = ic_rms$t (Mem$t[IC_XFIT(ic)], Mem$t[IC_YFIT(ic)],
Mem$t[fit], Mem$t[wts1], n)
} else
rms = INDEF
}
# Print the parameters and errors.
call salloc (str, SZ_LINE, TY_CHAR)
call salloc (params, 2*SZ_LINE, TY_CHAR)
call sprintf (Memc[str], SZ_LINE,
"func=%s, order=%d, low_rej=%r, high_rej=%r, niterate=%d, grow=%r")
call ic_gstr (ic, "function", Memc[params], 2*SZ_LINE)
call pargstr (Memc[params])
call pargi (IC_ORDER(ic))
call pargr (IC_LOW(ic))
call pargr (IC_HIGH(ic))
call pargi (IC_NITERATE(ic))
call pargr (IC_GROW(ic))
call sprintf (Memc[params], 2*SZ_LINE,
"%s\ntotal=%d, sample=%d, rejected=%d, deleted=%d, RMS=%7.4g")
call pargstr (Memc[str])
call pargi (npts)
call pargi (n)
call pargi (IC_NREJECT(ic))
call pargi (deleted)
call parg$t (rms)
call gt_sets (gt, GTPARAMS, Memc[params])
# Free allocated memory.
call sfree (sp)
end
|