| 1 |
! @(#)ccdfrcor.prg 19.1 (ESO-DMD) 02/25/03 14:16:00 |
| 2 |
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 3 |
!.COPYRIGHT (C) 1993 European Southern Observatory |
| 4 |
!.IDENT ccdfrcor.prg |
| 5 |
!.AUTHOR Rein H. Warmels, ESO-Garching |
| 6 |
!.KEYWORDS Direct imaging, CCD package, SKYCOR/CCD |
| 7 |
!.PURPOSE Make fringe correction frame |
| 8 |
!.USE FRCOR/CCD p1 p2 p3 p4 p5 p6 |
| 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 |
! |
| 35 |
! *** keyword saving |
| 36 |
DEFINE/LOCAL CCDIN/C/1/60 " " |
| 37 |
DEFINE/LOCAL CCDOUT/C/1/60 " " |
| 38 |
DEFINE/LOCAL SCFRM/C/1/60 " " |
| 39 |
DEFINE/LOCAL BSFRM/C/1/60 "{SC_BSFRM}" |
| 40 |
DEFINE/LOCAL DKFRM/C/1/60 "{SC_DKFRM}" |
| 41 |
DEFINE/LOCAL FFFRM/C/1/60 "{SC_FFFRM}" |
| 42 |
DEFINE/LOCAL ILFRM/C/1/60 "{SC_ILFRM}" |
| 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 LL/I/1/1 0 |
| 49 |
DEFINE/LOCAL NRR/I/1/1 0 |
| 50 |
DEFINE/LOCAL NCR/I/1/1 0 |
| 51 |
DEFINE/LOCAL NCA/I/1/1 0 |
| 52 |
DEFINE/LOCAL NRA/I/1/1 0 |
| 53 |
DEFINE/LOCAL IRA/I/1/1 0 |
| 54 |
DEFINE/LOCAL IDOT/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 .bdf |
| 67 |
IF TBL .EQ. 0 THEN ! frame input |
| 68 |
IDOT = M$INDEX(P1,".bdf") |
| 69 |
IF IDOT .EQ. 0 THEN |
| 70 |
CCDIN = "{P1}.bdf" |
| 71 |
ELSE |
| 72 |
CCDIN = "{P1}" |
| 73 |
ENDIF |
| 74 |
IF M$EXIST(CCDIN) .EQ. 0 THEN |
| 75 |
WRITE/OUT "*** ERROR: Input frame {CCDIN} doesn't exist" |
| 76 |
RETURN |
| 77 |
ENDIF |
| 78 |
! |
| 79 |
DEFINE/PARAM P2 {CCD_OUT} IMA "Enter the output fringe frame:" |
| 80 |
IDOT = M$INDEX(P2,".bdf") |
| 81 |
IF IDOT .EQ. 0 THEN |
| 82 |
CCDOUT = "{P2}.bdf" |
| 83 |
ELSE |
| 84 |
CCDOUT = "{P2}" |
| 85 |
ENDIF |
| 86 |
! |
| 87 |
! *** the following part in for reduction table input |
| 88 |
ELSE ! reduction table input |
| 89 |
IF M$EXIST(P1) .EQ. 0 THEN ! check exsistence |
| 90 |
WRITE/OUT "*** FATAL: Missing CCD reduction table {P1}" |
| 91 |
RETURN |
| 92 |
ENDIF |
| 93 |
! |
| 94 |
COPY/TABLE {P1} &r ! copy only selected part |
| 95 |
WRITE/OUT "{P1}: Start creating fringe correction frames" |
| 96 |
SET/FORMAT I3 |
| 97 |
NCA = {&r.tbl,TBLCONTR(3)} |
| 98 |
NRA = {&r.tbl,TBLCONTR(4)} ! check number of rows |
| 99 |
! |
| 100 |
! *** collect the input/output frame and calibration frames |
| 101 |
IRA = 0 |
| 102 |
NXTFRM: |
| 103 |
IRA = IRA + 1 |
| 104 |
IF IRA .LE. {NRA} THEN |
| 105 |
CCDIN = "{&r,:{SK_COL},@{IRA}}" ! get input image name |
| 106 |
CCDOUT = "{&r,:{FR_COL},@{IRA}}" ! output frame |
| 107 |
! |
| 108 |
! *** this part for checking the input frame |
| 109 |
IF M$EXIST(CCDIN) .EQ. 0 THEN |
| 110 |
WRITE/OUT "*** INFO Flat field {CCDIN} to be created" |
| 111 |
LL = M$INDEX(P1,"_sk")-1 ! science image |
| 112 |
SCFRM = "{P1(1:{LL})}" ! master science |
| 113 |
COMBINE/CCD SK {SCFRM} {CCDIN} ! combine |
| 114 |
ENDIF |
| 115 |
IF M$EXIST(CCDIN) .EQ. 0 THEN ! is it there? |
| 116 |
WRITE/OUT "*** ERROR: Failed to make combined flat frame {CCDIN}" |
| 117 |
RETURN |
| 118 |
ENDIF |
| 119 |
! |
| 120 |
IF SC_BSCOR(1:1) .EQ. "y" THEN ! bias correc. wanted? |
| 121 |
BSFRM = "{SC_BSFRM}" |
| 122 |
SC_BSFRM = "{&r,:{BS_COL},@{IRA}}" |
| 123 |
ENDIF |
| 124 |
! |
| 125 |
IF SC_DKCOR(1:1) .EQ. "y" THEN ! dark correc. wanted? |
| 126 |
DKFRM = "{SC_DKFRM}" |
| 127 |
SC_DKFRM = "{&r,:{DK_COL},@{IRA}}" |
| 128 |
ENDIF |
| 129 |
! |
| 130 |
IF SC_FFCOR(1:1) .EQ. "y" THEN ! dark correc. wanted? |
| 131 |
FFFRM = "{SC_FFFRM}" |
| 132 |
SC_FFFRM = "{&r,:{FF_COL},@{IRA}}" |
| 133 |
ENDIF |
| 134 |
! |
| 135 |
IF SC_ILCOR(1:1) .EQ. "y" THEN ! dark correc. wanted? |
| 136 |
ILFRM = "{SC_ILFRM}" |
| 137 |
SC_ILFRM = "{&r,:{IL_COL},@{IRA}}" |
| 138 |
ENDIF |
| 139 |
ENDIF |
| 140 |
ENDIF |
| 141 |
! |
| 142 |
! *** see if there is a status descriptor |
| 143 |
IF M$EXISTD(CCDIN,"CCDSTAT") .EQ. 0 THEN |
| 144 |
WRITE/DESCR {CCDIN} CCDSTAT/I/1/10 0 ALL |
| 145 |
ENDIF |
| 146 |
! |
| 147 |
! *** set the processing keywords |
| 148 |
CCDCOR = "no" ! calibration |
| 149 |
CCDCORS = "XXXXXXXXXXXXXXXXXXXX" ! init flags |
| 150 |
! |
| 151 |
! *** set the correction flags |
| 152 |
@s prep_scan {CCDIN} ! get the overscan |
| 153 |
@s prep_trim {CCDIN} ! get trim section |
| 154 |
@s prep_fix {CCDIN} ! get pixel correct. |
| 155 |
@s prep_bias {CCDIN} ! get bias frame |
| 156 |
@s prep_dark {CCDIN} ! get dark frame |
| 157 |
@s prep_flat {CCDIN} ! get flat frame |
| 158 |
@s prep_illum {CCDIN} ! get illum frame |
| 159 |
! |
| 160 |
! *** all done: frames are prepared to be used in final step |
| 161 |
IF CCDCOR .EQ. "yes" THEN |
| 162 |
@s ccdcorrect {CCDIN} {CCDIN} |
| 163 |
IF VERBOSE(1:1) .EQ. "Y" THEN |
| 164 |
STATISTIC/IMAGE {CCDIN} {IM_SEC} ? ? FF ! full statistics |
| 165 |
ELSE |
| 166 |
STATISTIC/IMAGE {CCDIN} {IM_SEC} ? ? FN ! short statistics |
| 167 |
ENDIF |
| 168 |
ENDIF |
| 169 |
! |
| 170 |
! *** now do the smoothing |
| 171 |
@s make_fringe {CCDIN} {CCDOUT} {P3} {P4} {P5} {P6} ! smooth |
| 172 |
WRITE/DESCR {CCDOUT} HISTORY/C/-1/80 "ILLCOR/CCD {P1} {P2} |
| 173 |
! |
| 174 |
! *** finish up |
| 175 |
FINISH: |
| 176 |
IF TBL .EQ. 0 THEN ! single frame input |
| 177 |
WRITE/OUT "{CCDOUT}: Fringe frame created from {CCDIN} ready" |
| 178 |
ELSE ! table input |
| 179 |
IF IRA .EQ. NRA THEN ! all done |
| 180 |
SC_BSFRM = "{BSFRM}" ! restore keyword setting |
| 181 |
SC_DKFRM = "{DKFRM}" |
| 182 |
SC_FFFRM = "{FFFRM}" |
| 183 |
SC_ILFRM = "{ILFRM}" |
| 184 |
DELETE/TABLE &r NO |
| 185 |
WRITE/OUT "{P1}: Fringe correction frame(s) created" |
| 186 |
ELSE |
| 187 |
GOTO NXTFRM ! next frame in table |
| 188 |
ENDIF |
| 189 |
ENDIF |
| 190 |
! |
| 191 |
RETURN |