#! /bin/sh
WIDTH=420
HEIGHT=400
HEIGHT2=900
WIDTHOFF1=0
WIDTHOFF2=430
WIDTHOFF3=860
HEIGHTOFF1=50
HEIGHTOFF2=500


###PURPOSE###
# We make some simple data: 8 traces with 2-way reverberations and
# a weak tilting reflector hidden underneath the reverberations.  The
# spike data is convolved with the minimum phase wavelet specified below.

# The purpose of this demo is to create and apply a wavelet shaping
# filter 

# Construction of the minimum phase wavelet with Mathematica:
# (2-z)(3+z)(3-2z)(4+z)(4-2z)(4+3z)//(CoefficientList[#,z])&
#     {1152, -384, -904, 288, 174, -34, -12}


# First make the synthetic data for the deconvolution demo.
######START OF MODEL######
I=${CWPROOT}/include
L=${CWPROOT}/lib

cc traces.c -I$I -L$L -lcwp -lm

./a.out |
suaddhead ns=512 |
sushw key=dt a=4000 |
suaddnoise sn=2000 |
suconv filter=1152,-384,-904,288,174,-34,-12  >modeldata

rm a.out
######END OF MODEL######

# Plot the model 
suxwigb <modeldata title="Data: 64ms reverbs" \
	windowtitle="Data" \
	label1="Time (sec)" label2="Trace" \
	wbox=$WIDTH hbox=$HEIGHT2 xbox=$WIDTHOFF1 ybox=$HEIGHTOFF1 &

sushape w=1152,-384,-904,288,174,-34,-12 d=1 <  modeldata |
suxwigb title="Data: Shaping filter applied" \
	label1="Time (sec)" label2="Trace" \
	wbox=$WIDTH hbox=$HEIGHT2 xbox=$WIDTHOFF2 ybox=$HEIGHTOFF1 &

echo "Zoom in on traces to see that arrivals have been spiked"
 
exit 0
