aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/identify/iddoshift.x
diff options
context:
space:
mode:
Diffstat (limited to 'noao/onedspec/identify/iddoshift.x')
-rw-r--r--noao/onedspec/identify/iddoshift.x41
1 files changed, 41 insertions, 0 deletions
diff --git a/noao/onedspec/identify/iddoshift.x b/noao/onedspec/identify/iddoshift.x
new file mode 100644
index 00000000..2dfdff74
--- /dev/null
+++ b/noao/onedspec/identify/iddoshift.x
@@ -0,0 +1,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