#! /bin/bash # invoke gnuplot to compare hydrology output from WEPS generated runs. # invocation: allhlayers [Col num] [file-1 file-2 ... file-#] # set up column and title correspondence mincol=6 maxcol=19 coltitle[6]=`echo "6) Volumetric Water Content (m/m)"` coltitle[7]=`echo "7) Saturated Vol Water Cont (m/m)"` coltitle[8]=`echo "8) Field Capacity Vol Water Cont (m/m)"` coltitle[9]=`echo "9) Permanent Wilting Point Vol Water Cont (m/m)"` coltitle[10]=`echo "10) Residual Vol Water Cont (m/m)"` coltitle[11]=`echo "11) Fraction Crop Available Water"` coltitle[12]=`echo "12) Saturation Ratio"` coltitle[13]=`echo "13) Soil Temperature (C)"` coltitle[14]=`echo "14) Unsaturated hydraulic Conductivity (m/s)"` coltitle[15]=`echo "15) Matric Potential (m)"` coltitle[16]=`echo "16) Soil Relative Humidity (fraction)"` coltitle[17]=`echo "17) Bulk Density (Mg/m^3)"` coltitle[18]=`echo "18) Air Entry Potential (m)"` coltitle[19]=`echo "19) Brooks and Corey Exponent b =(1/lambda)"` # grab column number and shift command arguments colnum=$1 shift if [[ ${colnum} = "" ]] then echo 'invocation: allhlayers [Col num] [file-1 file-2 ... file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit elif [[ ${colnum} -lt $mincol ]] then echo 'invocation: allhlayers [Col num] [file-1 file-2 ... file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit elif [[ ${colnum} -gt $maxcol ]] then echo 'invocation: allhlayers [Col num] [file-1 file-2 ... file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit fi # determine number of index blocks in each series by looping through # command arguments 1 to # let nfile=0 for nf in $* do echo "${nf} checking index count" # create filename array let nfile=nfile+1 filename[nfile]="$nf" # find number of year blocks (output has years separated by 2 blank lines making these index blocks as well) fileindex=`dm "if x3>0 then x3 else SKIP" < ${nf} | dm y2 x1 | dm "if x1=x2 then SKIP else 1" | stats sum` #echo "fileindex = ${fileindex}" # check to use minimum of all files numindex=`echo "$fileindex $numindex" | stats min` #echo "numindex now equal to $numindex" echo " ${nf} checking column maximum value" # find selected column maximum value for this file filemaxval=`dm "if x${colnum}>0 then x${colnum} else SKIP" < ${nf} | stats max` #echo "filemaxval now equal to $filemaxval" # check for maximum of all files allmaxval=`echo "$filemaxval $allmaxval" | stats max` echo "allmaxval now equal to $allmaxval" done # rather than loop within gnuplot, create specific plot lines # for each year so these parameters can be added to the # title of the graph. # associate graph title name with column number specified titlebase=${coltitle[${colnum}]} # write single instance lines top plot file echo "set yrange [0:366]" > temp.plt echo "set zrange [] reverse" >> temp.plt echo "set pm3d at bs hidden3d 100" >> temp.plt echo "set style line 100 lt 0 lw 0.2" >> temp.plt echo "unset hidden3d" >> temp.plt echo "unset surf" >> temp.plt if [[ ${colnum} -eq 12 ]] then echo "set logscale x" >> temp.plt echo "set xrange [:${allmaxval}]" >> temp.plt elif [[ ${colnum} -eq 13 ]] then echo "set logscale x" >> temp.plt echo "set xrange [:${allmaxval}]" >> temp.plt elif [[ ${colnum} -eq 11 ]] then echo "set xrange [:${allmaxval}]" >> temp.plt else echo "set xrange [0:${allmaxval}]" >> temp.plt fi for year in $(seq $numindex) do echo "year = $year" # create graph title line echo "set title '${titlebase}, Year ${year}'" >> temp.plt #create plot lines for each file for num in $(seq $nfile) do let yearm=year-1 plotline[num]="'${filename[num]}' index ${yearm} using ${colnum}:2:5:${colnum} with lines, \\" done # add splot command to first plotline plotline[1]=`echo "${plotline[1]}" | sed -e 's/^.*/splot &/'` # strip last plotline of 3 extra characters plotline[nfile]=`echo "${plotline[nfile]}" | sed -e 's/...$//'` # write out plot lines to file for num in $(seq $nfile) do echo ${plotline[num]} >> temp.plt done echo "pause -1 'Stike Key for Next Year'" >> temp.plt done gnuplot temp.plt #rm temp.plt