Processing/CaliGeo: sbet2cali.sh

File sbet2cali.sh, 1.3 KB (added by benj, 15 years ago)

Bash script to convert ASCII SBET files (as output by PosPac's "Output" program) to Caligeo-readable format

Line 
1# Script file for converting POSPac output ASCII SBET files into nav files readable by CaliGeo
2#
3# Author: Ben Taylor
4# Date: 05/02/2008
5#
6# Arguments:
7# $1: Input file name
8# $2: Output file name
9# $3: -del to delete original ASCII sbet file when done (default), -nodel to leave it there
10
11if [ ! $2 ] ; then
12        echo "Not enough arguments. Usage: sbet2cali.sh Input_File Output_File [-del|-nodel]"
13        exit 1
14elif [ $3 ] ; then
15        if [ $3 == "-nodel" ] ; then
16                NODELETEFILE=true
17        elif [ $3 != "-del" ] ; then
18                echo "Delete argument unrecognised. Usage: sbet2cali.sh Input_File Output_File [-del|-nodel]"
19                exit 1
20        fi
21fi
22
23TEMPDIR=/tmp #Temp directory location - must exist
24
25#Temporary files
26TEMPFILE=${TEMPDIR}/cali_tmp.txt
27
28# First line specifies that first column is GPS time
29echo "time = gps" > $2
30echo "; TIME(s) LATITUDE(deg) LONGITUDE(deg) ALTITUDE(m) ROLL(deg) PITCH(deg) HEADING(deg)" >> $2
31
32# Trim off first 23 lines - header information not used by CaliGeo
33tail -n +24 $1 > $TEMPFILE
34
35# Run AWK script to trim unwanted columns
36awk '{ \
37        printf "%s %s %s %s %s %s %s\n", $1, $6, $7, $8, $9, $10, $11
38        }' $TEMPFILE >> $2
39       
40# Delete temporary file
41rm -f $TEMPFILE
42       
43# Delete original ASCII sbet file unless user opted not to (don't need it any more)
44if [ ! $NODELETEFILE ] ; then
45        rm -f $1
46fi