#!/bin/tcsh #+ # Name: # cubecopy # Purpose: # Copies a cube created by SMURF:MAKECUBE, updating the MEDTSYS, EXP_TIME # and EFF_TIME FITS headers in the process. # Description: # This script uses NDFCOPY to copy the supplied cube (normally a cube # section) to a new location. It modifies the bounds of the EFF_TIME, # EXP_TIME and TSYS NDFs stored within the SMURF extension to match # the main cube NDF. It also recalculates and stores values for the # corresponding FITS headers (MEDTSYS, EXP_TIME and EXP_TIME) that # hold the median values in these NDFs. # Usage: # cubecopy # Notes: # - The input and output cubes will be prompted for if not supplied on # the command line. # Authors: # DSB: David S. Berry (JAC) # History: # 27-FEB-1991 (RFWS): # Original version. #- # Get the input NDF. if( $# == 0 ) then set def = `$KAPPA_DIR/parget data_array GLOBAL` echo -n "Input MAKECUBE cube /$def/ > " set in = $< if( "$in" == "" ) then set in = $def else if( "$in" == "\!" || "$in" == "\!\!" ) then echo "" exit endif else set in = "$argv[1]" shift endif # Check the input NDF is accessable. $KAPPA_DIR/ndftrace $in quiet << EOF > ./copycube-001.tmp !! EOF grep -q PAR__ABORT ./copycube-001.tmp set err = $status rm -f ./copycube-001.tmp if( $err == 0 ) then echo "CUBECOPY: Cannot access input NDF $in." echo "" exit endif # Check it is a cube created by MAKECUBE. $KAPPA_DIR/parget extname ndftrace | grep SMURF > /dev/null if( $status != 0 ) then echo "CUBECOPY: Input NDF $in does not have a SMURF extension." echo "" exit endif # Get the output NDF. if( $# < 1 ) then echo -n "Output cube > " set out = $< if( "$out" == "" || "$out" == "\!" || "$out" == "\!\!" ) then echo "" exit endif else set out = "$argv[1]" shift endif # Warn about unused parameters. if( $# > 0 ) then echo "Usage: cubecopy " echo "Ignoring extra supplied parameter values: $*" endif # Copy the cube to the new location. Set the EXTEN parameter true so that # extension NDFs are truncated to the size of the main output NDF. $KAPPA_DIR/ndfcopy in="$in" out="$out" exten # Calculate the median value in the output TSYS array. $KAPPA_DIR/histat "$out.more.smurf.tsys" > /dev/null set medtsys = `$KAPPA_DIR/parget median histat` # Change the value of the MEDTSYS FITS header. set old_medtsys = `$KAPPA_DIR/fitsmod "$out" MEDTSYS p` echo "Changing MEDTSYS from $old_medtsys to $medtsys" $KAPPA_DIR/fitsmod "$out" MEDTSYS u value=$medtsys comment='$C' position=\! # Calculate the median value in the output EFF_TIME array. $KAPPA_DIR/histat "$out.more.smurf.eff_time" > /dev/null set eff_time = `$KAPPA_DIR/parget median histat` # Change the value of the EFF_TIME FITS header. set old_eff_time = `$KAPPA_DIR/fitsmod "$out" EFF_TIME p` echo "Changing EFF_TIME from $old_eff_time to $eff_time" $KAPPA_DIR/fitsmod "$out" EFF_TIME u value=$eff_time comment='$C' position=\! # Calculate the median value in the output EXP_TIME array. $KAPPA_DIR/histat "$out.more.smurf.exp_time" > /dev/null set exp_time = `$KAPPA_DIR/parget median histat` # Change the value of the EXP_TIME FITS header. set old_exp_time = `$KAPPA_DIR/fitsmod "$out" EXP_TIME p` echo "Changing EXP_TIME from $old_exp_time to $exp_time" $KAPPA_DIR/fitsmod "$out" EXP_TIME u value=$exp_time comment='$C' position=\!