#! /bin/bash # invoke gnuplot to plot comparison between two plot.out files # on days that erosion occurs in either of the files. #! /bin/bash # invoke gnuplot to compare erosion plotting output from WEPS generated runs. # invocation: allplot [Col_num file-1] [Col_num file-2] ... [Col_num file-#] # set up columns titles for plot.out file mincol=6 maxcol=77 coltitle[6]=`echo "6) Total erosion loss (kg/m^2)"` coltitle[7]=`echo "7) Suspension erosion loss (kg/m^2)"` coltitle[8]=`echo "8) pm10 erosion loss (kg/m^2)"` coltitle[9]=`echo "9) Maximum wind speed (m/s)"` coltitle[10]=`echo "10) Wind direction (degrees from N)"` coltitle[11]=`echo "11) Precipitation (mm)"` coltitle[12]=`echo "12) Soil surface water content"` coltitle[13]=`echo "13) Ridge height (mm)"` coltitle[14]=`echo "14) Ridge width (mm)"` coltitle[15]=`echo "15) Ridge spacing (mm)"` coltitle[16]=`echo "16) Ridge orientation (degrees from N)"` coltitle[17]=`echo "17) Dike height (mm)"` coltitle[18]=`echo "18) Dike width (mm)"` coltitle[19]=`echo "19) Dike spacing (mm)"` coltitle[20]=`echo "20) Random roughness (mm)"` coltitle[21]=`echo "21) Aggregate size geometric mean diameter (mm)"` coltitle[22]=`echo "22) Aggregate size geometric standard deviation (mm)"` coltitle[23]=`echo "23) Aggregate size minimum size limit (mm)"` coltitle[24]=`echo "24) Aggregate size maximum size limit (mm)"` coltitle[25]=`echo "25) Aggregate stability (J/cm^2)"` coltitle[26]=`echo "26) Crust fraction"` coltitle[27]=`echo "27) Loose mass on crust (Mg/m^2)"` coltitle[28]=`echo "28) Loose mass crust cover fraction"` coltitle[29]=`echo "29) Soil bulk density (Mg/m^3)"` coltitle[30]=`echo "30) Total Flat cover fraction"` coltitle[31]=`echo "31) Total Stem cover fraction"` coltitle[32]=`echo "32) Crop Leaf area index"` coltitle[33]=`echo "33) Crop Stem area index"` coltitle[34]=`echo "34) Crop Stem mass (kg/m^2)"` coltitle[35]=`echo "35) Crop canopy cover fraction"` coltitle[36]=`echo "36) Crop height (m)"` coltitle[37]=`echo "37) Crop Representative Stem Diameter (m)"` coltitle[38]=`echo "38) Crop biodrag"` coltitle[39]=`echo "39) Crop total soil cover"` coltitle[40]=`echo "40) Residue mass weighted average height (m)"` coltitle[41]=`echo "41) Residue stem area index"` coltitle[42]=`echo "42) Residue leaf area index"` coltitle[43]=`echo "43) Residue biodrag"` coltitle[44]=`echo "44) Residue canopy cover fraction"` coltitle[45]=`echo "45) Residue soil cover fraction"` coltitle[46]=`echo "46) 1 - erosion was entered"` coltitle[47]=`echo "47) 1 - snow depth prevented erosion"` coltitle[48]=`echo "48) anemometer located friction velocity"` coltitle[49]=`echo "49) site surface random roughness adjusted friction velocity"` coltitle[50]=`echo "50) site surface oriented roughness adjusted friction velocity"` coltitle[51]=`echo "51) site biodrag adjusted friction velocity"` coltitle[52]=`echo "52) site friction velocity"` coltitle[53]=`echo "53) bare friction velocity threshold"` coltitle[54]=`echo "54) flat cover increases threshold"` coltitle[55]=`echo "55) surface wetness increases threshold"` coltitle[56]=`echo "56) ag density increases threshold"` coltitle[57]=`echo "57) resultant threshold friction velocity"` coltitle[58]=`echo "58) ratio anemometer located friction velocity"` coltitle[59]=`echo "59) ratio site surface random roughness adjusted friction velocity"` coltitle[60]=`echo "60) ratio site surface oriented roughness adjusted friction velocity"` coltitle[61]=`echo "61) ratio site biodrag adjusted friction velocity"` coltitle[62]=`echo "62) ratio bare friction veolocity threshold"` coltitle[63]=`echo "63) ratio flat cover increases threshold"` coltitle[64]=`echo "64) ratio surface wetness increases threshold"` coltitle[65]=`echo "65) ratio ag density increases threshold"` coltitle[66]=`echo "66) Surface soil fraction less than 0.84 mm"` coltitle[67]=`echo "67) Surface soil fraction greater than 2 mm"` coltitle[68]=`echo "68) Surface soil aerodynamic roughness (mm)"` coltitle[69]=`echo "69) Soil surface fraction which does not emit"` coltitle[70]=`echo "70) Surface soil fraction less than 10 microns initial condition"` coltitle[71]=`echo "71) Surface soil fraction less than 100 microns initial condition"` coltitle[72]=`echo "72) Surface soil fraction less than 0.84 mm initial condition"` coltitle[73]=`echo "73) Surface soil fraction less than 2.0 mm initial condition"` coltitle[74]=`echo "74) Surface soil fraction less than 10 microns"` coltitle[75]=`echo "75) Surface soil fraction less than 100 microns"` coltitle[76]=`echo "76) Surface soil fraction less than 0.84 mm"` coltitle[77]=`echo "77) Surface soil fraction less than 2.0 mm"` # short column titles shortcoltitle[6]=`echo "T eros"` shortcoltitle[7]=`echo "S eros"` shortcoltitle[8]=`echo "pm eros"` shortcoltitle[9]=`echo "Max wind"` shortcoltitle[10]=`echo "Wind dir"` shortcoltitle[11]=`echo "Precip"` shortcoltitle[12]=`echo "surf wat"` shortcoltitle[13]=`echo "Ridge h"` shortcoltitle[14]=`echo "Ridge w"` shortcoltitle[15]=`echo "Ridge s"` shortcoltitle[16]=`echo "Ridge o"` shortcoltitle[17]=`echo "Dike h"` shortcoltitle[18]=`echo "Dike w"` shortcoltitle[19]=`echo "Dike s"` shortcoltitle[20]=`echo "Rand r"` shortcoltitle[21]=`echo "GMD"` shortcoltitle[22]=`echo "GSD"` shortcoltitle[23]=`echo "Mnot"` shortcoltitle[24]=`echo "Minf"` shortcoltitle[25]=`echo "Ag stab"` shortcoltitle[26]=`echo "Crust f"` shortcoltitle[27]=`echo "L on crust"` shortcoltitle[28]=`echo "L cover frac"` shortcoltitle[29]=`echo "bulk den"` shortcoltitle[30]=`echo "T Flat cov frac"` shortcoltitle[31]=`echo "T Stem cov frac"` shortcoltitle[32]=`echo "C LAI"` shortcoltitle[33]=`echo "C SAI"` shortcoltitle[34]=`echo "C Stem mass"` shortcoltitle[35]=`echo "C canopy cov"` shortcoltitle[36]=`echo "C height"` shortcoltitle[37]=`echo "C Rep Stem Dia"` shortcoltitle[38]=`echo "C biodrag"` shortcoltitle[39]=`echo "C cover"` shortcoltitle[40]=`echo "R ave height"` shortcoltitle[41]=`echo "R SAI"` shortcoltitle[42]=`echo "R LAI"` shortcoltitle[43]=`echo "R biodrag"` shortcoltitle[44]=`echo "R canopy cov"` shortcoltitle[45]=`echo "R cover"` shortcoltitle[46]=`echo "1-eros"` shortcoltitle[47]=`echo "1-snow"` shortcoltitle[48]=`echo "anemom f vel"` shortcoltitle[49]=`echo "rr f vel"` shortcoltitle[50]=`echo "or f vel"` shortcoltitle[51]=`echo "biodrag f vel"` shortcoltitle[52]=`echo "site f vel"` shortcoltitle[53]=`echo "bare thresh f vel"` shortcoltitle[54]=`echo "f cov inc"` shortcoltitle[55]=`echo "surf wet inc"` shortcoltitle[56]=`echo "ag den inc"` shortcoltitle[57]=`echo "thresh f vel"` shortcoltitle[58]=`echo "f vel anemom/site"` shortcoltitle[59]=`echo "f vel rr/site"` shortcoltitle[60]=`echo "f vel or/site"` shortcoltitle[61]=`echo "f vel biodrag/site"` shortcoltitle[62]=`echo "thresh bare/site"` shortcoltitle[63]=`echo "thresh flat cov/site"` shortcoltitle[64]=`echo "thresh surf wet/site"` shortcoltitle[65]=`echo "thresh ag den/site"` shortcoltitle[66]=`echo "< 0.84 mm"` shortcoltitle[67]=`echo "> 2 mm"` shortcoltitle[68]=`echo "aero rough"` shortcoltitle[69]=`echo "no emit"` shortcoltitle[70]=`echo "< 0.01 mm ic"` shortcoltitle[71]=`echo "< 0.1 mm ic"` shortcoltitle[72]=`echo "< 0.84 mm ic"` shortcoltitle[73]=`echo "< 2 mm ic"` shortcoltitle[74]=`echo "< 0.01 mm"` shortcoltitle[75]=`echo "< 0.1 mm"` shortcoltitle[76]=`echo "< 0.84 mm"` shortcoltitle[77]=`echo "< 2 mm"` # set up column groupings tgroups=16 colgroupnum[6]=1 colgroupnum[7]=1 colgroupnum[8]=1 colgroupnum[9]=2 colgroupnum[10]=3 colgroupnum[11]=4 colgroupnum[12]=5 colgroupnum[13]=4 colgroupnum[14]=4 colgroupnum[15]=4 colgroupnum[16]=3 colgroupnum[17]=4 colgroupnum[18]=4 colgroupnum[19]=4 colgroupnum[20]=4 colgroupnum[21]=4 colgroupnum[22]=4 colgroupnum[23]=4 colgroupnum[24]=4 colgroupnum[25]=6 colgroupnum[26]=5 colgroupnum[27]=16 colgroupnum[28]=5 colgroupnum[29]=7 colgroupnum[30]=5 colgroupnum[31]=5 colgroupnum[32]=9 colgroupnum[33]=10 colgroupnum[34]=1 colgroupnum[35]=5 colgroupnum[36]=11 colgroupnum[37]=11 colgroupnum[38]=12 colgroupnum[39]=5 colgroupnum[40]=11 colgroupnum[41]=10 colgroupnum[42]=9 colgroupnum[43]=12 colgroupnum[44]=5 colgroupnum[45]=5 colgroupnum[46]=13 colgroupnum[47]=13 colgroupnum[48]=14 colgroupnum[49]=14 colgroupnum[50]=14 colgroupnum[51]=14 colgroupnum[52]=14 colgroupnum[53]=14 colgroupnum[54]=14 colgroupnum[55]=14 colgroupnum[56]=14 colgroupnum[57]=14 colgroupnum[58]=14 colgroupnum[59]=15 colgroupnum[60]=15 colgroupnum[61]=15 colgroupnum[62]=15 colgroupnum[63]=15 colgroupnum[64]=15 colgroupnum[65]=15 colgroupnum[66]=5 colgroupnum[67]=5 colgroupnum[68]=4 colgroupnum[69]=5 colgroupnum[70]=5 colgroupnum[71]=5 colgroupnum[72]=5 colgroupnum[73]=5 colgroupnum[74]=5 colgroupnum[75]=5 colgroupnum[76]=5 colgroupnum[77]=5 # group y axis labels grouplabel[1]=`echo "Mass (kg/m^2)"` grouplabel[2]=`echo "Speed (m/s)"` grouplabel[3]=`echo "Degrees from N"` grouplabel[4]=`echo "length (mm)"` grouplabel[5]=`echo "Fraction (0-1)"` grouplabel[6]=`echo "Stability (J/cm^2)"` grouplabel[7]=`echo "Density (Mg/m^3)"` grouplabel[8]=`echo "Percent"` grouplabel[9]=`echo "Leaf Area Index"` grouplabel[10]=`echo "Stem Area Index"` grouplabel[11]=`echo "meters"` grouplabel[12]=`echo "biodrag"` grouplabel[13]=`echo "0 or 1"` grouplabel[14]=`echo "Friction Velocity"` grouplabel[15]=`echo "Velocity Ratio"` grouplabel[16]=`echo "Mass (Mg/m^2)"` # define range for special group with stacked lines sumgroupmin=45 sumgroupmax=48 sumgrouptotcnt=0 # create column number, file name pairs # screen column numbers for valid values # determine number of index blocks in each series # 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 # check command argument count, zero means none if [[ ncmdarg -eq 0 ]] then echo 'invocation: allplot [Col_num-1 Col_num-2 ... Colnum-# file-1] [Col_num-1 Col_num-2 ... Colnum-# file-2] ... [Col_num-1 Col_num-2 ... Colnum-# file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit fi # parse command arguments checking for numbers and when not a number checking for a valid file name # initialize total number of columns parsed tcols=0 # initialize total number of valid file names parsed (must assume one when column numbers preceed file names) tfiles=1 # initialize column count for first file name tcolfile[tfiles]=0 for ncmd in $( seq 1 $ncmdarg ) do # test if it is an integer number echo "${cmdarg[ncmd]}" | grep [^0-9] > /dev/null 2>&1 if [ "$?" -eq "0" ] then # not a column number, check for file name if [ -e "${cmdarg[ncmd]}" ] then # valid file name, check for preceeding columns if [[ tcolfile[tfiles] -gt 0 ]] then # columns are listed in front of this name # back fill column file name pairings for ncol in $( seq 1 ${tcolfile[tfiles]} ) do # write file name let index=(tcols-tcolfile[tfiles])+ncol filename[index]="${cmdarg[ncmd]}" done # add file name to unique file names list ufilename[tfiles]="${cmdarg[ncmd]}" # Increment file number counter let tfiles+=1 # zero out count of special stacked columns sumgrouptotcnt=0 fi # find number of index blocks in this file linecount=`wc -l < ${ufilename[tfiles-1]}` lineswithnumbers=`grep -c '\.' < ${ufilename[tfiles-1]}` 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" else # not a valid file name, show error message and exit echo \'"${cmdarg[ncmd]}"\' is not valid file name. exit fi else # it is an integer number, check for valid column number if [[ ${cmdarg[ncmd]} -lt $mincol ]] then echo \'"${cmdarg[ncmd]}"\' is a Bad Column Number echo 'invocation: allplot [Col_num-1 Col_num-2 ... Colnum-# file-1] [Col_num-1 Col_num-2 ... Colnum-# file-2] ... [Col_num-1 Col_num-2 ... Colnum-# file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit elif [[ ${cmdarg[ncmd]} -gt $maxcol ]] then echo \'"${cmdarg[ncmd]}"\' is a Bad Column Number echo 'invocation: allplot [Col_num-1 Col_num-2 ... Colnum-# file-1] [Col_num-1 Col_num-2 ... Colnum-# file-2] ... [Col_num-1 Col_num-2 ... Colnum-# file-#]' echo 'Valid Column Numbers are:' for num in $( seq $mincol $maxcol ) do echo ${coltitle[num]} done exit fi # valid column number, add into column number array and increment indexes let tcols+=1 let tcolfile[tfiles]+=1 colnum[tcols]="${cmdarg[ncmd]}" # set column group number colgroup[tcols]=${colgroupnum[${colnum[tcols]}]} # set column file number colfilenum[tcols]=${tfiles} # create column listing for plotting special column group if [ ${colnum[tcols]} -ge ${sumgroupmin} ] && [ ${colnum[tcols]} -le ${sumgroupmax} ] then # add the number of columns that fall into the sum group let "sumgrouptotcnt = sumgrouptotcnt + 1" let "sumgroupcnt[tcols] = sumgrouptotcnt" # stack the values on top of the first one in the order entered if [ ${sumgrouptotcnt} -eq 1 ] then sumgrouplist[tcols]="\$${colnum[tcols]}" else sumgrouplist[tcols]="${sumgrouplist[tcols-1]}+\$${colnum[tcols]}" fi fi fi done # screen for terminating valid file name if [ ! -e "${filename[tcols]}" ] then echo "No terminating file name." echo 'invocation: allplot [Col_num-1 Col_num-2 ... Colnum-# file-1] [Col_num-1 Col_num-2 ... Colnum-# file-2] ... [Col_num-1 Col_num-2 ... Colnum-# file-#]' fi # set tfiles to the correct count let tfiles-=1 # echo the resulting arrays of column numbers and file names # echo "The input command line results in the following columns and file names:" # for num in $( seq 1 ${tcols} ) # do # echo "${colnum[num]} ${colgroup[num]} ${filename[num]}" # done # exit # set up graph to column group correspondence # sort group list (result is zero reference array) colgroupsort=(`echo ${colgroup[@]} | transpose | sort | transpose`) # total number of column groups to be plotted tgroups=1 # list of groups represented groupnum[1]=${colgroupsort[0]} let tindex=tcols-1 for num in $( seq 1 ${tindex} ) do let index=num-1 if [[ ${colgroupsort[num]} -ne ${colgroupsort[index]} ]] then let tgroups+=1 groupnum[tgroups]=${colgroupsort[num]} fi done # show groups # echo "unique group numbers" # echo ${groupnum[@]} # exit # find maximum column value for each column and assign that to the maximum for the group for num in $( seq 1 $tcols ) do echo -n " Find maximum value: column ${colnum[num]} in ${filename[num]} : " # find selected column maximum value for this file if [ ${colnum[num]} -ge 6 ] && [ ${colnum[num]} -le 8 ] then # Erosion values are negative, invert filemaxval=`dm "if -x${colnum[num]}>0 then -x${colnum[num]} else SKIP" < ${filename[num]} | stats max` echo "${filemaxval}" else filemaxval=`dm "if x${colnum[num]}>0 then x${colnum[num]} else SKIP" < ${filename[num]} | stats max` echo "${filemaxval}" fi # special case for displaying friction velocity and threshold # do not scale according to the soil wetness threshold increase if [ ${colnum[num]} -ne 47 ] && [ ${colnum[num]} -ne 49 ] || [ ${tcols} -eq 1 ] then # check for maximum for this column group for all files if [ ${tcols} -ne 1 ] && [ ${colnum[num]} -ge 45 ] && [ ${colnum[num]} -le 49 ] then # expand maximum a little since not scaled to all maximum filemaxval=$( echo "scale=4; ${filemaxval}*1.2" | bc -l ) fi groupmaxval[${colgroup[num]}]=`echo "$filemaxval ${groupmaxval[${colgroup[num]}]}" | stats max` echo "groupmaxval(${colgroup[num]}) now equal to ${groupmaxval[${colgroup[num]}]}" fi 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[1]}]} # create text for graph title, using file names graphtitle="Files: " for num in $( seq 1 ${tfiles} ) do graphtitle=`echo "${graphtitle} ${num}) ${ufilename[num]} "` done # Set up plot sizes for multiple plots (ie. groups) if [[ $tgroups -gt 1 ]] then # plot sizes for each group psizebase=$( echo "scale=4; 0.9/${tgroups}" | bc -l ) for num in $( seq 1 $tgroups ) do # create coordinates # y size for plot (x is 1.0) if [[ $num -eq 1 ]] then # increase the size of the first plot psize[num]=$( echo "scale=4; ${psizebase}+0.05" | bc -l ) # place plots from the top down in the order specified porigin[num]=$( echo "scale=4; 0.05+($tgroups-$num)*${psizebase}" | bc -l ) elif [[ $num -eq $tgroups ]] then # increase the size of the last plot psize[num]=$( echo "scale=4; ${psizebase}+0.05" | bc -l ) porigin[num]=0 else psize[num]=${psizebase} porigin[num]=$( echo "scale=4; 0.05+($tgroups-$num)*${psizebase}" | bc -l ) fi done fi # 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[1]}]} # write single instance lines top plot file #--- start pdf --- echo "set terminal pdf font 'Helvetica,4'" > temp.plt echo "set output 'allplot.pdf'" >> temp.plt view_pause=0 #--- end pdf --- #--- start postscript --- #echo "set terminal postscript 'Helvetica,6'" > temp.plt #echo "set output 'allplot.eps'" >> temp.plt #view_pause=0 #--- end postscript --- ##--- start emf --- ## create temporary directory for files if needed #tempdir="htemp" #mkdir -p ${tempdir} ## clear any files #rm ${tempdir}/*.emf #echo "set terminal emf monochrome dashed" > temp.plt #view_pause=0 #echo "set line style 1 lt 1 lw 1" >> temp.plt #echo "set line style 2 lt 2 lw 1" >> temp.plt #echo "set line style 3 lt 3 lw 1" >> temp.plt #echo "set line style 4 lt 4 lw 1" >> temp.plt #echo "set line style 5 lt 5 lw 1" >> temp.plt #echo "set line style 6 lt 1 lw 3" >> temp.plt #echo "set line style 7 lt 2 lw 3" >> temp.plt #echo "set line style 8 lt 3 lw 3" >> temp.plt #echo "set line style 9 lt 4 lw 3" >> temp.plt #echo "set line style 10 lt 5 lw 3" >> temp.plt #echo "set line style 11 lt 1 lw 5" >> temp.plt ##--- end emf --- #--- start screen --- #view_pause=-1 #echo "" > temp.plt #--- end screen --- # set legend location echo "set key left top" >> temp.plt echo "set xrange [0:366]" >> temp.plt #echo "set xrange [0:100]" >> temp.plt for year in $(seq $numindex) do echo "Simulation Year = $year" # # --- emf output files --- # echo "set output '${tempdir}/${year}.emf'" >> temp.plt # zero out special group counter sumgroupcnt=0 # create graph title line echo "set title 'Simulation Yr ${year}, ${graphtitle}'" >> temp.plt # set up single or multiple plot windows if [[ $tgroups -gt 1 ]] then echo "multiple plots" echo "set size 1.0, 1.0" >> temp.plt echo "set origin 0.0, 0.0" >> temp.plt echo "set multiplot" >> temp.plt fi # create plot commands for each group for idx in $( seq 1 $tgroups ) do # only print title once, above first graph if [[ $idx -gt 1 ]] then echo "set title ''" >> temp.plt fi # remove x axis from all but last graph if [[ $idx -lt $tgroups ]] then # remove x axis labels echo "set format x ''" >> temp.plt echo "set xlabel ''" >> temp.plt else # remove x axis labels echo "set format x '% g'" >> temp.plt echo "set xlabel 'Day of Year'" >> temp.plt fi # individual sizes for multiplots if [[ $tgroups -gt 1 ]] then # set plot size echo "set size 1.0, ${psize[idx]}" >> temp.plt echo "set origin 0.0, ${porigin[idx]}" >> temp.plt fi # set axis scales, labels echo "set yrange [0:${groupmaxval[${groupnum[idx]}]}]" >> temp.plt # echo "set yrange [0:2]" >> temp.plt echo "set ylabel '${grouplabel[${groupnum[idx]}]}'" >> temp.plt # create plot lines for each column and file in this group index=0 for num in $(seq 1 $tcols) do if [[ colgroup[num] -eq groupnum[idx] ]] then let index+=1 let yearm=year-1 # create plotlines for special columns if [ ${colnum[num]} -ge ${sumgroupmin} ] && [ ${colnum[num]} -le ${sumgroupmax} ] then # stack the values on top of the first one in the order entered if [ ${sumgroupcnt[num]} -eq 1 ] then plotline[index]="'${filename[num]}' index ${yearm} using 2:${colnum[num]} with lines title '${colfilenum[num]}) ${shortcoltitle[${colnum[num]}]}', \\" else plotline[index]="'${filename[num]}' index ${yearm} using 2:(${sumgrouplist[num]}) with lines title '${colfilenum[num]}) Plus ${shortcoltitle[${colnum[num]}]}', \\" fi else if [ ${colnum[num]} -ge 6 ] && [ ${colnum[num]} -le 8 ] then # erosion values are negative, invert plotline[index]="'${filename[num]}' index ${yearm} using 2:(-\$${colnum[num]}) with lines title '${colfilenum[num]}) ${shortcoltitle[${colnum[num]}]}', \\" else plotline[index]="'${filename[num]}' index ${yearm} using 2:${colnum[num]} with lines title '${colfilenum[num]}) ${shortcoltitle[${colnum[num]}]}', \\" fi fi fi done # add plot command to first plotline plotline[1]=`echo "${plotline[1]}" | sed -e 's/^.*/plot &/'` # strip last plotline of 3 extra characters plotline[index]=`echo "${plotline[index]}" | sed -e 's/...$//'` # write out plot lines to file for num in $(seq 1 $index) do echo ${plotline[num]} >> temp.plt done done # check multiple plots if [[ $tgroups -gt 1 ]] then # this command necessary to display all plots on some terminals echo "unset multiplot" >> temp.plt fi echo "pause ${view_pause}" >> temp.plt done gnuplot temp.plt #rm temp.plt exit