Skip to content

batchCorrelation.sh

Eric E Palmer edited this page Oct 23, 2026 · 1 revision

Batch Correlation Script

By TC

For usage see batchCorrelation


Header="
"







version=1.3

opt=$1
out=false

spcpth=/opt/local/spc/bin
cp=COROUT
opath=$PWD


if [[ $# == 0 ]]
then
        echo "Input single mapfile path/name or list of maplets."
        read file1

        echo "Input path/name of truth map."
        read file2
elif [[ $# == 2 && $opt != "-"* ]]
then
	file1=$1
	file2=$2
elif [[ $opt == "-"* ]]
then
	if [ $opt == '-v' ]
	then
		echo "Version: "$version
		exit
	elif [ $opt == '-h' ]
	then
		echo "$Header"
		exit
	elif [ $opt == '-o' ]
	then
		out=true

		opath=$2
		cp=$opath/$cp

		file1=$3
		file2=$4
	fi
else
	echo "Try again."
	exit
fi

echo "batchCorrelation.sh version: "$version
echo "Map list: "$file1
echo "Truth map: "$file2
echo "Output directory: "$opath
echo " "

if [[ $file1 == *".MAP" ]]
then 
	list=${file1:(-10):(6)}
else
	list=`cat $file1`
fi

mkdir -p $cp

cdir=$PWD

if [ $out == 'true' ]
then
        ln -s $cdir/MAPFILES $opath/MAPFILES
fi

cd $opath

tmap=${file2:(-10):(6)}
fmap=WWXXYY

ln -s $file2 MAPFILES/$fmap.MAP
showmap <<< $fmap
mv $fmap.pgm $cp/$tmap.pgm

cp $cdir/BIGLIST.TXT $opath/bak.BIGLIST.TXT
echo $fmap > BIGLIST.TXT
cat bak.BIGLIST.TXT >> BIGLIST.TXT


rm -f locations.txt

for i in $list
do
	showmap <<< $i
	mv $i.pgm $cp/

	Qsize=`$spcpth/dumpMapHeaders <<< $i | awk '/Qsize/{print $3}'`

	echo "m" > tmpf
	echo $i >> tmpf
	echo $Qsize $Qsize >> tmpf

	read x y <<< $($spcpth/newFind < tmpf | awk "/$fmap/"'{print $3, $4}')
	
	python $spcpth/mpXcorr.py $cp/$i.pgm $cp/$tmap.pgm > $cp/$i.txt

	read tx ty <<< $(awk '/match/{print $8, $9}' $cp/$i.txt)
	dx=`echo "$tx-$x" | bc`
	dy=`echo "$ty-$y" | bc`

	cor=`awk '/Max/{print $4}' $cp/$i.txt`

	printf "$i $x $y $dx $dy $cor\n" >> locations.txt
done


rm tmpf
rm MAPFILES/$fmap.MAP
rm BIGLIST.TXT

mv bak.BIGLIST.TXT BIGLIST.TXT	

Clone this wiki locally