#! /bin/bash # generated windgen file and histogram file are compared on a single graph # The generated windgen file is processed into a histogram file, then the # comparison to the specified histogram file graphed. Histogram_filename # is optional and will only create graph of generated windgen data file. # invocation: windgen_histo_files [windgen_filename] [histogram_filename] # 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 -ne 2 ]] then if [[ ncmdarg -ne 1 ]] then echo 'windgen_histo_files [windgen_filename] [histogram_filename]' exit fi fi # parse command arguments checking for valid file names when not a valid file name a valid option # initialize total number of station numbers found totsta=0 tcolfile[tfiles]=0 for ncmd in $( seq 1 $ncmdarg ) do # test if it is a valid file name if [ -e "${cmdarg[ncmd]}" ] then # increment station number count let totsta=totsta+1 # it is a valid file name, assign to list filename[totsta]=${cmdarg[ncmd]} else # not a valid column for an invalid file name, echo error echo "File: ${cmdarg[ncmd]} :does not exist." exit fi done echo "Creating histogram from windgen data file: ${filename[1]}" # convert windgen output file into mdb input file ~/wind_data/gen2mdb < ${filename[1]} > temp.org # create histogram data file from mdb input file ~/wind_data/wind_mdb -x < temp.org > temp.wdb # graph the two histogram files for comparison if [[ totsta -eq 1 ]] then windhisto_files temp.wdb else windhisto_files ${filename[2]} temp.wdb fi #rm temp.org #rm temp.wdb