aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/generic/flatten.cl
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /noao/imred/generic/flatten.cl
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/imred/generic/flatten.cl')
-rw-r--r--noao/imred/generic/flatten.cl64
1 files changed, 64 insertions, 0 deletions
diff --git a/noao/imred/generic/flatten.cl b/noao/imred/generic/flatten.cl
new file mode 100644
index 00000000..928e09b2
--- /dev/null
+++ b/noao/imred/generic/flatten.cl
@@ -0,0 +1,64 @@
+#{ FLATTEN -- Divide images by a flat field
+
+#images,s,a,,,,Images to be flattened
+#flatfield,f,a,,,,Flat field
+#minflat,r,h,INDEF,,,Minimum flat field value
+#pixtype,s,h,"real",,,Flattened image pixel datatype
+#keeplog,b,h,@generic.keeplog,,,Keep log of processing?
+#logfile,f,h,@generic.logfile,,,Log file
+#imlist,f,h
+#imfd,*s,h
+#input,f,h
+#flat,f,h
+#flt,f,h
+
+{
+ # Startup message.
+ if (keeplog) {
+ time (>> logfile)
+ print (" FLATTEN: Flatten images.", >> logfile)
+ }
+
+ # Set temporary files.
+ imlist = mktemp ("tmp$ims")
+
+ # Replace low flat field values if needed.
+ flat = flatfield
+ if (minflat == INDEF)
+ flt = flat
+ else {
+ if (keeplog)
+ print (" Minimum flat field value = ", minflat, >> logfile)
+ flt = mktemp ("tmp$ims")
+ imcopy (flat, flt, verbose=no)
+ imreplace (flt, 1., upper=minflat)
+ }
+
+ # Generate image list.
+ sections (images, option="fullname", >imlist)
+ imfd = imlist
+
+ while (fscan (imfd, input) != EOF) {
+
+ # Print output.
+ if (keeplog) {
+ time (>> logfile)
+ print (" Flatten ", input, " with ", flat, ".", >> logfile)
+ }
+
+ # Flatten the image with the flat field. Replace the input
+ # image by the flattened image.
+
+ imarith (input, "/", flt, input, pixtype=pixtype, calctype="real")
+ }
+
+ if (minflat != INDEF)
+ imdelete (flt, verify=no)
+ delete (imlist, verify=no)
+
+ # Ending message.
+ if (keeplog) {
+ time (>> logfile)
+ print (" FLATTEN: Done.", >> logfile)
+ }
+}