home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh
- set ylabel="Voltage"
- set xlabel="Time"
- while ($#argv > 0)
- switch ("$argv[1]")
- case -i:
- if ($#argv <1) goto usageerror
- set ylabel="Current"
- shift
- breaksw
- case -f:
- if ($#argv < 1) goto usageerror
- set xlabel="Frequency"
- shift
- breaksw
- case -xl:
- if ($#argv < 2) goto usageerror
- set xlabel="$argv[2]"
- shift
- shift
- breaksw
- case -yl:
- if ($#argv < 2) goto usageerror
- set ylabel="$argv[2]"
- shift
- shift
- breaksw
- case -pn:
- if ($#argv < 2) goto usageerror
- set plotname="$argv[2]"
- shift
- shift
- breaksw
- case -s:
- set fn
- if !($?plotname) set plotname=$fn endif
- shift
- breaksw
- default:
- set fn=$argv[1]
- if !($?plotname) set plotname=$fn endif
- shift
- breaksw
- endsw
- end
-
- if ($?fn) then
- sed -e '/\$/,/^----/d' -e 's/^Index *[^ ]* */\"/' -e 's/^ *.*$//' -e '/^--*/d' -e 's/^0 */move /' -e 's/^[0-9]*//' -e '1i\\
- TitleText: '"$plotname"'\\
- XUnitText: '"$xlabel"'\\
- YUnitText: '"$ylabel"' ' -e 's/\,[ ]*[+-0-9e]*//g' $fn
- else
- usage:
- echo -n
- echo 'Usage:'" $0 [options] filename"
- echo "This program translates spice3 print command output to xgraph input format."
- echo "It WILL handle multiple variables in one file- provided they were put there"
- echo "by _consecutive_ print statements. ie. 'print i1 i2 > filename' will not work"
- echo "but 'print i1 > filename' followed by 'print i2 >> filename' WILL work."
- echo "Output is on stdout. Author: jmn@power.berkeley.edu"
- echo "Options are:"
- echo " -i Set YAxisLabel to 'Current' (default is 'Voltage')"
- echo " -f Set XaxisLabel to 'Frequency' (default is 'Time')"
- echo " -xl XName Set XaxisLabel to Xname"
- echo " -yl YName Set YaxisLabel to Yname"
- echo " -pn PlotName Set PlotTitle to PlotName (default is filename)"
- echo " -s Take input from stdin"
- echo -n
- echo "Example Usage:"
- echo "$0 -xl 'log(frequency)' -yl 'Gain(db)' -pn '741 Plot' filename | xgraph"
- echo "will plot a graph called '741 Plot' with Gain(db) vs log(frequency)."
- exit 1
- usageerror:
- echo $argv[1] needs more arguments!
- goto usage
-
- endif
-