#! /bin/csh -f
# patchcorr3d - to get local 3d cross-correlations between two volumes at
# a grid of positions.
if ($#argv != 14 && $#argv != 16) then
cat < $x2) then
@ tmp = $x1
@ x1 = $x2
@ x2 = $tmp
endif
if ($x1 > $x3) then
@ tmp = $x1
@ x1 = $x3
@ x3 = $tmp
endif
if ($x1 > $x4) then
@ tmp = $x1
@ x1 = $x4
@ x4 = $tmp
endif
if ($x2 > $x3) then
@ tmp = $x2
@ x2 = $x3
@ x3 = $tmp
endif
if ($x2 > $x4) then
@ tmp = $x2
@ x2 = $x4
@ x4 = $tmp
endif
if ($x3 > $x4) then
@ tmp = $x3
@ x3 = $x4
@ x4 = $tmp
endif
@ y1 = $yll
@ y2 = $ylr
@ y3 = $yul
@ y4 = $yur
if ($y1 > $y2) then
@ tmp = $y1
@ y1 = $y2
@ y2 = $tmp
endif
if ($y1 > $y3) then
@ tmp = $y1
@ y1 = $y3
@ y3 = $tmp
endif
if ($y1 > $y4) then
@ tmp = $y1
@ y1 = $y4
@ y4 = $tmp
endif
if ($y2 > $y3) then
@ tmp = $y2
@ y2 = $y3
@ y3 = $tmp
endif
if ($y2 > $y4) then
@ tmp = $y2
@ y2 = $y4
@ y4 = $tmp
endif
if ($y3 > $y4) then
@ tmp = $y3
@ y3 = $y4
@ y4 = $tmp
endif
# Use the middle values to modify the borders
if ($x2 > 0) @ xbl += $x2
if ($x3 < $nxt) @ xbh += ($nxt - $x3)
if ($y2 > 0) @ zbl += $y2
if ($y3 < $nzt) @ zbh += ($nzt - $y3)
endif
#
if ($nx == 1) then
@ dx = 0
@ xs = $nxt / 2
else
@ dx = (($nxt - $nxl) - ($xbl + $xbh))/($nx - 1)
@ xs = $xbl + ($nxl / 2)
endif
#
if ($ny == 1) then
@ dy = 0
@ ys = $nyt / 2
else
@ dy = (($nyt - $nyl) - ($ybl + $ybh))/($ny - 1)
@ ys = $ybl + ($nyl / 2)
endif
#
if ($nz == 1) then
@ dz = 0
@ zs = $nzt / 2
else
@ dz = (($nzt - $nzl) - ($zbl + $zbh))/($nz - 1)
@ zs = $zbl + ($nzl / 2)
endif
#
@ nxtap = ($nxl + 9) / 10
@ nytap = ($nyl + 9) / 10
@ nztap = ($nzl + 9) / 10
@ nxpad = ($nxl + 4) / 5
@ nypad = ($nyl + 4) / 5
@ nzpad = ($nzl + 4) / 5
#
set pad1 = "$tmpdir/pad1.$$"
set pad2 = "$tmpdir/pad2.$$"
set cortmp = "$tmpdir/corr3d.$$"
onintr clean
#
@ numtot = $nx * $ny * $nz
echo $numtot " positions"
while ($nz > 0)
@ iy = $ny
@ yp = $ys
while ($iy > 0)
@ ix = $nx
@ xp = $xs
while ($ix > 0)
tapervoledge >/dev/null </dev/null <