diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /noao/imred/generic/normflat.cl | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/imred/generic/normflat.cl')
-rw-r--r-- | noao/imred/generic/normflat.cl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/noao/imred/generic/normflat.cl b/noao/imred/generic/normflat.cl new file mode 100644 index 00000000..60b7025b --- /dev/null +++ b/noao/imred/generic/normflat.cl @@ -0,0 +1,69 @@ +#{ NORMFLAT -- Make a flat field by normalizing and replacing low values. + +# image,f,a,,,,Calibration image +# flatfield,f,a,,,,Flat field image +# norm,r,h,INDEF,,,Normalization if not INDEF +# minflat,r,h,INDEF,,,Minimum data value to use in the flat field +# sample_section,s,h,"[]",,,Sample section for determining normalization +# keeplog,b,h,@generic.keeplog,,,Keep log of processing? +# logfile,f,h,@generic.logfile,,,Log file +# img,f,h +# flt,f,h +# tmp,f,h +# rlist,*s,h +# mean,r,h +# stat,i,h + +{ + # Get query parameters and set temporary parameters. + img = image + flt = flatfield + tmp = mktemp ("tmp$gec") + + # Startup message. + if (keeplog) { + time (>> logfile) + print (" NORMFLAT: Create a flat field.\n", >> logfile) + print (" Calibration image: ", img, >> logfile) + print (" Flat field: ", flt, >> logfile) + if (minflat != INDEF) + print (" Minimum data value used in flat field = ", minflat, + >> logfile) + } + + # Determine normalization. + if (norm == INDEF) { + # Determine the mean of the sample region. + + imstatistics (img // sample_section, fields="mean", + lower=minflat, upper=INDEF, format=no, > tmp) + rlist = tmp + stat = fscan (rlist, mean) + rlist = "" + delete (tmp, verify=no) + } else + mean = norm + + if (keeplog) + print (" Normalization = ", mean, >> logfile) + + # Replace low values by the mean and normalize. + if (mean != 0.) { + if (minflat != INDEF) { + imcopy (img, flt, verbose=no) + imreplace (flt, mean, upper=minflat) + imarith (flt, "/", mean, flt, pixtype="real") + } else + imarith (img, "/", mean, flt, pixtype="real") + } else + print (" ERROR: Cannot normalize calibration image.") + + # Set CCDMEAN to 1. + hedit (flt, "ccdmean", "1.", add=yes, update=yes, show=no, verify=no) + + # Ending message. + if (keeplog) { + time (>> logfile) + print (" NORMFLAT: Done.", >> logfile) + } +} |