1
! @(#)irac_focus.prg 19.1 (ES0-DMD) 02/25/03 14:22:55
2
! @(#)irac_focus.prg 19.1 (ESO-Chile) 02/25/03 14:22:55
3
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
!.COPYRIGHT (C) 1995 European Southern Observatory
6
!.AUTHOR C. Lidman, ESO-Chile
7
!.KEYWORDS IRAC package
8
!.PURPOSE procedure to determine the correct focus
9
!.NOTE Adapted from comb.prg
10
!.VERSION 950826 C. Lidman Creation
12
! 951031 CEL Selection by sequence name corrected
13
!-------------------------------------------------------
14
crossref select seqname focout create
16
define/par p1 null C "Enter sequence name:"
17
define/par p2 focus C "Name of output/input image:"
18
define/par p3 Y C "Create Image:"
22
write/out {p1},{p2},{p3}
24
!Check Input parameter bounds.
26
def/local last/I/1/1 100
28
def/local upper/I/1/1 1
29
def/local readout/I/1/1 2
30
def/local gain/R/1/1 6.6
31
def/local ndit/I/1/1/ 10
32
def/local ron/r/1/1 49.
33
def/local med/r/1/1 0.0
34
def/local scale/r/1/1 0.49
35
def/local lens/c/1/2 LC
36
def/local filter/c/1/4/ K
37
def/local s_lens/c/1/2 LC
38
def/local s_filter/c/1/4/ K
39
def/local s_readou/I/1/1 2
40
def/local error/I/1/1 0
41
def/local cont/C/1/1 Y
42
def/local exist/I/1/1 1
43
def/local medran/I/1/1 0
44
def/local focus/R/1/1 3000.0
45
def/local a2/d/1/1 0.0
46
def/local a3/d/1/1 0.0
47
def/local xfocus/d/1/1 3000.0
48
def/local yfocus/d/1/1 3000.0
49
def/local average/d/1/1 3000.0
50
define/loc focname/C/1/20 "focfunction"
51
IF M$EXIST("{focname}.fit") .EQ. 0 THEN
52
IF AUX_MODE(1) .LE. 1 THEN ! VMS
53
define/local fmtdir/c/1/60 -
54
"MID_DISK:[&MIDASHOME.&MIDVERS.STDRED.IRAC2.LIB]"
56
define/local fmtdir/c/1/60 -
57
"$MIDASHOME/$MIDVERS/stdred/irac2/lib/"
59
-COPY {fmtdir}{focname}.fit {focname}.fit ! copy
62
copy/table irac2b_ost work
64
delete/col work :MJD :DATE :AZIMUTH :ALTITUDE
66
select/table work :SEQID .eq. {p1}
77
!Determine the readout mode
79
copy/dk {work2,FILENAME,@1} _ED_NCORRS readout
80
copy/dk {work2,FILENAME,@1} _ED_NDIT ndit
81
copy/dk {work2,FILENAME,@1} _EIO3_NAME lens
82
copy/dk {work2,FILENAME,@1} _EIO2_NAME filter
84
If lens .eq. "LA" then
86
elseif lens .eq. "LB" then
88
elseif lens .eq. "LC" then
90
elseif lens .eq. "LD" then
92
elseif lens .eq. "LE" then
96
!Check the compatability of filters, lens, readout mode etc.
97
!This could be extended to other optical elements
101
copy/dk {work2,FILENAME,@1} _ED_NCORRS s_readou
102
copy/dk {work2,FILENAME,@1} _EIO2_NAME s_filter
103
copy/dk {work2,FILENAME,@1} _EIO3_NAME s_lens
105
if {s_readou} .ne. {readout} then
106
write/out Incompatable readout modes.
110
if "{s_filter}" .ne. "{filter}" then
111
write/out Incompatable filters.
115
if "{s_lens}" .ne. "{lens}" then
116
write/out Incompatible lenses.
122
if {error} .eq. 2 then
124
elseif {error} .eq. 1 then
125
inquire/key cont "Do wish to continue (Y/N):"
126
if cont .eq. "N" then
131
create/icat obj.cat work2,:FILENAME
133
!The average command will need to be replaced with the combine/ccd command,
134
!as the combine/ccd command is likely to create the better skies.
135
!The Combine/ccd command requires, at the very least, an association table to
136
!work. There is a strange problem with the calculation of the mode.
137
!For now we shall stick with the average command.
139
write/out skynum={last}
143
if {medran} .le. 0 then
147
average/images sky = obj.cat ? ? min,{medran}
149
average/images obj = obj.cat
150
comp/ima {p2} = obj - sky
152
!Display the image and ask the user to select the object to determine the focus
158
center/gauss CURSOR focus ? ? 10,10
160
create/col focus :focus r
163
copy/dk {work2,FILENAME,@{n}} _ET_FOC_POS focus
164
write/table focus :focus @{n} {focus}
167
set/graph binmode=off
169
plot/table focus :focus :xsig ? 2 0
171
overplot/table focus :focus :ysig ? 3 0
175
fit/table 100,0.000001,0.2 focus :xsig :focus focfunction
177
compute/fit focus :xout = focfunction(:focus)
178
overplot/table focus :focus :xout ? 0 2
182
copy/dk focfunction.fit fitparam/d/2/1 a2
183
copy/dk focfunction.fit fitparam/d/3/1 a3
184
xfocus = {a2}/(-2.*a3)
185
write/out x-focus is {xfocus}
188
fit/table 100,0.000001,0.2 focus :ysig :focus focfunction
190
compute/fit focus :yout = focfunction(:focus)
192
overplot/table focus :focus :yout ? 0 2
195
copy/dk focfunction.fit fitparam/d/2/1 a2
196
copy/dk focfunction.fit fitparam/d/3/1 a3
197
yfocus = {a2}/(-2.*a3)
198
write/out y-focus is {yfocus}
200
average = ({xfocus} + {yfocus})/2.
204
write/out Average = {average}
206
!Clean up loose files