aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/inrms.gx
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/xtools/inlfit/inrms.gx
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/xtools/inlfit/inrms.gx')
-rw-r--r--pkg/xtools/inlfit/inrms.gx31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/xtools/inlfit/inrms.gx b/pkg/xtools/inlfit/inrms.gx
new file mode 100644
index 00000000..a2c5015b
--- /dev/null
+++ b/pkg/xtools/inlfit/inrms.gx
@@ -0,0 +1,31 @@
+# IN_RMS -- Compute rms of points which have a non-zero weight.
+
+PIXEL procedure in_rms$t (y, fit, wts, npts)
+
+PIXEL y[npts] # function
+PIXEL fit[npts] # fit
+PIXEL wts[npts] # weights
+int npts # number of points
+
+int i, ndata
+PIXEL resid, rms
+
+begin
+ rms = PIXEL (0.0)
+ ndata = 0
+
+ do i = 1, npts {
+ if (wts[i] == PIXEL (0.0))
+ next
+ resid = y[i] - fit[i]
+ rms = rms + resid * resid
+ ndata = ndata + 1
+ }
+
+ if (ndata > 0)
+ rms = sqrt (rms / ndata)
+ else
+ rms = PIXEL (0.0)
+
+ return (rms)
+end