AWK script awkit_tmp:
BEGIN {
FS=","
}
{
FS= ","
ARGC = 2
if ($1=="$GPRMC") {
gpstime = $2
hr = substr($2,1,2)
min = substr($2,3,2)
sec = substr($2,5,2)
latdeg = substr($4,1,2)
latmin = substr($4,3,6)
londeg = substr($6,2,2)
lonmin = substr($6,4,6)
declat = latdeg + (latmin/60)
declon = (londeg + (lonmin/60)) * -1
date = $10
day = substr($10,1,2)
month = substr($10,3,2)
year = substr($10,5,2)
printf("%8.6f, %8.6f, %s:%s:%s, %s, %s\n",declon, declat, hr, min, sec, date, ARGV[2])
}
}
This AWK script was initialized by "doawk" - shell script run under CYGWIN (UNIX like environment that runs under Windows):
files=`ls *.gps | cut -d. -f1` for file in $files do awk -f awkhold $file.gps $file >> resnav_jd250.txt done
{
shipdate = $1
gpstime = $2
latdeg = substr($5,1,2)
latdecmin = $6
declat = latdeg + (latdecmin/60)
londeg = substr($7,1,3)
londecmin = $8
declon = -1 * (londeg + (londecmin/60))
depmeters = $10 printf("%s, %s, %9.6f, %9.6f, %s\n",shipdate, gpstime, declat, >declon, depmeters)
}
AWK script awknewgps:
BEGIN {
FS=","
}
{
FS=","
alltime=$2
hr=substr($2,1,2)
min=substr($2,4,2)
sec=substr($2,7,2)
month=substr($1,1,2)
day=substr($1,4,2)
yr=substr($1,9,2)
depth=$5
declon=$4 * -1
londeg=int(declon)
lonmin=(declon-londeg)*60
declat=$3
latdeg=int(declat)
latmin=(declat-latdeg)*60 >printf("$GPRMC,%s%s%s,A,%02d%06.3f,N,%03d%06.3f,W,000.0,0,%s%s%s,0,W*73\n",hr,min,sec,latdeg,latmin,londeg,lonmin,day,month,yr)
printf("$SDDPT,%s,0.0*56\n",depth)
printf("$SDMTW,24.3,C*01\n") }
AWK script awkhold:
BEGIN {
FS = ","
}
{
FS = ","
ARGC = 2
depth = -9999
temp = -9999
if ($1=="$GPRMC")
{
utctime = $2
date = $10
latdeg = substr($4,1,2)
latmin = substr($4,3,6)
declat = latdeg + (latmin/60)
londeg = substr($6,1,3)
lonmin = substr($6,4,6)
declon = -1 * (londeg + (lonmin/60))
if (NR==1) {
holddepth = -9999
holdtemp = -9999
}
else {
printf("%9.6f, %9.6f, %s, %s, %5.1f, %5.1f, %s\n", holddeclon, >holddeclat, holdutctime, holddate, holddepth, holdtemp, ARGV[2])
}
holdutctime = >substr(utctime,1,2)":"substr(utctime,3,2)":"substr(utctime,5,2)
holddate = date
holddeclon = declon
holddeclat = declat
holddepth = -9999
holdtemp = -9999
}
if ($1=="$SDDPT")
{
depthreal = $2
holddepth = depthreal
}
if ($1=="$SDMTW")
{
tempreal = $2
holdtemp = tempreal
}
}
END {
printf("%9.6f, %9.6f, %s, %s, %5.1f, %5.1f, %s\n", holddeclon, holddeclat, >holdutctime, holddate, holddepth, holdtemp, ARGV[2])
}
The running of the script was initiated with a simple executable shell script "doawk":
files=`ls *.gps | cut -d. -f1`
for file in $files
do
awk -f awkhold $file.gps $file >> resnav_jd250.txt
done
schema.ini: [resnav_jd250.txt] Format=CSVDelimited ColNameHeader=True Col1=longitude Double Col2=latitude Double Col3=gpstime Text Width 8 Col4=gpsdate Text Width 10 Col5=depth_m float Col6=temp_c float Col7=linename Text Width 11