aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/fitsky/aphgmsub.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/digiphot/apphot/fitsky/aphgmsub.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/digiphot/apphot/fitsky/aphgmsub.x')
-rw-r--r--noao/digiphot/apphot/fitsky/aphgmsub.x51
1 files changed, 51 insertions, 0 deletions
diff --git a/noao/digiphot/apphot/fitsky/aphgmsub.x b/noao/digiphot/apphot/fitsky/aphgmsub.x
new file mode 100644
index 00000000..ae969bba
--- /dev/null
+++ b/noao/digiphot/apphot/fitsky/aphgmsub.x
@@ -0,0 +1,51 @@
+# AP_HGMSUB -- Procedure to subtract a point from an existing histogram.
+
+procedure ap_hgmsub (hgm, nbins, z1, z2, skypix)
+
+real hgm[ARB] # histogram
+int nbins # number of bins
+real z1, z2 # range of histogram
+real skypix # sky value
+
+int bin
+real dh
+
+begin
+ if (skypix < z1 || skypix > z2)
+ return
+ dh = real (nbins - 1) / (z2 - z1)
+ bin = int ((skypix - z1) * dh) + 1
+ hgm[bin] = hgm[bin] - 1.0
+end
+
+
+# AP_HGMSUB2 -- Procedure to subract points from the accumulated sums
+# and the existing histogram.
+
+procedure ap_hgmsub2 (hgm, nbins, z1, z2, skypix, sky_zero, sumpx, sumsqpx,
+ sumcbpx)
+
+real hgm[ARB] # histogram
+int nbins # number of bins
+real z1, z2 # range of histogram
+real skypix # sky value
+real sky_zero # sky zero point for moment analysis
+double sumpx # sum of the sky pixel values
+double sumsqpx # sum of the squares of the sky pixel values
+double sumcbpx # sum of the cubes of the sky pixel values
+
+double dsky
+int bin
+real dh
+
+begin
+ if (skypix < z1 || skypix > z2)
+ return
+ dsky = skypix - sky_zero
+ sumpx = sumpx - dsky
+ sumsqpx = sumsqpx - dsky ** 2
+ sumcbpx = sumcbpx - dsky ** 3
+ dh = real (nbins - 1) / (z2 - z1)
+ bin = int ((skypix - z1) * dh) + 1
+ hgm[bin] = hgm[bin] - 1.0
+end