Debian Codegraph @

stdred/ccdred/proc/prep_flat.prg

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