| 1 |
! @(#)prep_dark.prg 19.1 (ES0-DMD) 02/25/03 14:16:05 |
| 2 |
! @(#)prep_dark.prg 19.1 (ESO-SDAG) 02/25/03 14:16:05 |
| 3 |
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 4 |
!.COPYRIGHT (C) 1993 European Southern Observatory |
| 5 |
!.IDENT prep_dark.prg |
| 6 |
!.AUTHOR Rein H. Warmels, ESO-Garching |
| 7 |
!.KEYWORDS Direct imaging, CCD package |
| 8 |
!.PURPOSE Prepare dark correction image for the reduction |
| 9 |
!.METHOD - Return if dark correction is not requested or has been |
| 10 |
! corrected previously |
| 11 |
!. - Get the dark correction image. If not found return an error |
| 12 |
!. - If dark image has not been processed execute ccdredfrm |
| 13 |
!. - Set the processing flags. |
| 14 |
!.PARAMETERS P1: input frame |
| 15 |
! P2: correction label string which will be checked by |
| 16 |
! ccdcorrect.prg to do the desired actions. |
| 17 |
!.NOTE The procedure checks if the operation was already done |
| 18 |
!. CCDSTAT(1) for overscan correction |
| 19 |
!. CCDSTAT(2) for trimming the frame |
| 20 |
!. CCDSTAT(3) for bad pixel correction |
| 21 |
!. CCDSTAT(4) for bias subtraction |
| 22 |
!. CCDSTAT(5) for dark current subtraction |
| 23 |
!. CCDSTAT(6) for flat fielding |
| 24 |
!. CCDSTAT(7) for illumination correction |
| 25 |
!. CCDSTAT(8) for fringing correction |
| 26 |
!.VERSION 930416 RHW Creation |
| 27 |
!.VERSION 930507 RHW Check input frame for dark correction |
| 28 |
!.VERSION 931015 RHW Include constant dark |
| 29 |
!.VERSION 940113 RHW Change for DO association table |
| 30 |
!.VERSION 971117 SW correction labels have to be local -> new param. |
| 31 |
!------------------------------------------------------- |
| 32 |
DEFINE/PARAM P1 ? I "Input frame for dark correction:" |
| 33 |
DEFINE/PARAM P2 {CCDCORS(1:20)} |
| 34 |
!The correction label string CCDCORS which will be checked by CCDCORRECT.PRG |
| 35 |
!has to be local, in order to always get the right link to the actual frame. |
| 36 |
!In a global definition the correction labels may overwritten by other pre- |
| 37 |
!pared frames which leads to unwished actions to previous frames (SW,97.11.17). |
| 38 |
! |
| 39 |
DEFINE/LOCAL CONST/I/1/1 0 |
| 40 |
! |
| 41 |
! *** do we want the dark correction |
| 42 |
IF SC_DKCOR .NE. "yes" .OR. {{P1},CCDSTAT(5)} .EQ. 1 THEN |
| 43 |
WRITE/OUT "{P1}: Dark correction not requested or has been applied" |
| 44 |
RETURN {P2} |
| 45 |
ELSE |
| 46 |
P2(11:11) = "Y" !<--- [email protected] (13.11.97) |
| 47 |
ENDIF |
| 48 |
! |
| 49 |
! *** check the DARK image name |
| 50 |
IF SC_DKFRM(1:1) .EQ. " " THEN ! dark image unknown |
| 51 |
WRITE/OUT "{P1}: *** WARNING: Dark correction unknown or undefined" |
| 52 |
RETURN {P2} |
| 53 |
ENDIF |
| 54 |
! |
| 55 |
! *** check if dark current correction is a constant |
| 56 |
IF M$TSTNO("{SC_DKFRM}") .EQ. 1 THEN ! check for constant value |
| 57 |
CONST = 1 |
| 58 |
ELSE ! real frame wanted |
| 59 |
IF M$EXIST("{SC_DKFRM}.bdf") .EQ. 0 THEN ! make dark frame |
| 60 |
WRITE/OUT "{P1}: Dark correction {SC_DKFRM} to be created" |
| 61 |
COMBINE/CCD DK |
| 62 |
IF M$EXIST("{SC_DKFRM}.bdf") .EQ. 0 THEN ! is it there? |
| 63 |
WRITE/OUT "{P1}: *** ERROR: Failed to make dark correction" |
| 64 |
RETURN {P2} |
| 65 |
ENDIF |
| 66 |
ENDIF |
| 67 |
ENDIF |
| 68 |
! |
| 69 |
! *** return if only listing is wanted |
| 70 |
IF SC_PROC .EQ. "yes" THEN |
| 71 |
WRITE/OUT "{P1}: *** TO BE DONE: Dark correction is {SC_DKFRM}" |
| 72 |
RETURN {P2} |
| 73 |
ENDIF |
| 74 |
! |
| 75 |
! *** here for the real thing |
| 76 |
IF CONST .EQ. 0 THEN ! frame required |
| 77 |
@s ccdcheck {SC_DKFRM} DK ! check if processed |
| 78 |
IF Q1 .EQ. "1" THEN ! no; not processed |
| 79 |
@s ccdredfrm {SC_DKFRM} {SC_DKFRM} ! do processing |
| 80 |
IF P2(11:11) .NE. "Y" THEN |
| 81 |
RETURN {P2} |
| 82 |
ENDIF |
| 83 |
ENDIF |
| 84 |
DEFINE/LOCAL OBSTIM/R/1/2 0.0,0.0 |
| 85 |
OBSTIM(1) = {{P1},{O_DESC}} |
| 86 |
OBSTIM(2) = {{SC_DKFRM},{O_DESC}} |
| 87 |
IF OBSTIM(1) .LE. 0 THEN |
| 88 |
WRITE/OUT "{P1}: *** ERROR: invalid exposure time " |
| 89 |
RETURN {P2} |
| 90 |
ENDIF |
| 91 |
IF OBSTIM(2) .LE. 0 THEN |
| 92 |
WRITE/OUT "{P1}: *** ERROR: {SC_DKFRM} dark has invalid exposure time" |
| 93 |
RETURN {P2} |
| 94 |
ENDIF |
| 95 |
CCDDARK = OBSTIM(1)/OBSTIM(2) |
| 96 |
ELSE |
| 97 |
CCDDARK = 1.0 |
| 98 |
ENDIF |
| 99 |
! |
| 100 |
WRITE/OUT "{P1}: Dark correction is {SC_DKFRM}; scale = {CCDDARK}" |
| 101 |
P2(5:5) = "D" |
| 102 |
P2(11:11) = "Y" |
| 103 |
RETURN {P2} |