#!/bin/csh -f source /star/etc/login >& /dev/null source /star/etc/cshrc >& /dev/null kappa >& /dev/null if (`alias kappa` == "") then echo "" echo "Fatal: Initialization error of kappa environment" echo "" exit endif set kap = $KAPPA_DIR if ($#argv < 2) set argv = "help" if ($argv[1] =~ *"help"* || $argv[1] == "-h") then echo "" echo "Use: sp_axis file axis" echo " e.g. 'sp_axis myfile [pix | freq | vrad | vopt | velo | red]'" echo "" echo "Axis names: pixel, freq, vrad, vopt, velo, redshift" echo "" exit endif set infile = $argv[1] set infile = `echo "$infile" | cut -d\. -f1` set infile = "${infile}.sdf" shift argv if !(-e "$infile") then echo "" echo "Fatal: file $infile not found" echo "" exit endif set axtype = "$argv[1]" set axtype = `echo $axtype | tr '[a-z]' '[A-Z]'` echo "" echo "Setting 3rd axis ${infile} of infile to '${axtype}'" # ---------------------------------------------------------------------- # Set X-axis unit # if ( "${axtype}" =~ 'P'* || "${axtype}" == 1 ) then set wframe = "pixel" set wsys = "" else if ( "${axtype}" =~ 'F'* || "${axtype}" == 2 ) then set wframe = "SKY-DSBSPECTRUM" set wsys = "FREQ" else if ( "${axtype}" =~ 'VR'* || "${axtype}" == 3 ) then set wframe = "SKY-DSBSPECTRUM" set wsys = "VRAD" else if ( "${axtype}" =~ 'VO'* || "${axtype}" == 4 ) then set wframe = "SKY-DSBSPECTRUM" set wsys = "VOPT" else if ( "${axtype}" =~ 'VE'* || "${axtype}" == 5 ) then set wframe = "SKY-DSBSPECTRUM" set wsys = "VELO" else if ( "${axtype}" =~ 'RE'* || "${axtype}" == 6 ) then set wframe = "SKY-DSBSPECTRUM" set wsys = "ZOPT" else echo "" echo "Error: spaxis file [ pixel | 1 | freq | 2 | vrad | 3 | vopt | 4 | velo | 5 | redshift | 6 ]" echo "" exit endif ${kap}/wcsframe $infile $wframe if ("$wframe" != "pixel") then ${kap}/wcsattrib $infile set System $wsys if ( "$wsys" == "FREQ") then ${kap}/wcsattrib $infile set 'unit(3)' GHz ${kap}/wcsattrib $infile set 'stdofrest' Source echo "Standard of rest: SOURCE" else ${kap}/wcsattrib $infile set 'stdofrest' LsrK echo "Standard of rest: LSRK" endif ${kap}/setaxis $infile mode=wcs 3 else setaxis $infile mode=pixel 3 endif # Flip axis if axis now from high-to-low: ndftrace $infile >& /dev/null set astrts = `${kap}/parget astart ndftrace | head -1` set aends = `${kap}/parget aend ndftrace | head -1` set astart = `echo $astrts[3]` set aend = `echo $aends[3]` set range = \ `echo "scale=2;(10000*(($aend)-($astart)))" | bc | cut -d\. -f1` if ($range < 0) then echo "Flipping axis" cp ${infile} temp.sdf ${kap}/flip temp.sdf ${infile} 3 \rm -f temp.sdf >& /dev/null endif echo ""