#! /bin/csh -f
# Last edited on 1999-09-01 15:35:31 by hcgl

echo "=== begin $0 =========" 

set usage = "$0 RUN INBAND OUTBAND TAG"

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

set run = "$1"; shift;
set inBand = "$1"; shift;
set outBand = "$1"; shift;
set tag = "$1"; shift;

echo "run-PZMapStraightSegs inBand = ${inBand} outBand = ${outBand} tag = ${tag}"

if ( "x${inBand}" != "x${outBand}" ) then

  echo "inBand = ${inBand} outBand = ${outBand}"

  source RUN-${run}/f${outBand}.parms
  set outStep = ${step}
  echo "step = ${step}"

  set input = "RUN-${run}/f${inBand}-${tag}"
  set output = "RUN-${run}/f${outBand}-${tag}"

  # Note that the segments returned by PZGetStraightSegs include the
  # adjacent corners, so the "blurFactor" must be negative.  Make sure
  # its absolute value matches the "blurFactor" given to
  # PZGetStraightSegs.
  
  /n/gnu/bin/nice -n 19 \
    PZMapSegs \
      -chainDir . -chainPrefix f \
      -input ${input} \
      -inBand ${inBand} \
      -outBand ${outBand} -outStep ${outStep} \
      -output ${output} \
      -blurFactor -2.0 \
      -extraLength 0.0

else
  echo "mapping to same band, skipped"
endif

echo "=== end $0 ========="