Debian Codegraph @

stdred/ccdred/proc/ccdredfrm.prg

raw
1 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 !.COPYRIGHT (C) 1993,2005 European Southern Observatory
3 !.IDENT ccdredfrm.prg
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
9 !. p2 in output 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)
24 ! 050309 last modif
25 !------------------------------------------------------------------------------
26 !
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]:"
30 !
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
34 !
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).
41 !
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 <---"
46 RETURN -1
47 ELSE
48 DEFINE/LOCAL EXP_TYP/C/1/10 "{{P1},{EXP_DESC}}" ! exposure type
49 ENDIF
50 !
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
54 ENDIF
55 !
56 ! *** remove the .bdf extension of the calibration frames
57 IDOT = M$INDEX(SC_BSFRM,".bdf") - 1
58 IF IDOT .GT. 0 THEN
59 SC_BSFRM = "{SC_BSFRM(1:{IDOT})}"
60 ENDIF
61 IDOT = M$INDEX(SC_DKFRM,".bdf") - 1
62 IF IDOT .GT. 0 THEN
63 SC_DKFRM = "{SC_DKFRM(1:{IDOT})}"
64 ENDIF
65 IDOT = M$INDEX(SC_FFFRM,".bdf") - 1
66 IF IDOT .GT. 0 THEN
67 SC_FFFRM = "{SC_FFFRM(1:{IDOT})}"
68 ENDIF
69 IDOT = M$INDEX(SC_ILFRM,".bdf") - 1
70 IF IDOT .GT. 0 THEN
71 SC_ILFRM = "{SC_ILFRM(1:{IDOT})}"
72 ENDIF
73 IDOT = M$INDEX(SC_FRFRM,".bdf") - 1
74 IF IDOT .GT. 0 THEN
75 SC_FRFRM = "{SC_FRFRM(1:{IDOT})}"
76 ENDIF
77 !
78 ! *** define the reduction keywords
79 CCDCOR = "no " ! calibration
80 CCDCORS = "XXXXXXXXXXXXXXXXXXXX" ! init flags
81 CCD_CRS = CCDCORS
82 !
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
86 CCD_CRS = "{Q1}"
87 @s prep_trim {P1} {CCD_CRS} ! get trim section
88 CCD_CRS = "{Q1}"
89 @s prep_fix {P1} {CCD_CRS} ! get pixel correct.
90 CCD_CRS = "{Q1}"
91 !
92 ! *** now do the exposure type dependent correction
93 !
94 BRANCH EXP_TYP(1:2) BS,DK,FF,SK,IL,SC-
95 BIAS,DARK,FLAT,FLAT,ILLUM,SCIENCE
96
97 BRANCH EXP_TYP(1:3) BIA,DAR,FFD,FFS,SKY,ILL,SCI-
98 BIAS,DARK,FLAT,FLAT,FLAT,ILLUM,SCIENCE
99
100 BRANCH EXP_TYP(1:4)
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 [email protected] (06.05.98)
104 !in order to be more flexible in identifying the process to be done!
105
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}}"
110 RETURN -2
111 !
112 ! *** bias correction frame
113 BIAS:
114 GOTO DORED
115 ! ! do nothing
116 ! *** here for dark current frame
117 DARK:
118 @s prep_bias {P1} {CCD_CRS} ! get bias frame
119 CCD_CRS = "{Q1}"
120 GOTO DORED
121 !
122 ! *** here for flat field frame
123 FLAT:
124 @s prep_bias {P1} {CCD_CRS} ! get bias frame
125 CCD_CRS = "{Q1}"
126 @s prep_dark {P1} {CCD_CRS} ! get dark frame
127 CCD_CRS = "{Q1}"
128 CCD_CRS(11:11) = "Y"
129 !CCDCORS(11:11) = "Y"
130 GOTO DORED
131 !
132 ! *** here for the illumination frame
133 ILLUM:
134 @s prep_bias {P1} {CCD_CRS} ! get bias frame
135 CCD_CRS = "{Q1}"
136 @s prep_dark {P1} {CCD_CRS} ! get dark frame
137 CCD_CRS = "{Q1}"
138 @s prep_flat {P1} {CCD_CRS} ! get flat frame
139 CCD_CRS = "{Q1}"
140 GOTO DORED
141 !
142 ! *** here for the object
143 SCIENCE:
144 @s prep_bias {P1} {CCD_CRS} ! get bias frame
145 CCD_CRS = "{Q1}"
146 @s prep_dark {P1} {CCD_CRS} ! get dark frame
147 CCD_CRS = "{Q1}"
148 @s prep_flat {P1} {CCD_CRS} ! get flat frame
149 CCD_CRS = "{Q1}"
150 @s prep_illum {P1} {CCD_CRS} ! get illum. frame
151 CCD_CRS = "{Q1}"
152 @s prep_fring {P1} {CCD_CRS} ! get fringe frame
153 CCD_CRS = "{Q1}"
154 GOTO DORED
155 !
156 ! *** all done: frames are prepared to be used in final step
157 DORED:
158 IF CCD_CRS(11:11) .EQ. "Y" THEN
159
160 @s ccdcorrect {P1} {P2} {CCD_CRS}
161 WRITE/DESCR {P2} -
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
165 ELSE
166 STATISTIC/IMAGE {P2} {IM_SEC} ? ? FN ! short statistics
167 ENDIF
168 WRITE/OUT "{P1}: Reduction completed, output is in {P2}"
169
170 ELSEIF SC_PROC .EQ. "yes" THEN
171 WRITE/OUT "{P1}: *** NO REDUCTION *** SC_PROC option was set"
172 RETURN 0
173
174 ELSE
175 WRITE/OUT -
176 "{P1}: *** INFO: Calibration already done, OR problems ..."
177 RETURN -3
178 ENDIF
179 !
180 ! *** here calculated the mean of the flat field
181 IF EXP_TYP(1:2) .EQ. "FF" THEN
182 @s ccdmean {P1}
183 ENDIF
184 IF EXP_TYP(1:2) .EQ. "IL" THEN
185 @s ccdmean {P1}
186 ENDIF
187 IF EXP_TYP(1:2) .EQ. "FR" THEN
188 @s ccdmean {P1}
189 ENDIF
190
191 RETURN 0