#!/bin/sh
# Sunearcsv_testa - for program SUNEARCSV
# Author: Andre Latour, Oct  2022
#
  echo "----------------------------------------------------------------------------"
  echo "---  Same as test 1:                                                        "
  echo "---  - except specifying a small and unchanging range for X.                "
  echo "---  The print shows that all traces are assigned cdp 3 since it is         "
  echo "---  the nearest cdp within the allowed X-range.                            "
  echo "---                                                                         "
  echo "---  Note: The vertical is X axis (for these tests, I do not care).         "
  echo "----------------------------------------------------------------------------"
#
 suprofcsv keyx=gx keyy=gy keyp=asis gx=0,1000,1000 gy=0,0,1500 \
           chordi=100 nmaxa=3 nmaxs=3 chordf=100 \
           qout=testouta1.csv
#
 sunull nt=4 ntr=10 >tnulla1.su
 sushw <tnulla1.su >tnulla2.su key=sx,sy,gx,gy a=600,-50,600,-50 b=60,125,60,125
#
 sunearcsv qin=testouta1.csv <tnulla2.su dimx=mgx dimy=mgy >tneara1.su keyp=cdp okeys=cdp \
           typex=1 minx=-400 maxx=-200 nopoint=1
#
 suchw <tneara1.su >tneara2.su key1=sdel,gdel key2=sx,sy key3=gx,gy b=1,1 c=1,1 d=2,2 
 sugethw <tneara2.su key=sx,sy,gx,gy,sdel,gdel,cdp,igi,igc
#
# Use sed to remove the first lines (C_SU header lines).
# Use cut with a deliminator of comma to retain only fields 3 and 4
# Use sed to replace every comma with a blank.               
# Use a2b to convert ascii to binary                        
# Use sugethw to output x,y values in binary.                                   
# Use cat to combine the 2 sets of XYs into one file.                           
#
# Use xgraph to plot 2 sets of points with marks of Xs and triangles.
#
 sed '/C_SU/d' testouta1.csv >testouta2.csv
 cut -d, -f3,4 <testouta2.csv >testouta3.csv
 sed '1,$ s/,/ /g' testouta3.csv >testouta3.txt
 a2b <testouta3.txt >testouta3.bin
#
 sugethw <tneara2.su output=binary key=sdel,gdel >testouta4.bin
 cat testouta3.bin testouta4.bin >testouta5.bin
#
 xgraph <testouta5.bin n=40,10 linecolor=2,3 mark=2,6 marksize=10,10 linewidth=0 \
         width=1000 height=700 x1beg=-800 x1end=1400 x2beg=-100 x2end=2800
