#!/bin/sh
# Sunearcsv_testb - for program SUNEARCSV
# Author: Andre Latour, Oct  2022
#
  echo "----------------------------------------------------------------------------"
  echo "---  Same as test 1:                                                        "
  echo "---  - except specifying a small RELATIVE extent range for X.               "
  echo "---  - and specifying a small RELATIVE extent range for Y.                  "
  echo "---  - and use the nopoint=0 option, which continues without updating       "
  echo "---    trace keys cdp,igi,igc if the trace is out-of-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=testoutb1.csv
#
 sunull nt=4 ntr=10 >tnullb1.su
 sushw <tnullb1.su >tnullb2.su key=sx,sy,gx,gy a=600,-50,600,-50 b=60,125,60,125
#
 sunearcsv qin=testoutb1.csv <tnullb2.su dimx=mgx dimy=mgy >tnearb1.su keyp=cdp okeys=cdp \
           typex=2 minx=-100 maxx=100 typey=2 miny=-100 maxy=100 nopoint=0
#
 suchw <tnearb1.su >tnearb2.su key1=sdel,gdel key2=sx,sy key3=gx,gy b=1,1 c=1,1 d=2,2 
 sugethw <tnearb2.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' testoutb1.csv >testoutb2.csv
 cut -d, -f3,4 <testoutb2.csv >testoutb3.csv
 sed '1,$ s/,/ /g' testoutb3.csv >testoutb3.txt
 a2b <testoutb3.txt >testoutb3.bin
#
 sugethw <tnearb2.su output=binary key=sdel,gdel >testoutb4.bin
 cat testoutb3.bin testoutb4.bin >testoutb5.bin
#
 xgraph <testoutb5.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
