#!/bin/bash -f
#
#   Remember to run script "init_seisnet" (sioseis-seisnet daemon)
#
if [ "$#" = "0" ]; then
    echo "Usage: brute160 line-name plot-direction(ltr/rtl)"
    exit
fi
line=$1
DIR="ltr"
if [ "$2" = "rtl" ]; then
    DIR="rtl"
fi

#outdir="/home/logadmin/output"
outdir="."
latest="/tmp/latest"

#   where is the sioseis program?
/home/logadmin/bin/sioseis << eof
procs segddin prout geom wbt gather nmo stack diskoa avenor filter plot end

segddin
   fcset 1 lcset 1   #  assume the sonobuoys will be in channel set 2 and reflection in channel set 1n 1
   stack $latest
   logpath ./$line-stack.log
   end
end

prout
 fno 0 lno 9999999 ftr 1 ltr 1 end
end

geom
  type 9 # Use realtime GPS that's in the SEG-Y trace header
  fs 1 ls 999999  # all shot have the same parameters (preset)
  gxp 160 -250   # RESET the closest group only.
  ggx -12.5         # Used to extrapolate gxp!
  dfls 37.5   # ignored with type 9
  dbrps 6.25
  rpadd 1000 end
end

wbt
    vel 1500 track .1 end
end

gather
   maxtrs 50  maxrps 170 END
end

nmo
#
# real time nmo, replace interpolation by RP to WB depth in Meters.
# If water depth changes by > 500 m, use previous value.
# interpolation by iso-velocity layering
vtrkwb 500 stretc 1.50 dstretch 50

fno 10 lno 10
vtp 1500 0.013   #  The water bottom two way travel time at 10m is .013sec
 1700 0.884
 2171 1.312
 2486 1.687
 3092 2.208
 5733 8.588
 6556 13.088 end

fno 500 lno 500
vtp 1500 0.667
 1630 1.549
 1977 1.978
 2238 2.353
 2775 2.873
 5673 8.391
 6788 13.391 end

fno 1000 lno 1000
vtp 1500 1.333
 1564 2.216
 1761 2.644
 1932 3.019
 2089 3.332
 5413 7.470
 7181 13.470 end

fno 2000 lno 2000
vtp 1500 2.667
 1521 3.549
 1593 3.978
 1664 4.353
 1734 4.665
 4410 7.769
 7122 14.269 end

fno 2500 lno 2500
vtp 1500 3.333
 1502 3.627
 1521 3.885
 1546 4.135
 1555 4.260
 3312 6.329
 7244 13.829 end

fno 3000 lno 3000
vtp 1500 4.000
 1501 4.294
 1504 4.408
 1505 4.483
 1564 4.858
 2900 6.551
 7064 14.051 end
end

diskoa   # Write out disk file
  opath $outdir/$line-stack.segy
end end

avenor
  hold 300
  addwb yes sets 0 .5 5 6 end
end


filter
  pass 5 90 ftype 0 dbdrop 48 end
end

plot
  dir $DIR
  scalar -1
  tlines 0.5 1 nibs 7225 ann gmtint anninc 5 ann2 shotno
  def 0.04 trpin 125 wiggle 0
  vscale 1.25 clip .03
  opath $outdir/$line-stack.atlantek
  end
end

end
eof