1
! @(#)ccdillcor.prg 19.1 (ESO-DMD) 02/25/03 14:16:00
2
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++
3
!.COPYRIGHT (C) 1993 European Southern Observatory
5
!.AUTHOR Rein H. Warmels, ESO-Garching
6
!.KEYWORDS Direct imaging, CCD package, SKYCOR/CCD
7
!.PURPOSE Make illumination illumination correction frame(s)
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]:"
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}"
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
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
60
IF P5(1:1) .EQ. "Y" THEN
61
DEFINE/PARAM P6 {IL_SIGMA(1)},{IL_SIGMA(2)}
64
! *** first check for single frame of input table
65
TBL = M$INDEX(P1,".tbl") ! search for .tbl
68
DEFINE/PARAM P2 {CCD_OUT} IMA "Enter the output illumination frame:"
71
! *** the following part in for reduction table input
73
IF M$EXIST(P1) .EQ. 0 THEN ! check exsistence
74
WRITE/OUT "*** FATAL: Missing CCD reduction table {P1}"
77
COPY/TABLE {P1} &r ! copy only selected part
79
NCA = {&r.tbl,TBLCONTR(3)}
80
NRA = {&r.tbl,TBLCONTR(4)} ! check number of rows
86
! *** collect the input/output frame and calibration frames
88
WRITE/OUT "Creating flat illum. correction frames in table {P1}"
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"
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
101
IF SC_BSCOR(1:1) .EQ. "y" THEN ! bias correc. wanted?
102
SC_BSFRM = "{&r,:{BS_COL},@{IRA}}"
105
IF SC_DKCOR(1:1) .EQ. "y" THEN ! dark correc. wanted?
106
SC_DKFRM = "{&r,:{DK_COL},@{IRA}}"
110
! *** remove the .bdf extension
111
IDOT = M$INDEX(CCDIN,".bdf") - 1
113
CCDIN = "{CCDIN(1:{IDOT})}"
117
IF M$EXIST("{CCDIN}.bdf") .EQ. 0 THEN ! check exsistence
118
WRITE/OUT "*** FATAL: Missing input frame {CCDIN}"
122
IDOT = M$INDEX(CCDOUT,".bdf") - 1
124
CCDOUT = "{CCDOUT(1:{IDOT})}"
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}"
135
WRITE/DESCR {CCDOUT} HISTORY/C/-1/80 "ILLCOR/CCD {P1} {P2}
140
IF TBL .EQ. 0 THEN ! single frame input
141
WRITE/OUT "{CCDOUT}: Illumination frame from {CCDIN} ready"
143
IF IRA .LT. {NRA} THEN
148
WRITE/OUT "{P1}: *** WARNING: Selection in reduction table is empty "
150
WRITE/OUT "{P1}: Illumination frames ready"
156
SC_BSFRM = "{BSFRM}" ! restore keyword setting