#!/bin/bash # plot a cligen generated file # invocation: cliplot file [year] if [ "$1" = "" ] then echo "Useage: cliplot climate-file-name [year]" exit fi # strip header off of file dm 'if INLINE > 15 then INPUT else SKIP' < $1 > temp # get max years from file maxyear=`tail < temp | dm x3 | stats max` #echo "maxyear = $maxyear" # zero out plot file #--- start pdf --- view_pause=0 echo "set terminal pdf" > temp.plt echo "set output 'cliplot.pdf'" >> temp.plt #--- end pdf --- #--- start screen --- #view_pause=-1 #echo "# sends to screen defaults" > temp.plt #--- end screen --- # optional input of specific year plot if [ "$2" = "" ] then # value used for all years echo "set xrange [0:366]" >> temp.plt echo "set yrange [-30:50]" >> temp.plt echo "set xtics (1,32,60,91,121,152,182,213,244,274,305,335)" >> temp.plt # for each year plot groups of outputs # loop by year for year in $(seq $maxyear) do echo "year $year" # select year and put in file dm "if x3=$year then INPUT else SKIP" < temp > temp$year # generate temperature plot echo "set title 'Temperatures, year = $year'" >> temp.plt # echo "plot 'temp${year}' using 0:8 with lines linetype 1 title 'Tmax', 'temp${year}' using 0:9 with lines linetype 2 title 'Tmin', 'temp${year}' using 0:13 with lines linetype 3 title 'Tdew'" >> temp.plt echo "plot 'temp${year}' using 0:8 with lines linetype 1 title 'Tmax', 'temp${year}' using 0:9 with lines linetype 2 title 'Tmin', 0, -5" >> temp.plt echo "pause ${view_pause}" >> temp.plt # generate solar radiation plot # add others as needed # end year loop done else year=$2 # Plot a single year if [[ $year -gt $maxyear || $year -lt 1 ]] then # input year is not within range of maxyear echo "Year: $year entered on command line" echo "Maximum Year in file: $maxyear" exit else # create single year plot # select year and put in file dm "if x3=$year then INPUT else SKIP" < temp > temp1 # generate temperature plot echo "set title 'Temperatures, year = $year'" >> temp.plt echo "set xrange [0:366]" >> temp.plt #echo "set yrange [-20:50]" >> temp.plt echo "set xtics (1,32,60,91,121,152,182,213,244,274,305,335)" >> temp.plt echo "plot 'temp1' using 0:8 with lines linetype 1 title 'Tmax', 'temp1' using 0:9 with lines linetype 2 title 'Tmin', 'temp1' using 0:13 with lines linetype 3 title 'Tdew'" >> temp.plt echo "pause ${view_pause} 'end display?'" >> temp.plt # generate solar radiation plot # add others as needed fi fi gnuplot temp.plt rm temp.plt temp for year in $(seq $maxyear) do rm temp$year done