! @(#)pfocus.prg 1.0 (ESO-ASD) 28/11/96 19:02:00 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !.IDENT pfocus.prg !.PURPOSE Determine focus correction (and good focus value) from an ! image taken with the focus pyramid in the beam. !.USE @c pfocus !.AUTHOR Jesper Storm (adapted from wfocus.prg by Cristian Levin) !.VERSION 1.0 28/11/96 Creation !.VERSION 1.1 20/01/97 obsinit contains constants !.VERSION 1.2 06/10/98 Adapted to call foc_db (JBR) !.KEYWORDS ! -------------------------------------------------------------- ! ! EXTERNAL VARIABLES: ! telpscal, campscal, signpyra, distpyrx, distpyry, imscale ! ! distpyrx and distpyry are in arcseconds (!) ! ------------------------------------------------------ ! ! define/local dx/r/1/1 0.0 define/local dy/r/1/1 0.0 define/local df/r/1/1 0.0 define/local dtelf/r/1/1 0.0 define/local xup/r/1/1 0.0 define/local xdown/r/1/1 0.0 define/local xleft/r/1/1 0.0 define/local xright/r/1/1 0.0 define/local yup/r/1/1 0.0 define/local ydown/r/1/1 0.0 define/local yleft/r/1/1 0.0 define/local yright/r/1/1 0.0 define/local dhoriz/r/1/1 0.0 define/local dvert/r/1/1 0.0 define/local dcamf/r/1/1 0.0 define/local bx/r/1/1 0.0 define/local by/r/1/1 0.0 define/local d_filt/C/1/10 define/local fa_filt/C/1/10 define/local fb_filt/C/1/10 define/local RA/r/1/1 0.0 define/local DEC/r/1/1 0.0 define/local MJD/r/1/1 0.0 define/local date/r/1/1 0. define/local exptime/r/1/1 0. create/table focleft 15 0 null create/table focright 15 0 null create/table focup 15 0 null create/table focdown 15 0 null clear/chan overlay ! define/local ioff/i/1/2 0,0 ioff = ididev(6)*ididev(15)+1 !offset into keyword IDIMEMC ioff(2) = ioff(1)+19 define/local cmc/c/1/20 {idimemc({ioff}:{ioff(2)})} ! @c get_mode {cmc} ! get the observing mode ! dx = {distpyrx} / {imscale} ! Convert to pixels dy = {distpyry} / {imscale} ! Convert to pixels bx = 0.8 * {dx} ! Set the fitting box size by = 0.8 * {dy} ! write/out write/out "Point to the left-most images in a number of quartets" write/out ! ! We force the box size to be just big enough to not include the ! other objects in the quartet, but big enough to allow a certain ! variation in position. Note also that perfect alignment is not ! required, but the program assumes a reasonable alignment to be able ! to find the other components of the quartet. ! The alignment should be such that the diagonals in the square ! are approximately aligned with the columns and rows of the CCD. ! center/gauss cursor focleft ? 1 {bx},{by} ! ! Optionally one could use the zoom window for each quartet ! ! center/gauss cursor focleft ? 1 {bx},{by} W,4 if outputi(1) .eq. 0 then write/out write/out Invalid number of coordinates. return endif ! compute/table focleft :xstart = :xstart + {dx} compute/table focleft :xend = :xend + {dx} ! center/gauss {cmc},focleft focright ? 1 {bx},{by} ! compute/table focleft :xstart = :xstart - 0.5 * {dx} compute/table focleft :xend = :xend - 0.5 * {dx} compute/table focleft :ystart = :ystart - 0.5 * {dy} compute/table focleft :yend = :yend - 0.5 * {dy} ! center/gauss {cmc},focleft focdown ? 1 {bx},{by} ! compute/table focleft :ystart = :ystart + {dy} compute/table focleft :yend = :yend + {dy} ! center/gauss {cmc},focleft focup ? 1 {bx},{by} set/midas output=no ! we don't want output on the screen... ! statist/table focleft :xcen xleft = outputr(3) ! mean value statist/table focleft :ycen yleft = outputr(3) ! mean value ! statist/table focright :xcen xright = outputr(3) ! mean value statist/table focright :ycen yright = outputr(3) ! mean value ! statist/table focdown :xcen xdown = outputr(3) ! mean value statist/table focdown :ycen ydown = outputr(3) ! mean value ! statist/table focup :xcen xup = outputr(3) ! mean value statist/table focup :ycen yup = outputr(3) ! mean value ! set/midas output=yes ! ! Compute the distance between the points in the diagonals ! dhoriz = m$sqrt(({xright} - {xleft})**2 + ({yright} - {yleft})**2) dvert = m$sqrt(({xup} - {xdown})**2 + ({yup} - {ydown})**2 ) ! ! Compute the f-shift ! df = {signpyra} * ({dx} - {dhoriz} + {dy} - {dvert}) ! ! TELESCOPE and CAMERA focus offsets ! dtelf = {telpscal} * {df} / 2. dcamf = {campscal} * {df} ! ! Write results to screen... ! write/out write/out set/format F6.1 write/out write/out Up: {xup},{yup} Left: {xleft},{yleft} Right: {xright},{yright} Down: {xdown},{ydown} write/out set/format F8.3 write/out X-shift = {dhoriz}, Y-shift = {dvert}, F-shift = {df} write/out write/out "-------------------------------------------------------------------------" ! write/out " CAMERA focus offset:" {dcamf} set/format F6.1 write/out " TELESCOPE focus offset:" {dtelf} set/format ! ! Clean up the mess ! delete/tab focleft NO delete/tab focright NO delete/tab focup NO delete/tab focdown NO ! ! Get DFOSC and FASU filter IDs from the image header. Note: MIDAS does ! not like hashes, the format of the DFOSC Filter ID is ESO#XXX, whilst ! that of FASU is #XXX. All of the below is to extract the filter number ! only. ! define/local tmp1/c/1/7 " NF" copy/dk {cmc} _EIO2_ID tmp1 ! DFOSC Filter ID copy/keyword tmp1/c/5/3 d_filt/c/1/3 define/local tmp2/c/1/4 " NF" copy/dk {cmc} _EIO4_ID tmp2 ! FASU B Filter copy/keyword tmp2/c/2/3 fb_filt/c/1/3 define/local tmp3/c/1/4 " NF" copy/dk {cmc} _EIO5_ID tmp3 ! FASU A Filter copy/keyword tmp3/c/2/3 fa_filt/c/1/3 ! ! Get other parameters from image header... ! set/format I5 F12.6 copy/dk {cmc} CAMERA camfoc ! DFOSC Camera focus value copy/dk {cmc} O_POS O_POS copy/dk {cmc} O_TIME O_TIME copy/dk {cmc} ST ST copy/dk {cmc} ZDIST ZD copy/dk {cmc} HA HA ! Note -- must define below variables as I'm not copying... RA = O_POS(1) ! Self explanatory DEC = O_POS(2) ! Self explanatory MJD = O_TIME(4) ! MJD at *start* of observation. date = O_TIME(1) ! Day of exposure (integer days!) exptime = O_TIME(7) ! DFOSC exposure time date = {O_TIME(1)}+({O_TIME(5)}+{O_TIME(7)}/2.0/60.0/60.0)/24.0/365.0 !write/out {date} {exptime} ! Just to test stuff... ! ! Call the shell script to write info to the database. Put in background ! in case of problems... ! write/out "Adding measurement to Danish 1.54-m focus database..." $~meteolog/scripts/foc_db {date} {exptime} {d_filt} {fa_filt} {fb_filt} {dtelf} {camfoc} {HA} {DEC} {ZD} ! ! To circumvent a 94NOV MIDAS bug we reassign the print device ! assign/print TERMINAL ! ! The End... ! STOP: