# Interpolating the velocity model

I have a text file which contains long, lat, depth, velocity information. Depth ranges are 0 1 2 3 4 5 6 8 10 12 18 24 40.

I have written this code based on previous suggestions in this forum. I extracted the velocity at each depth, saved it into txt file, and converted it to grd using xyz2grd. But I always get an error with the last “grdinterpolate” command using -Zi and -T. Any suggestions will be appreciated.

Here is my code

#!/bin/sh

vel_file=“merged_P_data.txt”

region=“-R103/106/28/31”

values=\$(awk ‘{gsub(“-”, “”); print \$3}’ \$vel_file | uniq)

echo \$values

for value in \$values; do
gmt begin \$value png

``````        awk -v value=-"\$value" '{if (\$3 == value) print \$1, \$2, \$4}' \$vel_file >> \$value.txt

gmt xyz2grd \$value.txt -G\$value.grd -I5k \$region #-V
``````

done

gmt grdinterpolate *.grd -Gfinal.grd -Fl \$region -Zdepth.txt -T0/40/1

gmt end

What error?

According to the manual, don’t think this is allowed. Maybe -Z0/40/1?

I have used -Z0/40/1 and -T0/40/1 but the error is the same as below."

grdinterpolate [ERROR]: Option -Z: Number of input 2-D grids does not match number of levels given via -Z

So you have 41 grids then? 0, 1, … 40?

I have tried both -Z0/41/1 and -T0/41/1 but the error is the same. Is it possible that input grids are only for certain depth (0 1 2 3 4 5 6 8 10 12 18 24 40)?

This is a few lines from the input file (Long, Lat, Depth, Vel):

104.30461 30.33333 0 4.50000
104.34982 30.35171 0 4.50000
104.39503 30.37008 0 4.50000
104.44025 30.38847 0 4.50000
104.53072 30.42523 0 4.50000
105.07415 30.64597 0 4.50000
104.11681 28.31539 -1 5.00000
104.52451 28.48079 -1 5.00000
104.61519 28.51757 -1 5.00000
104.70590 28.55435 -1 5.00000
104.79663 28.59113 -1 5.00000
104.84201 28.60953 -1 5.00000
104.88739 28.62792 -1 5.00000
104.93279 28.64632 -1 5.00000