#! /bin/sh

dt=0.004              # time sample interval in ray tracing             
nt=401        # number of time samples in ray tracing           
                                                                        
fz=0                   #first depth sample in velocity                  
nz=122        # number of depth samples in velocity             
dz=10         #depth interval in velocity                      
fx=0          #         first lateral sample in velocity                
nx=384        # number of lateral samples in velocity           
dx=10         #lateral interval in velocity        
nxs=20
dxs=192
marmmodel=$CWPROOT/src/demos/Velocity_Profiles/Marmousi/marmhard.dat.gz

# generate the smooth Marmousi model
cp $marmmodel .
gunzip marmhard.dat.gz
a2b < marmhard.dat n1=1 > marmhard.bin
smooth2 n1=122 n2=384 r1=5 r2=5 < marmhard.bin > marmsmooth.bin

ximage < marmsmooth.bin n1=122 n2=384 title="Marmousi Model" wbox=768 hbox=244 &

# use rayt2d to generate traveltime tables from the smooth Marmousi model
rayt2d dt=$dt nt=$nt  fz=$fz nz=$nz dz=$dz fx=$fx nx=$nx dx=$dx \
nxs=$nxs dxs=$dxs vfile=marmsmooth.bin tfile=marmtime.bin 


# view traveltime tables with xmovie
suaddhead < marmtime.bin ns=122 | sushw key=dt a=1 | sugain trap=1 |
suxmovie n1=122 n2=384 loop=1 title="Smooth frame=%g" width=768 height=244 &

# use rayt2d to generate traveltime tables from the hard Marmousi model
rayt2d dt=$dt nt=$nt  fz=$fz nz=$nz dz=$dz fx=$fx nx=$nx dx=$dx \
nxs=$nxs dxs=$dxs vfile=marmhard.bin tfile=marmhardtime.bin 

# view traveltime tables with xmovie
suaddhead < marmhardtime.bin ns=122 | sushw key=dt a=1 | sugain trap=1 |
suxmovie n1=122 n2=384 loop=1 title="hard frame=%g" width=768 height=244 &

exit 0
