#!/bin/sh
# Sunmocsv_test1 - for program SUNMOCSV
# Author: Andre Latour, Sept 2021
#
  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 tnullvels1.txt file.                                             "
  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 >tnull1.su
  sushw <tnull1.su >tnull2.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). 
#
  sunmocsv <tnull2.su >tnull3.su rfile=kEFG.csv voutfile=tnullvels1 check=1 2>tinfo7.txt \
        cdp=136,172,182,212,232,257,293,303,333,353,620,656,666,696,716  \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000136,2000015,3000002,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000172,2000051,3000002,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000182,2000061,3000002,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000212,2000091,3000002,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000232,2000111,3000002,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000257,2000015,3000003,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000293,2000051,3000003,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000303,2000061,3000003,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000333,2000091,3000003,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000353,2000111,3000003,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000620,2000015,3000006,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000656,2000051,3000006,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000666,2000061,3000006,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000696,2000091,3000006,4000000 \
        tnmo=0.000,0.004,0.008,0.012 \
        vnmo=1000716,2000111,3000006,4000000 \
#
# Dump the velocity values to text file.
#
        od -f -v tnullvels1 > tnullvels1.txt
#
