aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/quadred/src/ccdproc/ccdmean.x
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 /noao/imred/quadred/src/ccdproc/ccdmean.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/imred/quadred/src/ccdproc/ccdmean.x')
-rw-r--r--noao/imred/quadred/src/ccdproc/ccdmean.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/noao/imred/quadred/src/ccdproc/ccdmean.x b/noao/imred/quadred/src/ccdproc/ccdmean.x
new file mode 100644
index 00000000..d38ea97b
--- /dev/null
+++ b/noao/imred/quadred/src/ccdproc/ccdmean.x
@@ -0,0 +1,50 @@
+include <imhdr.h>
+
+
+# CCDMEAN -- Compute mean and add to header if needed.
+
+procedure ccdmean (input)
+
+char input[ARB] # Input image
+
+int i, nc, nl, hdmgeti()
+long time, clktime()
+bool clgetb()
+real mean, hdmgetr(), asumr()
+pointer in, immap(), imgl2r()
+errchk immap
+
+begin
+ # Check if this operation has been done.
+
+ in = immap (input, READ_WRITE, 0)
+ ifnoerr (mean = hdmgetr (in, "ccdmean")) {
+ iferr (time = hdmgeti (in, "ccdmeant"))
+ time = IM_MTIME(in)
+ if (time >= IM_MTIME(in)) {
+ call imunmap (in)
+ return
+ }
+ }
+
+ if (clgetb ("noproc")) {
+ call eprintf (
+ " [TO BE DONE] Compute mean of image\n")
+ call pargstr (input)
+ call imunmap (in)
+ return
+ }
+
+ # Compute and record the mean.
+ nc = IM_LEN(in,1)
+ nl = IM_LEN(in,2)
+ mean = 0.
+ do i = 1, nl
+ mean = mean + asumr (Memr[imgl2r(in,i)], nc)
+ mean = mean / (nc * nl)
+ time = clktime (long(0))
+ call hdmputr (in, "ccdmean", mean)
+ call hdmputi (in, "ccdmeant", int (time))
+
+ call imunmap (in)
+end