diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/onedspec/splot/smooth.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/onedspec/splot/smooth.x')
-rw-r--r-- | noao/onedspec/splot/smooth.x | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/noao/onedspec/splot/smooth.x b/noao/onedspec/splot/smooth.x new file mode 100644 index 00000000..1418fc4f --- /dev/null +++ b/noao/onedspec/splot/smooth.x @@ -0,0 +1,54 @@ +# SMOOTH -- Box smooth the array + +procedure smooth (y, n) + +real y[ARB] +int n + +int i, j, boxsize, halfbox, del +int nsum +real sum +pointer sp, smy + +int clgeti() + +begin + call smark (sp) + call salloc (smy, n, TY_REAL) + + # Get boxsize + boxsize = clgeti ("boxsize") + if (mod (boxsize, 2) == 0) { + boxsize = boxsize + 1 + call eprintf ("WARNING: Using a box size of %d") + call pargi (boxsize) + } + + halfbox = boxsize/2 + + # This is not efficiently coded, but easy to code + # A running box mean would be faster + do i = 1, n { + sum = 0.0 + nsum = 0 + + if (i > halfbox && i < (n-halfbox)) + del = halfbox + else + if (i <= halfbox) + del = i/2 + else + del = (n - i + 1)/2 + + do j = i-del, i+del { + nsum = nsum + 1 + sum = sum + y[j] + } + + Memr[smy+i-1] = sum / nsum + } + + # Replace pixels back + call amovr (Memr[smy], y, n) + call sfree (sp) +end |