#!/bin/bash # Takes 2 files # First file with Day Month Year Tmax Tmin Tavg Avg_RH Avg_VP Avg_VPD wind_run Solar_rad # used to find the monthly average maximum and minimum temperatures and solar radiation # Second file with Day Month Year precip # determine number of years of data for precip file firstyr=`head -1 < $2 | dm x3` lastyr=`tail -2 < $2 | dm x3 | stats max` let totyr=lastyr-firstyr+1 # extract values for each month and average for nline in $(seq 12) do avgtmax[nline]=`dm "if x2==$nline then x4 else SKIP" < $1 | stats mean` avgtmin[nline]=`dm "if x2==$nline then x5 else SKIP" < $1 | stats mean` avgsolrad[nline]=`dm "if x2==$nline then x11*23.88 else SKIP" < $1 | stats mean` avgprecip[nline]=`dm "if x2==$nline then x4 else SKIP" <$2 | stats sum | dm x1/$totyr` done # write lines and headers echo " 5.222" echo " 1 0 0" echo " Station: AKRON CGPRS CLIGEN VERSION 5.222 -r: 0 -I: 0" echo " Latitude Longitude Elevation (m) Obs. Years Beginning year Years of record:" echo " 40.1535 -103.1281 1378 10 1992 10" echo " Observed monthly ave max temperature (C)" echo " ${avgtmax[@]}" echo " Observed monthly ave min temperature (C)" echo " ${avgtmin[@]}" echo " Observed monthly ave solar radiation (Langleys/day)" echo " ${avgsolrad[@]}" echo " Observed monthly ave precipitation (mm)" echo " ${avgprecip[@]}" echo " da mo year prcp dur tp ip tmax tmin rad w-vl w-dir tdew" echo " (mm) (h) (C) (C) (l/d) (m/s)(Deg) (C)"