#!/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 < 1) set argv = "help" if ($argv[1] =~ *"help"* || $argv[1] == "-h") then echo "" echo "Use: sp_plot file1 [file2] [xleft xright] [linplot options]" echo "" echo "Plot spectrum of file 1, with optionally file 2 overlayed in red." echo "There is limited support for Starlink sections: a command like" echo " sp_plot myfile'(~1,~1)' -200 200 will result" echo "a plot of: myfile'(~1,~1,-200.:200.)'" echo "i.e. the boundaries get appended to any section specified in" echo "the filename. Linplot options can be added to the end of the" echo "line e.g. ybot=-1 ytop=10. Ones that require quotes probably" echo "won't work." exit endif # Get infile1; avoid '~' character which is causing a lot of problems and # strip suffix set in = $argv[1] set in = `echo "$in" | sed s/\~/\@/g` set in = `echo "$in" | cut -d\. -f1` # Handle section. Re-instate '~', if any, at end if (`echo "$in" | fgrep -c '('` > 0) then set section1 = `echo "$in" | cut -d\( -f2` set section1 = `echo "$section1" | cut -d\) -f1` else set section1 = "," endif set section1 = "`echo $section1 | sed s/\@/\~/g`" set infile1 = `echo "$in" | cut -d\' -f1 | cut -d\( -f1 | cut -d\. -f1` set infile1 = "${infile1}.sdf" shift argv if !(-e "$infile1") then echo "" echo "Fatal: file ${infile1} not found" echo "" exit endif set infile2 = "" set section2 = "" set left = "" set right = "" set params = "" while ( $#argv > 0) set in = $argv[1] set sdf2 = `echo "$in" | cut -d\' -f1 | cut -d\( -f1 | cut -d\. -f1` set sdf2 = "${sdf2}.sdf" if (-e "${sdf2}" && ${infile2} == "") then set in = `echo "$in" | sed s/\~/\@/g` set in = `echo "$in" | cut -d\. -f1` # Handle section. Re-instate '~', if any, at end if (`echo "$in" | fgrep -c '('` > 0) then set section2 = `echo "$in" | cut -d\( -f2` set section2 = `echo "$section2" | cut -d\) -f1` else set section2 = "," endif set section2 = "`echo $section2 | sed s/\@/\~/g`" set infile2 = "${sdf2}" if !(-e "$infile2") then echo "" echo "Fatal: file ${infile2} not found" echo "" exit endif else if (${left} == "") then set left = "$in" else if (${right} == "") then set right = "$in" else set params = "$params $in" endif shift argv end echo -n "Plot of ${infile1}(${section1})" set clims = "" if ($left != "") then if (`echo $left | fgrep -c \.` == 0) set left = "${left}." if (`echo $right | fgrep -c \.` == 0) set right = "${right}." set clims = "${left}:${right}"; endif set type = `ndftrace $infile1 | fgrep -i Domain | head -1` set type = `echo "$type" | awk '{print $NF}'` if ("$type" == "DSBSPECTRUM-SPACEINDEX-TIME") then set region = "${clims},${section1}" else set region = "${section1},${clims}" endif linplot $infile1'('${region}')' device=xw mode=histogram tempstyle="'colour(Lines)=white'" $params if ($infile2 != "") then echo -n " with ${infile2}(${section2}) overlayed in red." set type = `ndftrace $infile1 | fgrep -i Domain | head -1` if ("$type" == "DSBSPECTRUM-SPACEINDEX-TIME") then set region = "${clims},${section1}" else set region = "${section1},${clims}" endif linplot $infile2'('${region}')' device=xw mode=histogram noclear tempstyle="'colour(Lines)=red'" $params endif echo ""