aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/identify/iddoshift.x
blob: 2dfdff74e2f7f32031c4639573c480d62f38e716 (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
include	"identify.h"

# ID_DOSHIFT -- Minimize residuals by constant shift.

procedure id_doshift (id, interactive)

pointer	id			# ID pointer
int	interactive		# Called interactively?

int	i, j
double	shft, delta, rms, id_fitpt()

begin
	shft = 0.
	rms = 0.
	j = 0
	for (i=1; i <= ID_NFEATURES(id); i = i + 1) {
	    if (IS_INDEFD (USER(id,i)) || WTS(id,i) == 0.)
		next
	    delta = USER(id,i) - id_fitpt (id, PIX(id,i))
	    shft = shft + delta
	    rms = rms + delta * delta
	    j = j + 1
	}

	if (j > 0) {
	    shft = shft / j
	    rms = rms / j
	    if (interactive == YES) {
	        call printf ("%s%s: Coordinate shift=%5f, rms=%5f, npts=%3d\n")
		    call pargstr (ID_IMAGE(id))
		    call pargstr (ID_SECTION(id))
		    call pargd (shft)
		    call pargd (sqrt (rms - shft ** 2))
		    call pargi (j)
	    }
	    ID_SHIFT(id) = ID_SHIFT(id) + shft
	    ID_NEWCV(id) = YES
	    ID_NEWGRAPH(id) = YES
	}
end