Using bplt in a bash script

BSU comes with some example bash scripts. The scripts xplot and psplot are examples of how we can combine trace equalization with plotting, and default a number of bplt parameters. As can be seen from the listing below, the script prompts the user for some values, then scales the data with either bscl or bequ before plotting.


{listpsplot}
#!/bin/sh
#  $Id: psplot,v 1.2 2009-05-05 19:43:43 pm Exp $
#
# Script to plot seismic data in Postscript format using BSU program bplt $
#Author: P. Michaels  <pm@cgiss.boisestate.edu>
#set -x
XDIM=5
YDIM=2

if test "$1" = "-h"
then
echo "USAGE: xplot  filename  tmax  scaling"
echo 'Scaling Choices:'
echo '1= Peak Absolute Value of profile'
echo '2= L2 Norm of profile'
echo '3= Trace by trace L2 Norm'
else
if test "$1" = ”
then
echo 'Enter input file name'
read FILEN
else
FILEN=$1
fi

if test "$2" = ”
then
echo 'Enter tmax'
read TMAX
else
TMAX=$2
fi

if test "$3" = ”
then
echo 'Enter Scaling Choice'
echo '1= Peak Absolute Value of profile'
echo '2= L2 Norm of profile'
echo '3= Trace by trace L2 Norm'
read SCL
else
SCL=$3
fi

NAME=`basename $FILEN .seg`
NAME4=`echo $NAME | gawk -F "" '{print $1$2$3$4}' `
case $SCL in
1)
bscl $FILEN 1 500 3
AMP=`gawk '/Peak Absolute Value/ {print $4}' bscl$NAME4.lst`
rm -f bscl$NAME4.*
PFILEN=$FILEN
bplt $PFILEN 1 1 0 1 500 0 $TMAX 1 $AMP 200 $XDIM $YDIM
 ;;
2)
bscl $FILEN 1 500 1
AMP=`gawk '/L2 Norm of Data Set=/ {print $6}' bscl$NAME4.lst`
rm -f bscl$NAME4.*
PFILEN=$FILEN
bplt $PFILEN 1 1 0 1 500 0 $TMAX 1 $AMP 200 $XDIM $YDIM
;;
3)
bequ $FILEN 0 $TMAX
PFILEN=bequ$NAME4.seg
AMP=4
bplt $PFILEN 1 1 0 1 500 0 $TMAX 1 $AMP 200 $XDIM $YDIM
rm -f bequ$NAME4.*
;;
esac
rm -f bplt*.lst
fi
listpsplot

There are two ways to run this script. One can simply type psplot and then be prompted for the data set name, the maximum time to plot, and the type of scaling to use. Alternatively, one can type all the arguments on the command line:


psplot twav.seg .2 3



which produces a plot as shown in Figure 3.

Figure 3: Example use of the psplot script. Data are rescaled by the L2 norm (option 3) of each trace before plotting by bplt
\includegraphics[scale=1]{FigureC}

Another useful script is xplot. It plots the data using the X11 x-window device, and is very similar to the psplot script.