#!/bin/tcsh -ef # # ABOUT : NOTCam imaging 9point beam-switch script. # Takes alternatingly 9 ON target and 9 OFF target images # giving two 9-point dithers separated by "beam" arcsec # with a dither step of "step" arcsec and possibly skewed # by an amount "skew" arcsec. # # The OFF position is selected by the user input # parameters "beam" (in arcseconds) and cardinal # sky directions (e,w,n,s) are set in "dir". In # this script we have introduced cardinal sky directions # for user friendliness, since one usually checks in which # direction to move from a finding chart, but one should # be aware that the directions will be correct only for the # default NOTCam field-r (-90). The teloffset command itself # is defined to "move the star x,y arcseconds on the array", # which is independent of field. The use of another than # default field (-90) is seldom, but may happen if guide stars # cannot be found. # # Useful for both cameras. Typically useful dither steps # are 10" for WF-cam and 5" for HR-cam. The "beam" # step size must be determined by the need to avoid # extended emission at the OFF position. # # USAGE : notcam.beamswitch [-e] [-nowakeup] rmode t N obj dir beam dith skew # -e : Echo script on stdout, do not execute # -nowakeup: No astrowakeup at the end of script # rmode : Readout mode (exp, mexp or frame) # t : Time between ramp-sampling reads or exptime # N : Number of readouts (only valid for frame) # obj : The object name # dir : Sky direction for beamswitch offset (S-posX,N-negX,E-negY,W-posY) # beam : Beamswitch large offset size (arcsec) # step : Small dithering offset size (arcsec) # skew : Skew offset (arcsec) # # DEPENDS : notcam.expose, notcam.teloffset, notcam.autosave_on # notcam.imtype, notcam.object, notcam.frames, # # PROVIDES: notcam.beamswitch # # TFUNCT : (Texp + Tread + Tsave + Tteloffset)*18 # # AUTHOR : Anlaug Amanda Djupvik # # HISTORY : 2008/05/26 (Initial release, AAD) # 2009/04/23 Changed notcaminst. -> notcam. (AAD) # 2009/05/10 User selects beam step and direction + dither step (AAD) # 2009/05/26 Upgraded to include skew mode. (AAD) # 2009/05/26 User selected readout mode added. (AAD) # 2009/09/28 Beamswitch direction renamed from "s,n,e,w" to "S-posX,N-negX,E-negY,W-posY" # 2010/09/13 Added -nowakeup as an option. (AAD) # 2010/09/29 Added notcam.clearobject (AAD) # 2011/04/13 Added script parameters to talker log (AAD) # 2011/05/15 Added Peter's filecheck algorithm (AAD) if ("$1" == "-e") then set e = "echo" shift else set e = "" endif set nowakeup = False if ("$1" == "-nowakeup") then set nowakeup = True shift endif # Get command line arguments set rmode = `echo "$1"` set t = `echo "$2" | sed -n -e '/^[0-9.]*$/p'` set N = `echo "$3" | sed -n -e '/^[0-9.]*$/p'` set obj = `echo "$4"` set dir = `echo "$5"` set beam = `echo "$6" | sed -n -e '/^[0-9.]*/p'` set step = `echo "$7" | sed -n -e '/^[0-9.]*/p'` set skew = `echo "$8" | sed -n -e '/^[0-9.]*/p'` # Check for errors in arguments if ($rmode == '' || $t == '' || $N == '' || "$obj" == '' || $dir == '' || $beam == '' || $step == '' || $skew == '') then echo "Error in arguments" echo "Usage : notcam.beamswitch [-e] [-nowakeup] rmode t N obj dir beam step skew" echo " " echo " [-e] = test mode, listing commands only" echo " [-nowakeup] = no astrowakeup at the end of script" echo " rmode = readout mode (exp, mexp or frame)" echo " t = time in seconds " echo " N = number " echo " obj = object name (if it contains space, then inside quotes) " echo " dir = sky direction for beamswitch (S-posX, N-negX, E-negY, W-posY)" echo " beam = beamswitch step size (in arcsec)" echo " step = dither step size (in arcsec)" echo " skew = optional skew offset (in arcsec)" echo " " echo " \e[00;32mNote that S,N,E,W refer to the direction you move the telescope " echo " for taking sky, while posX, negX, negY, posY refer to " echo " the direction your target moves on the array!" echo " The first is valid only for default field-rotation (field-r = -90)." echo " The latter is always valid.\e[00m" exit 1 endif # Check which readout mode and validate exposure time settings for each if ("$rmode" == "exp" || "$rmode" == "expose" || "$rmode" == "mexp" || "$rmode" == "mexpose") then if ("$rmode" == "exp" || "$rmode" == "expose") then set expmode = `echo "expose"` set N = `echo ""` else if ("$rmode" == "mexp" || "$rmode" == "mexpose") then set expmode = `echo "mexpose"` endif set tt = `echo "10*$t" | bc -l | awk '{printf ("%5i"),$1}'` if ($tt == 0) then echo "Zero exposure time not allowed. Exiting." exit 1 endif if ($tt < 30) then echo "For t < 3 s shutter effects may alter flux by > 1%." echo "For t = 2 s errors may be 3% and increase with smaller t." echo "Continue anyhow (y/n)?" set answ = $< if ("$answ" == "n") then echo " Interrupted. \n" exit 1 else if ("$answ" == "y") then echo "Be warned." else echo "Invalid option." exit 1 endif endif else if ("$rmode" == "frame" || "$rmode" == "frames") then set expmode = `echo "frames"` # Check that "t" in notcam.frames is >= 3.6 seconds set tt = `echo "10*$t" | bc -l | awk '{printf ("%5i"),$1}'` if ($tt < 36) then echo "Minimum t = 3.6 seconds. Exiting. \n" exit 1 endif # Check that "N" in notcam.frames is <= 14 if ($N > 14) then echo "Maximum N = 14. Exiting. " exit 1 endif else echo "Invalid option. Use frame or exp. Exiting. \n" exit 1 endif # Write to Talker logger -p local0.debug -t "$0" "[NOTE]: Script started as $0 $*" #logger -p local0.debug -t "notcam.beamswitch" "[NOTE]: notcam.beamswitch started" if ($dir == 'E-negY') then set skyx = 0 set skyy = -1 set objx = 0 set objy = 1 else if ($dir == 'W-posY') then set skyx = 0 set skyy = 1 set objx = 0 set objy = -1 else if ($dir == 'N-negX') then set skyx = -1 set skyy = 0 set objx = 1 set objy = 0 else if ($dir == 'S-posX') then set skyx = 1 set skyy = 0 set objx = -1 set objy = 0 else echo " \e[00;31mInvalid sky direction! Select among: S-posX, N-negX, E-negY, W-posY.\e[00m" echo " " echo " \e[00;32mNote that S,N,E,W refer to the direction you move the telescope " echo " for taking sky, the notation posX, negX, negY, posY refer to the " echo " direction your target moves on the array!" echo " The first is valid only for default field-rotation (field-r = -90)," echo " while the latter is valid always.\e[00m" exit 1 endif # Calculate the large beamswitch offsets to sky field set sbx = `echo "$skyx*$beam" | bc -l` set sby = `echo "$skyy*$beam" | bc -l` # Calculate the large beamswitch offsets back to target set obx = `echo "$objx*$beam" | bc -l` set oby = `echo "$objy*$beam" | bc -l` # Calculate the back-to-target offsets with dithering set obxmindit = `echo "$obx-$step" | bc -l` set obxpludit = `echo "$obx+$step" | bc -l` set obymindit = `echo "$oby-$step" | bc -l` set obypludit = `echo "$oby+$step" | bc -l` # Calculate the back-to-target offsets with "skew grid" added set obxpsk = `echo "$objx*$beam+$skew" | bc -l` set obxmsk = `echo "$objx*$beam-$skew" | bc -l` set obypsk = `echo "$objy*$beam+$skew" | bc -l` set obymsk = `echo "$objy*$beam-$skew" | bc -l` # Execute or Echo script set files_expected = '18' set startdate = `date -u +"%Y-%m-%dT%H:%M:%S"` $e notcam.autosave_on $e notcam.object "$obj 1" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 1" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxpludit $obypsk $e notcam.object "$obj 2" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 2" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxmsk $obypludit $e notcam.object "$obj 3" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 3" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxmindit $obymsk $e notcam.object "$obj 4" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 4" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxmindit $obymsk $e notcam.object "$obj 5" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 5" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxpsk $obymindit $e notcam.object "$obj 6" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 6" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxpsk $obymindit $e notcam.object "$obj 7" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 7" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxpludit $obypsk $e notcam.object "$obj 8" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 8" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxpludit $obypsk $e notcam.object "$obj 9" $e notcam.imtype OBJECT $e notcam.$expmode $t $N $e notcam.teloffset $sbx $sby $e notcam.object "sky 9" $e notcam.imtype SKY $e notcam.$expmode $t $N $e notcam.teloffset $obxmindit $obypludit $e notcam.teloffset -$skew -$skew $e notcam.imtype OBJECT $e notcam.clearobject # sleep 4 set enddate = `date -u +"%Y-%m-%dT%H:%M:%S"` set files_written = `~staff/MISC/fits.countfiles NCprihdu $startdate $enddate` if ($files_expected != $files_written) then $e logger -p local0.debug -t "notcam.beamswitch" "[WARNING]: Only $files_written out of $files_expected files seems written to disk. Please check observing log." echo "  Only $files_written out of $files_expected files seems written to disk. Please check observing log. " endif $e logger -p local0.debug -t "notcam.beamswitch" "[NOTE]: files written: " $files_written if ($nowakeup == False) then $e astrowakeup endif # All done. Exit with error status 0 and write to Talker logger -p local0.debug -t "notcam.beamswitch" "[NOTE]: notcam.beamswitch ended successfully" echo "\n  notcam.beamswitch ready \n" exit 0