#!/bin/sh # # drft06rr_wp2lis - turn Dave's waypoints file into *.lis files # drft06rr_dredges.lis and drft06rr_smts.lis # # Paul Wessel, 03-DEC-2001 cat << EOF > $$.awk # This script extracts lon lat WPT { first = substr (\$1,1,1) if (first > 0 && first <= 9) # Waypoint { yd = \$2 ym = \$3 xd = \$4 xm = \$5 if (yd > 16 && yd < 30 && xd > 77 && xd < 115) { printf "%s:%sW\t%s:%sS\t%s\n", xd, xm, yd, ym, \$1 } } } EOF egrep -v '^$|^Dredge|^SMT|^ ' waypoints.txt | sed -e 's/(rev)//g' -e 's/rev//g' | awk -f $$.awk > waypts.d cat << EOF > $$.awk # This script extracts dredge-ID SMT-ID W E S N { if (substr(\$1,1,3) == "SMT") { smt = substr(\$1,4,3) if (NF == 13) { wd = \$2 wm = \$3 ed = \$4 em = \$5 sd = \$6 sm = \$7 nd = \$8 nm = \$9 ok = 1 } else if (NF == 15) { wd = \$4 wm = \$5 ed = \$6 em = \$7 sd = \$8 sm = \$9 nd = \$10 nm = \$11 ok = 1 } else ok = 0 } if (\$1 == "Dredge") { n = int(\$2) s = 3 if (n >= 100) s = 4 if (length(\$2) >= s && substr(\$2,s,1) == "-") { ID = n } else { ID = substr(\$2,1,s) } key = substr(\$2,length(\$2)) if (ok) printf "%s\t%s\t%s:%sW\t%s:%sW\t%s:%sS\t%s:%sS\t%s\n", ID, smt, wd, wm, ed, em, sd, sm, nd, nm, key } } EOF tail +25 waypoints.txt | egrep '^Dredge|^SMT' | tr '(,)', ' ' | awk -f $$.awk > ds.d rm -f $$.awk n=`cat ds.d | wc -l` cut -f3,4,5,6 ds.d | gmtconvert -fi0x,1x,2y,3y > xy.d grep -v '^#' drft06rr_boxes.lis | awk '{printf "%lg\t%lg\t%s\n", 0.5 * ($2 + $3), 0.5 * ($4 + $5), $1}' > tmp i=1 cat << EOF > drft06rr_dredges.lis # This is the list of dredges and the seamounts & boxes they belong to. # Also included is Type (D - datable and geochemical, G - geochemical, O - Other - Mn crust, biology, sediments, E - Empty) # (Do not edit - file is automatically created by drft06rr_wp2lis) # D-ID SMT BOX TYPE EOF rm -f drft06rr_smts.lis touch drft06rr_smts.lis while [ $i -le $n ]; do line1=`sed -n ${i}p ds.d` xy=`sed -n ${i}p xy.d | awk '{printf "%lg/%lg\n", 0.5 * ($1 + $2), 0.5 * ($3 + $4)}'` box=`mapproject -G$xy/k tmp -f0x,1y | sort -k 4,4 -g | awk '{if (NR == 1) print $3}'` echo "$line1 $box" | awk '{printf "%s\t%s\t%s\t%s\t%s\t%s\n", $2, $8, $3, $4, $5, $6}' >> drft06rr_smts.lis echo "$line1 $box" | awk '{printf "%s\t%s\t%s\t%s\n", $1, $2, $8, $7}' >> drft06rr_dredges.lis i=`expr $i + 1` done cat << EOF > t # List of seamount targets, which box they fall in and # the box west/east/south/north coordinates. # (Do not edit - file is automatically created by drft06rr_wp2lis) # # Smt Box W E S N EOF sort -k 1 -u drft06rr_smts.lis >> t mv t drft06rr_smts.lis rm -f tmp ds.d xy.d