Debian Codegraph @

stdred/ccdred/proc/ccdillflat.prg

raw
1 ! @(#)ccdillflat.prg 19.1 (ESO-DMD) 02/25/03 14:16:00
2 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 !.COPYRIGHT (C) 1993 European Southern Observatory
4 !.IDENT ccdillflat.prg
5 !.AUTHOR Rein H. Warmels, ESO-Garching
6 !.KEYWORDS Direct imaging, CCD package, SKYCOR/CCD
7 !.PURPOSE Make illumination corrected flat frame(s)
8 !.USE ILLFLAT/CCD p1 p2
9 !. where p1 = input table of science frames or single frame
10 !. p2 = output frame (only in case of single frame input)
11 !. p3 = xboxmin, xboxmax smoothing box
12 !. p4 = yboxmin, yboxmax smoothing box
13 !. p5 = clipping option
14 !. p6 = low and high clipping factor
15 !.ALGORYTHM: The procedure check if the sky frame are available and continues
16 !. with the pipeline reduction of each sky frame if that is
17 !. required. Using the reduced sky the illumation frame(s) are
18 !. created by a box smoothing algorithm which multiplied with the
19 !. flat field (sky_flat.prg).
20 !.NOTE The individual procedures check if one operation was already done
21 !. by checking the descriptor CCDSTAT. The CCDSTAT descriptor values
22 !. represent the following status:
23 !. CCDSTAT(1) for overscan correction
24 !. CCDSTAT(2) for trimming the frame
25 !. CCDSTAT(3) for bad pixel correction
26 !. CCDSTAT(4) for bias subtraction
27 !. CCDSTAT(5) for dark current subtraction
28 !. CCDSTAT(6) for flat fielding
29 !. CCDSTAT(7) for illumination correction
30 !. CCDSTAT(8) for fringing correction
31 !.VERSION: 920731 RHW Creation
32 !.VERSION: 930728 RHW Improve layout and structure
33 !-------------------------------------------------------
34 DEFINE/PARAM P1 {CCD_IN} C "Enter input specification [no default]:"
35 DEFINE/PARAM P5 {IL_CLIP} C "Clean frame form object first [IL_CLIP]:"
36 !
37 ! *** keyword saving
38 DEFINE/LOCAL CCDIN/C/1/60 " "
39 DEFINE/LOCAL CCDOUT/C/1/60 " "
40 DEFINE/LOCAL SCFRM/C/1/60 " "
41 DEFINE/LOCAL BSFRM/C/1/60 "{SC_BSFRM}"
42 DEFINE/LOCAL DKFRM/C/1/60 "{SC_DKFRM}"
43 !
44 DEFINE/LOCAL NAME/C/1/60 " "
45 DEFINE/LOCAL CNAME/C/1/10 " "
46 DEFINE/LOCAL IC/I/1/1 0
47 DEFINE/LOCAL IR/I/1/1 0
48 DEFINE/LOCAL IDOT/I/1/1 0
49 DEFINE/LOCAL IRA/I/1/1 0
50 DEFINE/LOCAL LL/I/1/1 0
51 DEFINE/LOCAL NRR/I/1/1 0
52 DEFINE/LOCAL NCR/I/1/1 0
53 DEFINE/LOCAL NCA/I/1/1 0
54 DEFINE/LOCAL NRA/I/1/1 0
55 DEFINE/LOCAL TBL/I/1/1 0
56 !
57 DEFINE/PARAM P3 {IL_XBOX(1)},{IL_XBOX(2)} N
58 DEFINE/PARAM P4 {IL_YBOX(1)},{IL_YBOX(2)} N
59 DEFINE/PARAM P5 {IL_CLIP} C
60 !
61 IF P5(1:1) .EQ. "Y" THEN
62 DEFINE/PARAM P6 {IL_SIGMA(1)},{IL_SIGMA(2)}
63 ENDIF
64 !
65 ! *** first check for single frame of input table
66 TBL = M$INDEX(P1,".tbl") ! search for .tbl
67 IF TBL .EQ. 0 THEN
68 CCDIN = "{P1}"
69 DEFINE/PARAM P2 {CCD_OUT} IMA "Enter the output illumination frame:"
70 CCDOUT = "{P2}"
71 !
72 ! *** the following part in for reduction table input
73 ELSE
74 IF M$EXIST(P1) .EQ. 0 THEN ! check exsistence
75 WRITE/OUT "*** FATAL: Missing CCD reduction table {P1}"
76 RETURN
77 ELSE
78 COPY/TABLE {P1} &r ! copy only selected part
79 SET/FORMAT I3
80 NCA = {&r.tbl,TBLCONTR(3)}
81 NRA = {&r.tbl,TBLCONTR(4)} ! check number of rows
82 IF NRA .EQ. 0 THEN
83 GOTO FINISH
84 ENDIF
85 ENDIF
86 !
87 ! *** collect the input/output frame and calibration frames
88 IRA = 0
89 WRITE/OUT "Creating flat illum. correction frames in table {P1}"
90 NXTFRM:
91 IRA = IRA + 1
92 CCDIN = "{&r,:{FF_COL},@{IRA}}" ! get input image name
93 LL = M$INDEX(CCDIN,"_ff")-1 ! science image
94 CCDOUT = "{CCDIN(1:{LL})}_if"
95 !
96 IF M$EXIST(CCDIN) .EQ. 0 THEN ! checking the flat frame
97 WRITE/OUT "*** INFO: Flat field {CCDIN} to be created"
98 SCFRM = "{CCDIN(1:{LL})}" ! master science
99 COMBINE/CCD FF {SCFRM} {CCDIN} ! combine
100 ENDIF
101 !
102 IF SC_BSCOR(1:1) .EQ. "y" THEN ! bias correc. wanted?
103 SC_BSFRM = "{&r,:{BS_COL},@{IRA}}"
104 ENDIF
105 !
106 IF SC_DKCOR(1:1) .EQ. "y" THEN ! dark correc. wanted?
107 SC_DKFRM = "{&r,:{DK_COL},@{IRA}}"
108 ENDIF
109 ENDIF
110 !
111 ! *** remove the .bdf extension
112 IDOT = M$INDEX(CCDIN,".bdf") - 1
113 IF IDOT .GT. 0 THEN
114 CCDIN = "{CCDIN(1:{IDOT})}"
115 ELSE
116 CCDIN = "{CCDIN}"
117 ENDIF
118 IF M$EXIST("{CCDIN}.bdf") .EQ. 0 THEN ! check exsistence
119 WRITE/OUT "*** FATAL: Missing input frame {P1}"
120 GOTO FINISH
121 ENDIF
122 !
123 IDOT = M$INDEX(CCDOUT,".bdf") - 1
124 IF IDOT .GT. 0 THEN
125 CCDOUT = "{CCDOUT(1:{IDOT})}"
126 ELSE
127 CCDOUT = "{CCDOUT}"
128 ENDIF
129 !
130 @s ccdredfrm {CCDIN} {CCDIN} ! reduce flat field
131 @s make_illum {CCDIN} &d {P3} {P4} {P5} {P6} ! smooth to create illum frame
132 IF M$EXIST("&d") .EQ. 0 THEN ! is it there?
133 WRITE/OUT "*** ERROR: Failed to make illumination frame from {CCDIN}"
134 GOTO FINISH
135 ELSE
136 @s make_illflat {CCDIN} &d {CCDOUT} ! create illum corrected flat
137 WRITE/DESCR {CCDOUT} HISTORY/C/-1/80 "ILLFLAT/CCD {P1} {P2}
138 ENDIF
139 !
140 ! *** finish up
141 FINISH:
142 IF TBL .EQ. 0 THEN ! single frame input
143 WRITE/OUT "{CCDOUT}: Illumination corrected flat field from {CCDIN} ready"
144 ELSE ! table input
145 IF IRA .LT. {NRA} THEN
146 GOTO NXTFRM
147 ELSE
148 WRITE/OUT " "
149 IF NRA .EQ. 0 THEN
150 WRITE/OUT "{P1}: *** WARNING: Selection in reduction table is empty "
151 ELSE
152 WRITE/OUT "{P1}: Illumination corrected flats fields ready"
153 ENDIF
154 DELETE/TABLE &r NO
155 ENDIF
156 ENDIF
157 !
158 DELETE/IMAGE &d NO
159 SC_BSFRM = "{BSFRM}" ! restore keyword setting
160 SC_DKFRM = "{DKFRM}"
161 RETURN
162
163
164
165