#!/bin/bash # Takes hourly precip record and creates daily depth, duration, peak fraction and peak intensity records for days with rain. # get line a place line values in variable array lineval=`dm x7 x6 x5 x9*0.254 x11*0.254 x13*0.254 x15*0.254 x17*0.254 x19*0.254 x21*0.254 x23*0.254 x25*0.254 x27*0.254 x29*0.254 x31*0.254 x33*0.254 x35*0.254 x37*0.254 x39*0.254 x41*0.254 x43*0.254 x45*0.254 x47*0.254 x49*0.254 x51*0.254 x53*0.254 x55*0.254 x57*0.254 < $1` # set up hourly value array np=0 for singval in ${lineval[@]} do let np=np+1 if [ $np -gt 3 ] then if [ $np -lt 28 ] then let index=np-3 hourvals[index]=$singval # echo "hourvals($index) = ${hourvals[index]}" fi else # retain the date values for output section dateval[np]=$singval fi if [ $np -eq 28 ] then # reset extraction counter np=0 if [ "$singval" != "0" ] then echo "${hourvals[@]}" # create statistics for line index=0 begrain=0 endrain=0 cntrain=0 maxrain=0 locmaxrain=0 for hourval in ${hourvals[@]} do let index=index+1 # find first rain hour if [ "$begrain" -eq "0" ] then if [ "$hourval" != "0" ] then begrain=$index fi fi # find last rain hour if [ "$hourval" != "0" ] then endrain=$index fi let durrain=endrain-begrain+1 # count number of rain hours if [ "$hourval" != "0" ] then let cntrain=cntrain+1 fi # check for tie on values if [ "$hourval" = "$maxrain" ] then let cntmaxtie=cntmaxtie+1 locmaxrain=`echo "$locmaxrain $index $cntmaxtie" | dm "x1+((x2-x1)/x3)"` fi # find location of maximum testmax=`echo "$hourval $maxrain" | dm "if x1 > x2 then x1 else 0"` if [ "$testmax" != "0" ] then cntmaxtie=1 locmaxrain=$index maxrain=$testmax fi done # calculate the output values durrain=`echo "$endrain $begrain $cntrain" | dm "if (x1-x2+1)/x3 > 2 then x3*2 else x1-x2+1"` timepeak=`echo "$endrain $begrain $locmaxrain" | dm "(x3-x2+0.5)/(x1-x2+1)"` intensepeak=`echo "$maxrain" | dm "x1*2"` echo " ${dateval[1]} ${dateval[2]} ${dateval[3]} $singval $durrain $timepeak $intensepeak" fi fi done