#! /bin/csh -f
# Last edited on 1999-09-04 11:37:01 by hcgl

set usage = "$0 MAXDIST NBINS HISTFILE EPSFILE BAND TITLE XUNITS"

# Draws a histogram of sample distances squared
# The maximum value is assumed to be MAXNUM/MAXDEN, with 25 bins
# on each side of the origin.

if ( $#argv != 7 ) then
  echo "usage: ${usage}"; exit 1
endif

set maxdist = "$1"; shift
set nbins = "$1"; shift
set hfile = "$1"; shift
set pfile = "$1"; shift
set band = "$1"; shift;
set title = "$1"; shift
set xunits = "$1"; shift

echo "${hfile} -> ${pfile}"

/n/image/bin/gnuplot <<EOF
# set terminal X11
set terminal postscript eps "TimesRoman" 24
set output "${pfile}"
set boxwidth (${maxdist}*${maxdist}/(${nbins}-1))
set size 1.5,0.60
set xrange [(${maxdist}*${maxdist}*(0 - 0.6/(${nbins}-1))):(${maxdist}*${maxdist}*(1 + 0.6/(${nbins}-1)))]
set xlabel "${title} squared (${xunits})"
set ylabel "samples"
set nokey
set title "lambda = ${band} pixels  -  ${title}"
plot "${hfile}" using 2:4 with boxes
# pause 30
quit
EOF

# /bin/ls -l ${inName}.ps