| 1 |
! @(#)ccdskyflat.prg 19.1 (ESO-DMD) 02/25/03 14:16:02 |
| 2 |
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 3 |
!.COPYRIGHT (C) 1993 European Southern Observatory |
| 4 |
!.IDENT ccdskyflat.prg |
| 5 |
!.AUTHOR Rein H. Warmels, ESO-Garching |
| 6 |
!.KEYWORDS Direct imaging, CCD package, SKYCOR/CCD |
| 7 |
!.PURPOSE Make sky illumination corrected flat frame(s) |
| 8 |
!.USE SKYFLAT/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 |
! |
| 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 |
DEFINE/LOCAL FFFRM/C/1/60 "{SC_FFFRM}" |
| 43 |
DEFINE/LOCAL FLATCOR/I/1/1 0 |
| 44 |
! |
| 45 |
DEFINE/LOCAL NAME/C/1/60 " " |
| 46 |
DEFINE/LOCAL CNAME/C/1/10 " " |
| 47 |
DEFINE/LOCAL IC/I/1/1 0 |
| 48 |
DEFINE/LOCAL IR/I/1/1 0 |
| 49 |
DEFINE/LOCAL LL/I/1/1 0 |
| 50 |
DEFINE/LOCAL NRR/I/1/1 0 |
| 51 |
DEFINE/LOCAL NCR/I/1/1 0 |
| 52 |
DEFINE/LOCAL NCA/I/1/1 0 |
| 53 |
DEFINE/LOCAL NRA/I/1/1 0 |
| 54 |
DEFINE/LOCAL IRA/I/1/1 0 |
| 55 |
DEFINE/LOCAL IDOT/I/1/1 0 |
| 56 |
DEFINE/LOCAL TBL/I/1/1 0 |
| 57 |
! |
| 58 |
DEFINE/PARAM P3 {IL_XBOX(1)},{IL_XBOX(2)} N |
| 59 |
DEFINE/PARAM P4 {IL_YBOX(1)},{IL_YBOX(2)} N |
| 60 |
DEFINE/PARAM P5 {IL_CLIP} C |
| 61 |
! |
| 62 |
IF P5(1:1) .EQ. "Y" THEN |
| 63 |
DEFINE/PARAM P6 {IL_SIGMA(1)},{IL_SIGMA(2)} |
| 64 |
ENDIF |
| 65 |
! |
| 66 |
! *** first check for single frame of input table |
| 67 |
TBL = M$INDEX(P1,".tbl") ! search for .tbl |
| 68 |
IF TBL .EQ. 0 THEN |
| 69 |
CCDIN = "{P1}" |
| 70 |
DEFINE/PARAM P2 {CCD_OUT} IMA "Enter the output illumination frame:" |
| 71 |
CCDOUT = "{P2}" |
| 72 |
! |
| 73 |
! *** the following part in for reduction table input |
| 74 |
ELSE |
| 75 |
IF M$EXIST(P1) .EQ. 0 THEN ! check exsistence |
| 76 |
WRITE/OUT "*** FATAL: Missing CCD reduction table {P1}" |
| 77 |
RETURN |
| 78 |
ELSE |
| 79 |
COPY/TABLE {P1} &r ! copy only selected part |
| 80 |
SET/FORMAT I3 |
| 81 |
NCA = {&r.tbl,TBLCONTR(3)} |
| 82 |
NRA = {&r.tbl,TBLCONTR(4)} ! check number of rows |
| 83 |
IF NRA .EQ. 0 THEN |
| 84 |
GOTO FINISH |
| 85 |
ENDIF |
| 86 |
ENDIF |
| 87 |
! |
| 88 |
! *** collect the input/output frame and calibration frames |
| 89 |
IRA = 0 |
| 90 |
WRITE/OUT "Creating flat illum. correction frames in table {P1}" |
| 91 |
NXTFRM: |
| 92 |
IRA = IRA + 1 |
| 93 |
CCDIN = "{&r,:{SK_COL},@{IRA}}" ! get input image name |
| 94 |
LL = M$INDEX(CCDIN,"_sk")-1 ! science image |
| 95 |
CCDOUT = "{CCDIN(1:{LL})}_sf" |
| 96 |
! |
| 97 |
IF M$EXIST(CCDIN) .EQ. 0 THEN ! checking the sky frame |
| 98 |
WRITE/OUT "*** INFO Sky frame {CCDIN} to be created" |
| 99 |
SCFRM = "{CCDIN(1:{LL})}" ! master science |
| 100 |
COMBINE/CCD SK {SCFRM} {CCDIN} ! combine |
| 101 |
ENDIF |
| 102 |
IF M$EXIST(CCDIN) .EQ. 0 THEN ! checking the flat frame |
| 103 |
WRITE/OUT "*** ERROR: Failed to make combined sky frame {CCDIN}" |
| 104 |
GOTO FINISH |
| 105 |
ENDIF |
| 106 |
! |
| 107 |
IF SC_BSCOR(1:1) .EQ. "y" THEN ! bias correc. wanted? |
| 108 |
SC_BSFRM = "{&r,:{BS_COL},@{IRA}}" |
| 109 |
ENDIF |
| 110 |
! |
| 111 |
IF SC_DKCOR(1:1) .EQ. "y" THEN ! dark correc. wanted? |
| 112 |
SC_DKFRM = "{&r,:{DK_COL},@{IRA}}" |
| 113 |
ENDIF |
| 114 |
|
| 115 |
IF SC_FFCOR(1:1) .EQ. "y" THEN ! dark correc. wanted? |
| 116 |
SC_FFFRM = "{&r,:{FF_COL},@{IRA}}" |
| 117 |
ENDIF |
| 118 |
ENDIF |
| 119 |
! |
| 120 |
! *** remove the .bdf extension |
| 121 |
IDOT = M$INDEX(CCDIN,".bdf") - 1 |
| 122 |
IF IDOT .GT. 0 THEN |
| 123 |
CCDIN = "{CCDIN(1:{IDOT})}" |
| 124 |
ELSE |
| 125 |
CCDIN = "{CCDIN}" |
| 126 |
ENDIF |
| 127 |
IF M$EXIST("{CCDIN}.bdf") .EQ. 0 THEN ! check exsistence |
| 128 |
WRITE/OUT "*** FATAL: Missing input frame {P1}" |
| 129 |
GOTO FINISH |
| 130 |
ENDIF |
| 131 |
! |
| 132 |
IDOT = M$INDEX(CCDOUT,".bdf") - 1 |
| 133 |
IF IDOT .GT. 0 THEN |
| 134 |
CCDOUT = "{CCDOUT(1:{IDOT})}" |
| 135 |
ELSE |
| 136 |
CCDOUT = "{CCDOUT}" |
| 137 |
ENDIF |
| 138 |
! |
| 139 |
{CCDIN},{EXP_DESC} = "{IL_TYP} " |
| 140 |
@s ccdredfrm {CCDIN} {CCDIN} ! reduce the frame |
| 141 |
FLATCOR = {{CCDIN},CCDSTAT(6)} |
| 142 |
IF FLATCOR .NE. 1 THEN |
| 143 |
WRITE/OUT "{CCDIN}: *** WARNING: Frame should be flat fielded first" |
| 144 |
GOTO FINISH |
| 145 |
ELSE |
| 146 |
@s make_illum {CCDIN} dummy_il {P3} {P4} {P5} {P6} ! create illum frame |
| 147 |
ENDIF |
| 148 |
! |
| 149 |
! *** check the presence of the illumination frame |
| 150 |
IF M$EXIST("dummy_il.bdf") .EQ. 0 THEN ! is it there? |
| 151 |
WRITE/OUT "*** ERROR: Failed to make sky illumination frame from {CCDIN}" |
| 152 |
GOTO FINISH |
| 153 |
ELSE |
| 154 |
IF M$EXIST("{SC_FFFRM}.bdf") .EQ. 0 THEN |
| 155 |
LL = M$INDEX(SC_FFFRM,"_ff") - 1 ! science image |
| 156 |
SCFRM = "{SC_FFFRM(1:{LL})}" ! master science |
| 157 |
COMBINE/CCD FF {SCFRM} {SC_FFFRM} ! combine |
| 158 |
IF M$EXIST("{SC_FFFRM}.bdf") .EQ. 0 THEN ! is it there? |
| 159 |
WRITE/OUT "{CCDIN}: *** ERROR: Failed to make flat field correction" |
| 160 |
GOTO FINISH |
| 161 |
ENDIF |
| 162 |
ENDIF |
| 163 |
@s ccdcheck {SC_FFFRM} FF ! check if processed |
| 164 |
IF {Q1} .EQ. 1 THEN ! no; not processed |
| 165 |
@s ccdredfrm {SC_FFFRM} {SC_FFFRM} ! do processing |
| 166 |
ENDIF |
| 167 |
@s make_skyflat {SC_FFFRM} dummy_il {CCDOUT} |
| 168 |
WRITE/DESCR {CCDOUT} HISTORY/C/-1/80 "SKYFLAT/CCD {P1} {P2} |
| 169 |
ENDIF |
| 170 |
! |
| 171 |
! *** finish up |
| 172 |
FINISH: |
| 173 |
IF TBL .EQ. 0 THEN ! single frame input |
| 174 |
WRITE/OUT "{CCDOUT}: Sky flat field created from {CCDIN} ready" |
| 175 |
ELSE ! table input |
| 176 |
IF IRA .LT. {NRA} THEN |
| 177 |
GOTO NXTFRM |
| 178 |
ELSE |
| 179 |
WRITE/OUT " " |
| 180 |
IF NRA .EQ. 0 THEN |
| 181 |
WRITE/OUT "{P1}: *** WARNING: Selection in reduction table is empty " |
| 182 |
ELSE |
| 183 |
WRITE/OUT "{P1}: Sky flat field frames ready" |
| 184 |
ENDIF |
| 185 |
DELETE/TABLE &r NO |
| 186 |
ENDIF |
| 187 |
ENDIF |
| 188 |
! |
| 189 |
DELETE/IMAGE dummy_il NO |
| 190 |
SC_BSFRM = "{BSFRM}" ! restore keyword setting |
| 191 |
SC_DKFRM = "{DKFRM}" |
| 192 |
SC_FFFRM = "{FFFRM}" |
| 193 |
RETURN |