#! /bin/csh -fe
# Last edited on 2008-02-04 20:30:21 by stolfi

if ( "x$1" == "x-log" ) then
  set log = 1; shift
else
  set log = 0
endif

if ( $#argv != 1 ) then
  echo "tsk tsk"; exit 1
endif
  
set file = "$1"
set file = "${file:r}"

if ( $log ) then
  gnuplot <<EOF
  set terminal postscript
  set output "${file}-fpw.ps"
  set yrange [-1:1]
  plot \
    "< gawk '/^[^#]/ {print log(\$1)/log(10),(\$3==0?0:log(\$3)/log(10))}' $file.fpw" \
    using 1:2 title "$file" \
    with histeps
  quit
EOF
else
  gnuplot <<EOF
  set terminal postscript
  set output "${file}-fpw.ps"
  set yrange [0:10]
  plot \
    "< gawk '/^[^#]/ {print \$1,\$3}' $file.fpw" \
    using 1:2 title "$file" \
    with linespoints
  quit
EOF
endif

ghostview ${file}-fpw.ps
