1
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
!.COPYRIGHT (C) 1993,2005 European Southern Observatory
4
!.AUTHOR Rein H. Warmels, ESO-Garching
5
!.KEYWORDS Direct imaging, CCD package
6
!.PURPOSE Do the reduction of a single image
7
!.USE: @s ccdredfrm p1 p2
8
!. where p1 is input frame
10
!.NOTE After each reduction step the CCD descriptor CCDRED is updated
11
! (write 1) to indicate that the reduction step is done.
12
! The following elements are allocated:
13
! CCDSTAT(1) for overscan correction
14
! CCDSTAT(2) for trimming the frame
15
! CCDSTAT(3) for bad pixel correction
16
! CCDSTAT(4) for bias subtraction
17
! CCDSTAT(5) for dark current subtraction
18
! CCDSTAT(6) for flat fielding
19
! CCDSTAT(7) for the illumination correction
20
! CCDSTAT(8) for fringing correction
21
!.VERSION 921009 RHW Creation
22
!.VERSION 930330 RHW Additional checks
23
!.VERSION 971117 SW correct. labels have to be local (CCDCORS->CCD_CRS)
25
!------------------------------------------------------------------------------
27
DEFINE/PARAM P1 ? IMA "Enter the input frame to reduce:"
28
DEFINE/PARAM P2 ? IMA "Enter output result frame:"
29
DEFINE/PARAM P3 N C "Overwrite the output frame [N]:"
31
DEFINE/LOCAL IND/I/1/1 0
32
DEFINE/LOCAL IDOT/I/1/1 0
33
DEFINE/LOCAL CCD_CRS/C/1/30 " " ALL
35
! The correction label string CCDCORS which will be checked by CCDCORRECT.PRG
36
! has to be local, in order to always get the right link to the actual frame.
37
! In a global definition the correction labels may overwritten by other pre-
38
! pared frames which leads to unwished actions to previous frames.
39
! That is the reason for defining a new local keyword CCD_CRS which will now
40
! do the work of CCDCORS and CCDOR together (SW,97.11.17).
42
! *** find out the exposure type
43
IF M$EXISTD(P1,EXP_DESC) .EQ. 0 THEN
44
WRITE/OUT "{P1}: *** WARNING: Frame descriptor {EXP_DESC}"
45
WRITE/OUT " exposure type descriptor not found ---> NOT REDUCED <---"
48
DEFINE/LOCAL EXP_TYP/C/1/10 "{{P1},{EXP_DESC}}" ! exposure type
51
! *** see if there is a status descriptor
52
IF M$EXISTD(P1,"CCDSTAT") .EQ. 0 THEN
53
WRITE/DESCR {P1} CCDSTAT/I/1/10 0 ALL
56
! *** remove the .bdf extension of the calibration frames
57
IDOT = M$INDEX(SC_BSFRM,".bdf") - 1
59
SC_BSFRM = "{SC_BSFRM(1:{IDOT})}"
61
IDOT = M$INDEX(SC_DKFRM,".bdf") - 1
63
SC_DKFRM = "{SC_DKFRM(1:{IDOT})}"
65
IDOT = M$INDEX(SC_FFFRM,".bdf") - 1
67
SC_FFFRM = "{SC_FFFRM(1:{IDOT})}"
69
IDOT = M$INDEX(SC_ILFRM,".bdf") - 1
71
SC_ILFRM = "{SC_ILFRM(1:{IDOT})}"
73
IDOT = M$INDEX(SC_FRFRM,".bdf") - 1
75
SC_FRFRM = "{SC_FRFRM(1:{IDOT})}"
78
! *** define the reduction keywords
79
CCDCOR = "no " ! calibration
80
CCDCORS = "XXXXXXXXXXXXXXXXXXXX" ! init flags
83
WRITE/OUT "{P1}: Start reduction; output frame {P2}"
84
! *** here for the overscan, trimming, and bad pixel correction
85
@s prep_scan {P1} {CCD_CRS} ! get the overscan
87
@s prep_trim {P1} {CCD_CRS} ! get trim section
89
@s prep_fix {P1} {CCD_CRS} ! get pixel correct.
92
! *** now do the exposure type dependent correction
94
BRANCH EXP_TYP(1:2) BS,DK,FF,SK,IL,SC-
95
BIAS,DARK,FLAT,FLAT,ILLUM,SCIENCE
97
BRANCH EXP_TYP(1:3) BIA,DAR,FFD,FFS,SKY,ILL,SCI-
98
BIAS,DARK,FLAT,FLAT,FLAT,ILLUM,SCIENCE
101
{BS_TYP(1:4)},{DK_TYP(1:4)},{FF_TYP(1:4)},{SK_TYP(1:4)},{IL_TYP(1:4)},{SC_TYP(1:4)} -
102
BIAS,DARK,FLAT,FLAT,ILLUM,SCIENCE
103
! this branch has been added by swolf@eso.org (06.05.98)
104
!in order to be more flexible in identifying the process to be done!
106
WRITE/OUT "{P1}: *** WARNING: Frame descriptor {EXP_DESC} = {{P1},{EXP_DESC}}"
107
WRITE/OUT " exposure type unknown ---> NOT REDUCED <---"
108
WRITE/OUT " . default exposure types: BS, DK, FF, SK, IL, SC"
109
WRITE/OUT " . or select exposure types by ??_TYP = {{P1},{EXP_DESC}}"
112
! *** bias correction frame
116
! *** here for dark current frame
118
@s prep_bias {P1} {CCD_CRS} ! get bias frame
122
! *** here for flat field frame
124
@s prep_bias {P1} {CCD_CRS} ! get bias frame
126
@s prep_dark {P1} {CCD_CRS} ! get dark frame
129
!CCDCORS(11:11) = "Y"
132
! *** here for the illumination frame
134
@s prep_bias {P1} {CCD_CRS} ! get bias frame
136
@s prep_dark {P1} {CCD_CRS} ! get dark frame
138
@s prep_flat {P1} {CCD_CRS} ! get flat frame
142
! *** here for the object
144
@s prep_bias {P1} {CCD_CRS} ! get bias frame
146
@s prep_dark {P1} {CCD_CRS} ! get dark frame
148
@s prep_flat {P1} {CCD_CRS} ! get flat frame
150
@s prep_illum {P1} {CCD_CRS} ! get illum. frame
152
@s prep_fring {P1} {CCD_CRS} ! get fringe frame
156
! *** all done: frames are prepared to be used in final step
158
IF CCD_CRS(11:11) .EQ. "Y" THEN
160
@s ccdcorrect {P1} {P2} {CCD_CRS}
162
HISTORY/C/-1/80 "Processed by @s ccdredfrm {P1} {P2}"
163
IF VERBOSE(1:1) .EQ. "Y" THEN
164
STATISTIC/IMAGE {P2} {IM_SEC} ? ? FF ! full statistics
166
STATISTIC/IMAGE {P2} {IM_SEC} ? ? FN ! short statistics
168
WRITE/OUT "{P1}: Reduction completed, output is in {P2}"
170
ELSEIF SC_PROC .EQ. "yes" THEN
171
WRITE/OUT "{P1}: *** NO REDUCTION *** SC_PROC option was set"
176
"{P1}: *** INFO: Calibration already done, OR problems ..."
180
! *** here calculated the mean of the flat field
181
IF EXP_TYP(1:2) .EQ. "FF" THEN
184
IF EXP_TYP(1:2) .EQ. "IL" THEN
187
IF EXP_TYP(1:2) .EQ. "FR" THEN