Debian Codegraph @

stdred/ccdred/proc/ccdillcor.prg

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