#! /bin/csh -f # @(#) postplot 2.5 01 Sep 1994 KJH if ($#argv < 1) then echo 'Usage: postplot station satellite postfit.nio [-d data_type] [-p plot_device] [-o outfile] [-xaz] [-xel] [-xt] [-xr lo:hi] [-style linespoints]' echo ' More help postplot -H' exit 1 endif if ($argv[1] == "-H") then echo 'Usage: postplot station satellite postfit.nio [-d data_type] [-p plot_device] [-o outfile] [-xaz] [-xel] [-xt] [-xr lo:hi] [-style linespoints]' echo ' plots postfit phase residuals for a given station-satellite pair' echo ' Single digit satellite names should be given as GPS08.' echo ' Default data_type is 120 (phase). Data-type, plot_device' echo ' and outfile can be given in any order.' echo ' ALL for either station or satellite will generate a plot of' echo ' residuals for all stations and/or satellites.' echo ' -d data type to be plotted (=110 or 120, default 120)' echo ' -p plot device (default = screen)' echo ' -o output file namee' echo ' -xaz plot azimuth on x axis' echo ' -xel plot elevation angle on x axis' echo ' -xt plot time on x axis (default)' echo ' -xr lo:hi set xrange ' echo ' -style use given style for plotting data' exit 1 endif if ($#argv < 3) then echo 'Usage: postplot station satellite postfit.nio [-d data_type] [-p plot_device] [-o outfile]' echo ' More help postplot -H' exit 1 endif if (! -e $3) then echo ERROR: no postfit.nio file named $3 exit 2 endif # set pstf_txt=$3:r.txt_$$ rm -f $pstf_txt set ppnml = rpostfit_kjh$$.nml set satn = `echo $2 | sed '/.*/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | sed 's/GPS0/GPS/'` set stn1 = `echo $1 | sed '/.*/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` # # x == field to plot on x axis, default = 4 = time # k == argv(k) = switch under consideration set x = 4 set k = 4 set xrng = "none" set stl = "points" set data_type = "120" set out_file = "0" set plot_dev = "post landscape color" if ($term == "sun-cmd" || $term == "hpterm" || $term == "xterm") set plot_dev = "post landscape color" while ($k <= $#argv) switch ($argv[$k]) case -d: @ k++ set data_type = $argv[$k] @ k++ breaksw case -o @ k++ set out_file = $argv[$k] @ k++ breaksw case -p @ k++ set plot_dev = $argv[$k] @ k++ breaksw case -xt set x = 4 @ k++ breaksw case -xel: set x = 8 @ k++ breaksw case -xaz: set x = 9 @ k++ breaksw case -xr: @ k++ set xrng = "$argv[$k]" @ k++ breaksw case -style: @ k++ set stl = $argv[$k] @ k++ endsw end # # run rdpostfit2 to read the postfit.nio file echo Runing rdpostfit - May take a few seconds echo ' $OPTIONS' > $ppnml echo " DTYP(1) = $data_type" >> $ppnml echo ' PLTREJ = .FALSE.' >> $ppnml echo " SATS(1) = '$satn'" >> $ppnml echo " stns(1) = '$stn1'" >> $ppnml echo ' $END' >> $ppnml setenv POSTFIT $3 setenv INPUT $ppnml setenv OUTPUT $pstf_txt time /goa/source/rdpostfit2/$ARCH/OFFICIAL/rdpostfit2.e rm -f $ppnml # # separate the station-satellite residuals out into individual files # kkk == satellite name # hhh == station name # ept == epoch time set kkk = `grep GPS $pstf_txt | grep -v RECEIVER |awk '{print $2}' | sort -u` set hhh = `grep GPS $pstf_txt | grep -v RECEIVER |awk '{print $1}' | sort -u` set ept = '1-Jan-2000 12:00:00' set tmpf1 = tmpf1.$$ set tmpf2 = tmpf2.$$ set tmpf3 = tmpf3.$$ foreach h ($hhh) foreach k ($kkk) set tmpf = $h-$k.$$ echo $tmpf >> tmpfn.$$ if ($x == 4) then grep $k $pstf_txt | grep $h | grep -v RECEIVER |awk '{printf "%s\t%s\t%s\n",$4,$5,$7}' > $tmpf1 awk '{printf "%s %s\n",$1,$2}' $tmpf1 | char2sec - > $tmpf2 awk '{printf "%s\n",$3}' $tmpf1 > $tmpf3 paste $tmpf2 $tmpf3 > $tmpf else grep $k $pstf_txt | grep $h | grep -v RECEIVER |awk '{printf "%s\t%s\n",$'$x',$7}' > $tmpf endif # head -1 $tmpf end end # now have the files to be plotted, get ready to writ gnuplot script rm -f $tmpf1 $tmpf2 $tmpf3 set files = `cat tmpfn.$$` if ($x == 4) then # adjust the time to a nice integer hour offset set ept = `cat $files | awk '{print $1}' | sort -n | head -1 | awk '{printf "%d",($1/3600.0)-1}' | awk '{printf "%f",$1*3600.0}'` foreach i ($files) awk '{printf "%f %f %f\n",$1,'$ept',$2}' $i | awk '{printf "%f %f\n",($1-$2)/3600.0,$3}' > ${i}_h mv ${i}_h $i end endif # if (! -z $tmpf) then set tmpld = tmpld.$$ set tmpld2 = tmpld2.$$ rm -f $tmpld switch ($x) case 4: echo 'set xlabel "hours past '`sec2char $ept`'"' >> $tmpld breaksw case 8: echo 'set xlabel "elevation (deg)"' >> $tmpld breaksw case 9: echo 'set xlabel "azimuth (deg)"' >> $tmpld breaksw endsw if ($data_type == "120") then echo 'set ylabel "postfit phase residual (cm)"' >> $tmpld else if ($data_type == "110") then echo 'set ylabel "postfit range residual (cm)"' >> $tmpld else echo 'set ylabel "postfit '$data_type' residual (cm)"' >> $tmpld endif echo 'set title "'`pwd | xroot -`' postfit residuals"' >> $tmpld echo 'set term '$plot_dev >> $tmpld echo 'set data style '$stl >> $tmpld if ($xrng != "none") echo 'set xrange ['$xrng']' >> $tmpld if ($out_file != "0") then echo 'set output "'$out_file'"' >> $tmpld endif echo -n 'plot ' >> $tmpld2 foreach h ($files) echo -n ' "'$h'"' >> $tmpld2 end echo ' ' >> $tmpld2 sed 's/" "/", "/g' $tmpld2 >> $tmpld if ($out_file == "0") then echo pause -1 >> $tmpld echo hit return to continue after viewing plot endif gnuplot $tmpld else echo ERROR: Unable to find station-satellite pair endif #cat $tmpld rm -f $tmpfn $tmpld $pstf_txt $tmpld2 foreach h ($files) rm -f $h end