#! /bin/bash # invoke gnuplot to create a probability plot from specified data column pairs # check for presence of command arguments if [ ! -n "$1" ] then echo 'invocation: histplot [valcol-1 fraccol-1 file-1] [valcol-2 fraccol-2 file-2] .... [valcol-n fraccol-n file-n]' exit fi # grab and count command arguments let ncmdarg=0 for ncmd in $* do let ncmdarg=ncmdarg+1 cmdarg[ncmdarg]="$ncmd" # echo "Command argument $ncmdarg = ${cmdarg[ncmdarg]}" done # create triad column numbers, file name list # sequence counts by 3 let nfile=0 for vcol in $( seq 1 3 $ncmdarg ) do # increment triad index let nfile=nfile+1 # create value column number array valcol[nfile]="${cmdarg[vcol]}" # create index to second member of triad let fcol=vcol+1 # create fraction column number array fraccol[nfile]="${cmdarg[fcol]}" # create index to third member of triad let narg=fcol+1 # create filename array filename[nfile]="${cmdarg[narg]}" #echo "Value column number = ${valcol[nfile]}" #echo "Fraction column number = ${fraccol[nfile]}" #echo "File name = ${filename[nfile]}" # find number of index blocks in this file linecount=`wc -l < ${filename[nfile]}` lineswithnumbers=`grep -c '\.' < ${filename[nfile]}` let fileindex=(linecount-lineswithnumbers-1)/2 #echo "fileindex = ${fileindex}" # check to use minimum of all files numindex=`echo "$fileindex $numindex" | stats min` #echo "numindex now equal to $numindex" done plotfile=temp.plt plotfile0=temp0.plt echo reset > $plotfile #echo "set terminal pdf" >> $plotfile #echo "set output 'plot.pdf'" >> $plotfile echo "set ylabel 'bin mass fraction (%)'" >> $plotfile echo "set xlabel 'upper bin diameter (mm)'" >> $plotfile echo "set logscale x" >> $plotfile echo "hblock = 0" >> $plotfile echo "call '$plotfile0' year" >> $plotfile # create file to read all blocks (inelegant ending) # clears plot file if it exists echo '' > $plotfile0 echo "print \" block: \", hblock+1" >> $plotfile0 echo "plot \\" >> $plotfile0 for fn in $( seq 1 $nfile ) do if [[ ${fn} -lt ${nfile} ]] then echo "'${filename[fn]}' every :::\$hblock::\$hblock using ${valcol[fn]}:${fraccol[fn]} ti '$fn ${filename[fn]}' w lp, \\" >> $plotfile0 else echo "'${filename[fn]}' every :::\$hblock::\$hblock using ${valcol[fn]}:${fraccol[fn]} ti '$fn ${filename[fn]}' w lp" >> $plotfile0 fi done echo "pause -1" >> $plotfile0 echo "hblock = hblock + 1" >> $plotfile0 echo "if(hblock < 9125) reread" >> $plotfile0 gnuplot $plotfile #rm $plotfile #rm $plot_out