#!/bin/bash #======================================================================================== # S V A L E X - 2 0 0 4 : N a v d a t a Q C p l o t s # # Using Gnuplot, generate png plots of shot point distances and DOL (Distance Off Line). # # Dept. of Earth Science # University of Bergen, Norway # # To create html page with thumbnail image gallery, install Igal and use this command: # igal -f -w 6 -y 120 -bigy 800 # Igal home page: http://www.stanford.edu/~epop/igal/ # # Rev. Date By Description # ------------------------------------------------------------------------ # 0.1 22. Nov. 2005 O. Meyer Initial version. #======================================================================================== #--- Change these variables if needed DIR="/home/olem/www/SVALEX-2004/Aleksandre/navdata" GNUPLOT="/usr/bin/gnuplot" for file in $(ls $DIR); do # Loop over all files in target directory if [ ${file#*.} = txt ]; then # Only process files with extension .txt. Use bash variable string operation to test filename extension. FILEPATH="$DIR/$file" echo -n "Plotting: $FILEPATH ... " #--- First calculate shot distance using Pythagoras. #--- Assuming we have shotpoint number in the first coloumn, and UTM coordinates in columns no. 3 and 4. #--- Value for the first shotpoint is meaningless, so use awk variable 'line' to get rid of this. cat $FILEPATH | awk 'BEGIN {line=0} /^[0-9]/ {line+=1; if (line>1) print $1, sqrt(($3-x)**2+($4-y)**2); x = $3; y = $4}' > Shot_distance #--- Now get Shotpoint/DOL pairs and dump to file. Assuming DOL is in column no. 8 cat $FILEPATH | awk '/^[0-9]/ {print $1,$8}' > DOL #--- Gnuplot section. Using the 'here document' method, script variables can be transfered to Gnuplot. $GNUPLOT << End_of_Gnuplot_section set terminal png color picsize 1100 800 # PNG terminal capabilities can vary ... set output "${file%.*}.png" # Strip file extension, use 'png' instead. The variable 'file' is from 'for' loop above. set autoscale y2 set grid set y2tics set ytics nomirror set y2tics nomirror #--- Now strip part of filename that starts with '_'. Assuming we have filename like 'Line10_LOG.txt' set title "SVALEX-2004: Plot of shot distance interval and DOL vs. shot number for ${file%_*}" set xlabel "Shot number" set ylabel "Shotpoint distance [m]" set y2label "DOL = Distance Off Line [m]" set key outside below box plot "Shot_distance" axis x1y1 with lines, "DOL" axis x1y2 with impulses #--- Final EOF must be positioned at left margin. End_of_Gnuplot_section echo "done" fi done #--- Remove temp stuff rm Shot_distance rm DOL