#! /bin/csh -fe
# Last edited on 2001-11-10 17:40:31 by stolfi

set cmd = $0
echo "=== begin ${cmd:t} ===" 
echo "${cmd:t} $*"

set usage = "$0 CANDDIR INBAND OUTBAND TAG"

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

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

set path = ( \
  ${STOLFIHOME}/programs/pm3-1.1.15/THESES/hcgl/1/bin/${PLATFORM} \
  ${cmd:h} \
  ${path} \
)

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

  set input = results/${canddir}/f${inBand}-${tag}
  set output = results/${canddir}/f${outBand}-${tag}

  echo "mapping ${input}.can to ${output}.can..."

  source data/multiscale/f${inBand}.parms
  set inStep = "${step}"

  source data/multiscale/f${outBand}.parms
  set outLambda = "${lambda}"
  set outStep = "${step}"

  set extraLength = 0.0
  set blurFactor = 3.0
  echo "extraLength = ${extraLength}"
  echo "blurFactor = ${blurFactor}"
  echo "outLambda = ${outLambda}"
  echo "outStep = ${outStep}"

  nice PZMapCands @M3stackdump \
    -input ${input} \
    -inBand ${inBand} \
    -chainDir data/multiscale -chainPrefix f \
    -output ${output} \
    -outBand ${outBand} -outLambda ${outLambda} \
    -outStep ${outStep} \
    -blurFactor ${blurFactor} \
    -extraLength ${extraLength} \
    -verbose
else
  echo "mapping to same band, skipped"
endif

run-PZDrawCands -show -displace 1.0 -drawMatchEvery 1 \
  ${output}.can \
  data/multiscale ${outBand} ${output}-can 

echo "=== end ${cmd:t} =========" 


