Before stacking seismograms for each grid point, cross correlation is required to align waveform.

At first, we need to choose a model station's waveform to compare another waveform, and generate cross correlation between them. The principle to pick up model station is make its geographical position locate in the center of dense array as far as possible.

$ csh Pick_model-station.csh

# open Pick_model-station.csh to look over all commands

Pick up most central station

gfortran -o Pick_sub-array_station_lat-layer.exe Pick_sub-array_station_lat-layer.f /usr/local/sac/lib/sacio.a
./Pick_sub-array_station_lat-layer.exe < input_station_names.txt

Set parameters

Then, we want to set some parameters for next programs: (1) the earthquake’s location; (2) the model station’s location; (3) the model station’s order in the file ‘stations.txt’. (4) P wave arrival time of the model station; (5) Event’s reference time in the model station.

set mod = `awk '{print $1}' mod_station.txt `

set evlo = ` saclst evlo f $mod | awk '{print $2}' `              # (1) earthquake's longnitude
set evla = ` saclst evla f $mod | awk '{print $2}' `              # (1) earthquake's latitude

set mod_stlo  = ` awk '{print $2}' mod_station.txt `              # (2) model station's longnitude
set mod_stla  = ` awk '{print $3}' mod_station.txt `              # (2) model station's latitude

set imod      = ` grep -n ''$mod'' stations.txt | cut -d: -f 1 `
set order_mod = ` echo ''$imod'-1' | bc -l `                      # (3) model station's order

###  Using PPK to pick P phases using the graphics cursor (tap 'A' or 'a' at the P arrival time)

echo "r $mod"  > sac.com
echo "qdp off" >> sac.com
#echo "bp co 0.5 2 p 2" >> sac.com
echo "rmean" >> sac.com
echo "rtrend" >> sac.com
echo "taper" >> sac.com
echo "ppk" >> sac.com
echo "wh" >> sac.com
echo "quit" >> sac.com
sac < sac.com > /dev/null
set ptime = `saclst A f $mod | awk '{printf "%d", $2}'`           # (4) P wave arrival time 
saclst nzhour nzmin nzsec nzmsec f $mod | awk '{print $2,$3,$4,$5}'> mod_time.txt  # (5) Reference time