#!/bin/sh #+ # acquire_slit_alignment_exposure -- take a DEIMOS slitmask alignment exposure # # Purpose: # Acquire a slitmask alignment exposure with optional binning and # windowing, and restore the original parameters afterwards. # # Usage: # acquire_slit_alignment_exposure [-binning ] [-window ] [-exptime ] # # Arguments: # factor = CCD binning factor (N,N) [default=current] # mode = windowing mode (Manual|FullFrame|MaskArea|AlignArea) [default=current] # # Output: # transcript to stdout # # Restrictions: # None # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Example: # 1) Acquire fullframe image binned by 1 in x and 2 in Y: # acquire_slit_alignment_exposure -bin 1,2 # # 2) Acquire using current binning factor, windowed to mask area: # acquire_slit_alignment_exposure -win maskarea # # 3) Acquire using current binning factor, current window area # with exposure time set to 20s # acquire_slit_alignment_exposure -exptime 20 # #- # Modification history: # 2012-May-25 GDW Original version (adapted from LRIS) #----------------------------------------------------------------------- cmd=`basename $0` default=default binning=$default # default is to use current binning exptime=$default # default is to use current exptime wmode=$default # default is to use current windowing debug=0 usage="Usage: $cmd [-binning ] [-window ] [-exptime ]" tempfile=/tmp/$cmd.$$ state_file=/tmp/.save_state.$$ # restore the original state... cleanup() { # trap "" 0 1 2 9 15 restore_state -clobber -verify $state_file s=$? # remove the tempfile created in the earlier restore process... if [ -f $tempfile ]; then \rm $tempfile fi # remove the state file if the restore operation was successful... if [ $s -eq 0 ]; then \rm $state_file else printf "[$cmd] ERROR: problem restoring keyword from file $state_file -- abort!\n\a" exit 1 fi } # loop over command-line args... while [ $# -gt 0 ]; do case "$1" in b*) shift ; binning="$1"; shift ;; e*) shift ; exptime="$1"; shift ;; w*) shift ; wmode="$1"; shift ;; *) printf "$usage\n\a" && exit 1;; esac done # check for debug... if [ $debug = 0 ]; then foo="" else printf "[$cmd] DEBUG MODE enabled\n" foo="echo" printf "binning=$binning\n" printf "exptime=$exptime\n" printf "wmode=$wmode\n" fi # save current state... save_state -clobber -detector $state_file # verify that the state file was written... if [ -f $state_file ]; then if [ $debug ]; then printf "Contents of state file ${state_file}:\n" cat $state_file printf "------------------------------------------------------------------------\n\n" fi else printf "[$cmd] ERROR: state file $state_file not found -- abort!\n" exit 1 fi # make sure that there is no exposure taking place... $foo wfi -nowait # define what to do on interrupt... trap cleanup 0 1 2 9 15 # allocate a file for settings... touch $tempfile if [ $? -ne 0 ]; then printf "[$cmd] ERROR: unable to create temp file $restore_file -- abort!\n\a" exit 1 fi # reconfig ccd... printf "deiccd mosmode Direct\n" >> $tempfile # include zeroth order command... slider=`slider` if [ "$slider" = "3" ]; then printf "deimot g3tltnam Zeroth_Order\n" >> $tempfile elif [ "$slider" = "4" ]; then printf "deimot g4tltnam Zeroth_Order\n" >> $tempfile else printf "[$cmd] ERROR: you must select slider 3 or 4 to run this command\n" exit 1 fi # put additional settings into file... if [ "$binning" != "$default" ]; then printf "deiccd binning $binning\n" >> $tempfile fi if [ "$exptime" != "$default" ]; then printf "deiccd ttime $exptime\n" >> $tempfile fi if [ "$wmode" != "$default" ]; then printf "deiccd autopane $wmode\n" >> $tempfile fi # execute restore state if we got any changes... if [ -s $tempfile ]; then command="$foo restore_state -verify $tempfile" $command if [ $? -ne 0 ]; then printf "[$cmd] ERROR: bad return from $command -- abort!\n\a" exit 1 fi fi # now acquire an image... $foo goi # cleanup is invoked at the end...