#!/bin/sh
# Sumutecsv_test2q - for program SUMUTECSV
# Author: Andre Latour, Feb 2022
#
  echo "----------------------------------------------------------------------------"
  echo "---  This test is the same as test2 except it inputs the same mute values   "
  echo "---  via a q-file. It also subtracts the results of test2 from the results  "
  echo "---  produced herein. The sumax results at end should be 0.0,0.0            "
  echo "----------------------------------------------------------------------------"
#
# I know the 3d grid is 121 by 23 cells. Make 1210 traces (5 inlines of 121).   
# Make 2 traces per cdp with offset of 500 and 800. 
#
  sunull nt=1500 ntr=1210 dt=0.004 >tnullq2.su
  sumath <tnullq2.su op=add a=100 >tnullq2a.su
  sushw <tnullq2a.su >tnullq2b.su key=tracl a=10 b=5
  sushw <tnullq2b.su >tnullq2bcdp.su key=cdp a=1 b=0 c=1 j=2
  sushw <tnullq2bcdp.su >tnullq2bcdpoff.su key=offset a=500 b=300 c=0 j=2
#
# sugethw <tnullbcdpoff.su key=tracl,cdp,offset >afile
#
# Similar to test1, try setting extrapi and/or extrapc to 0.
# Also, change the 300 above to -100 so that offsets 300 and 200 are created.
# Also, change the 300 above to 700 so that offsets 300 and 1200 are created.
#
  sumutecsv <tnullq2bcdpoff.su >tnullq2bcdpoffmute.su rfile=kEFG.csv mode=0 extrapi=1 extrapc=1 \
        qin=t2q.csv \
#
  suxwigb <tnullq2bcdpoffmute.su key=tracl xcur=0.5 
#
# The next 2 programs subtract the results of the command line input test Sunmocsv_realistic2 
# and this test of qin file input (which has the same velocity function values).
# The result should be all zeroes of course.                                      
#
  suop2 tnull2bcdpoffmute.su tnullq2bcdpoffmute.su op=diff >tnullq2fake.su
#
  sumax <tnullq2fake.su
#
# The suop2 and sumax concept above can be used as a (limited) unit test. 
# Before adding some option in the code, run all tests and preserve the outputs.
# Then make your code changes, and rerun all tests. Then use suop2,sumax
# to compare the old/new output files. The result should be 0,0 unless 
# you intended otherwise.  
#   However, do not presume this would be useful in general.
#   That is, if you uploaded the output files into GITHUB (or whatever) then,
#   later, you could run suop2,sumax tests comparing the old GITHUB files     
#   to files newly generated by these tests. 
#        You could then automate this into unit-tests.                                                     
#   But that is not likely to be a generally useful thing for Seismic Unix.
#   The trouble comes down to the fact the seismic data is floating point.
#   As hardware/compiler/optimizers develop, floating point results always 
#   change slightly, especially for seismic sample values themselves, but 
#   also for some header values (for instance: statics). For any change
#   of hardware/compiler/optimizer the difference after sumax is not 0.
#   Having worked a long time for a major corporation that developed an 
#   industry-leading seismic processing system, checking these kinds of
#   unit-tests requires large effort, manpower, and organizational structure
#   that Seismic Unix will never have available.
#
