#!/bin/sh
# Sunmocsv_test3q - for program SUNMOCSV
# Author: Andre Latour, Jan 2022
#
  echo "----------------------------------------------------------------------------"
  echo "---  This test uses unusual values in the input velocity functions to       "
  echo "---  make it (relatively) easy to confirm that sunmocsv is working as       "
  echo "---  intended. If you want to do a careful review, the output to look at    "
  echo "---  is the tnullvels.txt file, which is a dump of the voutfile.            "
  echo "----------------------------------------------------------------------------"
#
# Make a null dataset of 2783 traces (and 4 samples, which is convenient for the 
# dump at the end of this). Then set the cdp numbers to 1-2783, which is the     
# full number of cdps in the 3d grid defined within the kEFG.csv K-file.
#
  sunull nt=4 ntr=2783 >tnull31.su
  sushw <tnull31.su >tnull32.su key=cdp a=1 b=1
#
# Sunmocsv will translate the cdp= parameter values to their inline and crossline
# locations using the 3d grid defined in kEFG.csv (see where they are in vellocs.png).
# Sunmocsv will also interpolate and output velocities for all 2783 input trace cdps. 
# The interpolation will be bi-linear, linear, or constant depending on where the
# trace cdp is located relative to the input functions (see README).             
#
# To check that the interpolation is bi-linear, linear, or constant as appropriate, 
# note that the first  velocity value of each input function is 1000000 + cdp number, 
#           the second velocity value of each input function is 2000000 + igi number,
#           the third  velocity value of each input function is 3000000 + igc number,
#           the fourth velocity value of each input function is 4000000.                
# (if you do not know the 3d grid igi,igc indexes of cdps, note that check=1 
# will print this information and 2>tinfo.txt will put it into a text file).
#
# So, each output line in the tnullvels.txt file is the 4 interpolated velocities at
# one cdp (conveniently, the line number of this text file is equal to the cdp number). 
# Since all input velocity functions have values that match their cdp,igi,igc
# plus 1000000,2000000,3000000 the INTERPOLATED output tnullvels.txt values should
# match if they are within the large area surrounded by input functions (see README).
# On the sides of that large area, the igi or igc values should match since only
# linear interpolation is being done. (Actually, the values in tnullvels.txt will
# not match exactly because 1/velocity-squared is applied before interpolation.  
# But the addition of 1000000,2000000,3000000 reduces the effect of 1/vel-squared.                   
#
# If you do not understand the point of all this, go to line 555 in tnullvels.txt
# and see 1000555,2000071,3000005 which are the correct cdp,igi,igc values 
# generated by the bi-linear interpolation of the input functions surrounding  
# cdp 555 (the input functions located at cdps 303,333,666,696; see vellocs.png). 
# You can also look at the line number of any of the cdp= list.                    
#
  sunmocsv <tnull32.su >tnull33.su rfile=kEFG.csv voutfile=tnullvels33 check=1 2>tinfo10.txt qin=qx5.csv \
#
# Dump the velocity values to text file.
#
        od -f -v tnullvels33 > tnullvels34.txt
#
# You can also compare this with test3 (same values via parameter input).
#
#       diff tnullvels23.txt tnullvels34.txt
