#! /bin/sh # # This script is used to remove one of the ACIS ccd's for # L3 processing. Various files need to have the signature # of the chip removed at different steps along the processing # thread. # UpdateDetnam() { # # This routine replaces the detnam in the header to reflect # which chips have been dropped # ff="$1" todel=`echo "$2" | sed 's;\ ;,;g'` orig=`dmkeypar $ff DETNAM echo+ 2> /dev/null` if test x`pget dmkeypar exist` = xyes then new=`echo $orig | sed "s/[${todel}]//g"` dmhedit "$ff" file= op=add key=DETNAM value=$new fi } RebuildFile() { # # This routine re-creates a file that has multiple blocks, one block # per chip, skipping over the blocks corresponding to the chips to # be skipped. # rff=$1 drop=$2 mv -f ${rff} ${rff}.orig dmcopy ${rff}.orig"[1]" ${rff} blocks=`dmlist ${rff}.orig blocks | grep ^Block | egrep -vi "Primary|.fits" | awk '{print $3}'` for bb in $blocks do keep=1 ccd=`dmkeypar "${rff}.orig[${bb}]" ccd_id echo+` for dd in $drop do if test $ccd = $dd then keep=0 fi done if test $keep = 1 then dmappend "${rff}.orig[${bb}]" $rff UpdateDetnam "${rff}[${bb}]" "$2" fi done } ProcessMsk1() { echo "Processing Msk1 file" echo "" RebuildFile ${1} "$2" echo "Saved original file as ${1}.orig" } # ---------------------------------------------------- # # Main Routine. # if test $# -lt 2 then echo 'csc_dropchip_msk1.sh msk1 "drop"' exit 1 fi infile=$1 drop="$2" chmod +w $1 if test "x${drop}" = "x" then exit 0 fi ProcessMsk1 $infile "$drop" exit 0