aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/fitsky/apavsky.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/apavsky.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/digiphot/apphot/fitsky/apavsky.x')
-rw-r--r--noao/digiphot/apphot/fitsky/apavsky.x107
1 files changed, 107 insertions, 0 deletions
diff --git a/noao/digiphot/apphot/fitsky/apavsky.x b/noao/digiphot/apphot/fitsky/apavsky.x
new file mode 100644
index 00000000..c7e38c0e
--- /dev/null
+++ b/noao/digiphot/apphot/fitsky/apavsky.x
@@ -0,0 +1,107 @@
+include "../lib/display.h"
+include "../lib/fitsky.h"
+
+# AP_AVSKY -- Compute an estimate of the sky value by averaging several
+# individual sky values measured in different parts of the frame.
+
+int procedure ap_avsky (ap, im, stid, sd, id, gd, interactive)
+
+pointer ap # the pointer to the main apphot data structure
+pointer im # the pointer to the input image
+int stid # the current sequence number
+int sd # the sky file descriptor
+pointer id # the display stream descriptor
+pointer gd # the graphics stream descriptor
+int interactive # interactive mode
+
+int wcs, key, nmsky, nmsigma, nmskew, nsky, nrej, sier, ier
+pointer sp, cmd
+real wx, wy, msky, msigma, mskew
+int clgcur(), apfitsky(), apstati()
+real apstatr()
+
+begin
+ call smark (sp)
+ call salloc (cmd, SZ_LINE, TY_CHAR)
+
+ # Initialize the skyvalues.
+ msky = 0.0
+ nmsky = 0
+ msigma = 0.0
+ nmsigma = 0
+ mskew = 0.0
+ nmskew = 0
+ nsky = 0
+ nrej = 0
+ ier = AP_OK
+
+ call printf (
+ "\nMeasure sky around several cursor positions (t=measure, q=quit)\n")
+ while (clgcur ("icommands", wx, wy, wcs, key, Memc[cmd], SZ_LINE) !=
+ EOF) {
+
+ switch (key) {
+ case 'q':
+ break
+
+ case 't':
+ sier = apfitsky (ap, im, wx, wy, sd, gd)
+ if (sier != AP_OK)
+ ier = sier
+
+ if (id != NULL) {
+ call apmark (ap, id, NO, apstati (ap, MKSKY), NO)
+ if (id == gd)
+ call gflush (id)
+ else
+ call gframe (id)
+ }
+ call ap_splot (ap, stid, gd, apstati (ap, RADPLOTS))
+ if (interactive == YES)
+ call ap_qspsky (ap, sier)
+
+ if (! IS_INDEFR(apstatr (ap, SKY_MODE))) {
+ msky = msky + apstatr (ap, SKY_MODE)
+ nmsky = nmsky + 1
+ }
+ if (! IS_INDEFR(apstatr (ap, SKY_SIGMA))) {
+ msigma = msigma + apstatr (ap, SKY_SIGMA)
+ nmsigma = nmsigma + 1
+ }
+ if (! IS_INDEFR(apstatr (ap, SKY_SKEW))) {
+ mskew = mskew + apstatr (ap, SKY_SKEW)
+ nmskew = nmskew + 1
+ }
+ nsky = nsky + apstati (ap, NSKY)
+ nrej = nrej + apstati (ap, NSKY_REJECT)
+
+ default:
+ ;
+ }
+ }
+
+ # Compute the average values.
+ if (nmsky > 0)
+ msky = msky / nmsky
+ else
+ msky = INDEFR
+ if (nmsigma > 0)
+ msigma = msigma / nmsigma
+ else
+ msigma = INDEFR
+ if (nmskew > 0)
+ mskew = mskew / nmskew
+ else
+ mskew = INDEFR
+
+ # Store the average values.
+ call apsetr (ap, SKY_MODE, msky)
+ call apsetr (ap, SKY_SIGMA, msigma)
+ call apsetr (ap, SKY_SKEW, mskew)
+ call apseti (ap, NSKY, nsky)
+ call apseti (ap, NSKY_REJECT, nrej)
+
+ call sfree (sp)
+
+ return (ier)
+end