#!/bin/csh -f #+ #OSIRIS library of scripts # #NAME # osirisRefocusAO - change the AO focus to match sscale # #SYNOPSIS # osirisRefocusAO arg1 mode [-t #] [-m] etc... # #DESCRIPTION # The 4 plate scales of OSIRIS are not parfocal. This script corrects # that by moving the FCS (NGS) or TSS (LGS/NGS-ST). # #OPTIONS # -t # # ID number to attach to all script generated errors, warnings, and # questions that are passed to the OGS. The ID number is separated # from the rest of the message with a ";". # # -m # simulate calls to RPC servers. during simulated calls, the # command is echoed (instead of being executed). # # others? # #EXAMPLES # osirisRefocusAO junk1 -t 123 # What would happen? # #ENVIRONMENT VARIABLES # list of environment variables used # #FILES # list of files used # #SERVERS & KEYWORDS # list of the servers and keywords used, for example: # # service = osiris # keywords: sscale # #SCRIPTS CALLED # list of the scripts called by this script, for example: # # help, syncheck # #EXIT STATUS # 0 - normal exit, no error # 1 - script aborted by an interrupt # 2 - syncheck error # 3 - error parsing command line input # other errors... # #SEE ALSO # ??? #- # # Modification History: # 20041124 - MB: Initial version created # 20130115 - jlyke: mods for K1 post-IF # 20140122 - jlyke: mods for TRICK on K1 # 20190119 - jlyke: updates for imager upgrade # # Boiler plate for "-h" support for command autohelp. if ("$1" == "-h") then help $0 | more exit $status endif # Boilerplate for syncheck. # Note that the boiler plate should be transparent for all usages, # but to make correct use of syncheck you will need to specify the # correct pattern. set noglob set CheckStatus = `syncheck -command $0 $* -pattern {text...}` unset noglob if ("$CheckStatus" != "OK") then help $0 | more exit 2 endif # End of help/syncheck boiler plate. # Set up to trap interrupts (Ctrl-C, etc.) onintr abort # Set default variable values set cmdpre = "" set cmdsuf = "" set idnum = 0 set scalelist = "[IMAG,Imag,imag,0.020,0.02,20,0.035,35,0.050,0.05,50,0.100,0.10,0.1,100]" ################################################################## # OSIRIS Scale to Scale offsets ################################################################## # define offsets for ( 100, 50, 35, 20, Imager) mas scales in mm # we calibrate to the 20 mas scale so its offset is 0.00 by def. # 2008 Mar 23 #set offsets = ( -1.52 0.33 -0.48 0.00 0.00 ) # 2008 May 07 #set offsets = ( -1.36 0.31 -0.56 0.00 0.00 ) # 2009 Apr 13 #set offsets = ( -1.99 1.96 -0.28 0.00 0.00 ) # 2012 Apr 02 #set offsets = ( -0.29 0.11 -0.45 0.00 -0.33 ) # 2013 Feb 13 # Image sharpening now is run on imager in Kn4 so imager offset is 0.00 by def. #set offsets = ( 0.04 0.44 -0.12 0.33 0.00 ) # 2013 Dec 04 #set offsets = ( 0.48 0.73 0.10 0.32 0.00 ) # 2017 May 10 #set offsets = ( -0.20 -0.33 0.16 -0.32 0.00 ) # 2017 Dec 04 #set offsets = (0.40 -0.21 0.17 0.00 0.00 ) # 2018 Feb 11 #set offsets = (-0.08 0.16 -0.44 0.00 8.12) # 2018 Aug 29 #set offsets = (-0.08 0.16 -0.44 0.00 8.50) # 2018 Oct 21 #set offsets = (-0.08 0.16 -0.44 0.00 -0.40) # 2018 Oct 23 #set offsets = (-0.14 0.23 -0.32 0.00 -0.39) # 2019 May 28 set offsets = (-0.14 0.23 -0.32 0.00 0.00) ################################################################## # AO Bench TRICK (NIRTTS) Dichroic Focus Offsets ################################################################## # The TRICK dichroics introduce a focus offset (and image shift). # Will use osirisRefocusAO to handle the focus change # # First check that we are using TRICK # The TRICK dichroic is a single axis stage that has 4 named positions. # OBTDNAME: home, open, kBand, hBand # OBTD : 0.00, -0.001, -0.117, -0.267 (in meters) #set trickoff = ( 0.00 0.00 -4.45 -4.00 ) set trickoff = ( 0.00 0.00 0.00 0.00 ) # obtd is a new AO keyword. show -s ao obtd >& /dev/null if ($status == 0) then set trick = 1 else set trick = 0 endif if ( $trick == 1 ) then set tname = `show -s ao -terse obtdname` # force the output to be lower case for easier matching set tdname = `echo $tname | /usr/bin/tr "[A-Z]" "[a-z]"` switch ($tdname) case home: set aooff = ${trickoff[1]} breaksw case open: set aooff = ${trickoff[2]} breaksw case kband: set aooff = ${trickoff[3]} breaksw case hband: set aooff = ${trickoff[4]} breaksw default: set aooff = 0.00 breaksw endsw else set aooff = 0.00 endif # Check for flags set noglob while ($#argv != 0) ##echo "${0} ${mode}: Checking ${1}..." switch ($1) case -t: set CheckStatus = `syncheck -command $1 $2 -pattern int` if ("$CheckStatus" == "OK") then set idnum = $2 shift else echo "${0} ${mode}: Invalid script ID number specified <${2}> - using ${idnum}." endif unset Checkstatus breaksw case -m: set sim set cmdpre = "echo ${0}: sim:" set cmdsuf = "-m" breaksw case -x: echo $1 $2 set CheckStatus = `syncheck -command $1 $2 -pattern ${scalelist}` if ("$CheckStatus" == "OK") then set sscale = $2 shift else set errmsg = "${cmd} ${mode}: Invalid scale specified <${2}> - aborting." echo $errmsg unset errmsg exit 2 endif unset Checkstatus breaksw case -f: echo $1 $2 set sscale = 'None' set osrsoff = $2 shift breaksw default: echo "${0}: Invalid command line flag $1 specified." echo "${0}: Usage: $0 [-t #] [-m]" # set the error code for an error with command line input exit 3 breaksw endsw shift end unset noglob ### K2 # check if AO bench is configured for OSIRIS # ao keywords obof (mm) is most reliable # obofname of "out" is obof greater than 140 mm #set ofmpos = `show -s ao -terse obof | cut -d"." -f1` #if ( $ofmpos > 140 ) then ### K1 # check if AO bench is configured for OSIRIS # obdbname = open, obimname = out for OSIRIS #set dfb = `show -s ao -terse obdbname` #set ism = `show -s ao -terse obimname` set dfb = 'open' set ism = 'out' if ( $dfb == 'open' && $ism == 'out' ) then switch ($sscale) case 0.100: case 0.10: case 0.1: case 100: set osrsoff = ${offsets[1]} breaksw case 0.050: case 0.05: case 50: set osrsoff = ${offsets[2]} breaksw case 0.035: case 35: set osrsoff = ${offsets[3]} breaksw case 0.020: case 0.02: case 20: set osrsoff = ${offsets[4]} breaksw case Imag: case imag: case IMAG: set osrsoff = ${offsets[5]} breaksw default: breaksw endsw # combine the AO offsets and OSIRIS offsets set deltafoc = `math "$aooff + $osrsoff"` set lgstssoffset = `math "$deltafoc / 1000."` # in m $cmdpre modify -s ao aoscts00 = $lgstssoffset $cmdpre modify -s ao aofcc0io = $deltafoc sleep 1 $cmdpre modify -s ao obfmgoim = true else echo "${0}: AO bench not configured for OSIRIS" endif goto done abort: # Block of code to handle interrupts. exit 1 done: # is there anything that needs to go here? exit