bunravel
Description
bunravel (Bash Unravel, authored by Jonathan Beaudoin) is the standard automated batch-processing script for legacy Kongsberg Maritime .all and .wcd multibeam files. It orchestrates RTlite, dumpFlags, mergeAtt, mergeNav, getBounds, makess, deTVG, and moveOverWCinfo across local raw/ subdirectories or via incremental rsync from a shipboard logging directory.
A key feature of bunravel is its .rawfilesize tracking mechanism: for every .all file converted, it records the byte size of the .all file in merged/<subdir>/<prefix>.rawfilesize. On subsequent runs, if a .merged file already exists and its .rawfilesize matches the current .all file size, bunravel automatically skips the file (unless -F is passed). If the .all file was still being logged by SIS during the previous run and has since grown in size, bunravel detects the size mismatch and automatically re-unravels it while preserving any swathed cleaning flags via dumpFlags!
Usage
bunravel [OPTIONS] -f "raw/subdir/*.all"
# OR rsync from a remote/mounted logging directory:
bunravel [OPTIONS] -r /mnt/sis_logging/ -l raw/
Common Examples
1. Unravel all .all files in raw/JD100/ with deTVG backscatter (-d -s 4) and water column (-w):
bunravel -v -w -d -s 4 -f "raw/JD100/*.all"
2. Force re-unraveling of specific files (-F) and open each line in swathed (-i):
bunravel -F -i -f "raw/JD100/0001_*.all"
Arguments
| Option | Description | Default |
|---|---|---|
-f "<files>" | Specify local .all file(s) to process (quote wildcards so bunravel or the shell expands them properly). | Required (unless -r is used) |
-r <remote_dir> | Rsync new .all files (excluding 9999.all active logging file) from <remote_dir> into <local_dir> (raw/ by default) and unravel any new or grown files. | Disabled |
-l <local_dir> | Local directory to rsync into when -r is used. | raw/ |
-F | Force re-conversion of all specified .all files even if <prefix>.merged already exists and .rawfilesize has not changed. | Skip already-unravelled files (0) |
-w | Unpack water column data (-unpack_watercol in RTlite). Also checks for a companion .wcd file, unpacks it to WCD_<prefix>.merged, transfers water column pointers via moveOverWCinfo -tol 0.002, and renames WCD_<prefix>.watercol to <prefix>.watercol. | Disabled (0) |
-d | Run deTVG on <prefix>.merged and generate a second un-normalized sidescan file ss/<subdir>/<prefix>.ss_detvg via makess -use_deTVG. | Disabled (0) |
-s <shift> | Digitizer sample shift (-digitizer_sample_shift <shift>) passed to deTVG when -d is active. | 0 |
-i | Interactive inspection mode: launches swathed on <prefix>.merged right after getBounds and waits for the user to close swathed before generating sidescan and moving to the next file. | Disabled (0) |
-v | Verbose mode: prints parsed RAWDIR, SUBDIRS, OUTFILE_PREFIX, and SUFFIX for each file. | Disabled (0) |
-h | Show usage help message. | Â |
Step-by-Step Pipeline Executed by bunravel
For each <FILE> (raw/<SUBDIRS>/<OUTFILE_PREFIX>.all):
- Incremental Check: Compares
stat -f '%z' $FILEagainstmerged/$SUBDIRS/$OUTFILE_PREFIX.rawfilesize. Skips if.mergedexists, size is unchanged, and-Fis not set. - Save Existing Flags: If
.mergedalready exists, runsdumpFlags merged/$SUBDIRS/$OUTFILE_PREFIXto back up manualswathededits to.flag_bk. -
Unpack
.allviaRTlite:RTlite [-unpack_watercol] -v4 -float_twtt \ -auto_write_primary_nav -auto_write_primary_orientation -rescale_BSN \ -infile $FILE -outprefix merged/$SUBDIRS/$OUTFILE_PREFIX(Note:
-auto_write_primary_navand-auto_write_primary_orientationautomatically create.navand.orientationfor.allfiles, unlikeread_kmallwhich requires manualcpof.nav_1and.net_att_2.) - Restore Flags: If
.flag_bkexists, runsdumpFlags -load merged/$SUBDIRS/$OUTFILE_PREFIX. -
Merge Attitude & Navigation:
mergeAtt merged/$SUBDIRS/$OUTFILE_PREFIX mergeNav merged/$SUBDIRS/$OUTFILE_PREFIX.merged - Build Spatial Index: Runs
getBounds merged/$SUBDIRS/$OUTFILE_PREFIX.merged. - Optional Interactive Editing (
-i): Runsswathed merged/$SUBDIRS/$OUTFILE_PREFIX.merged. -
Generate Sidescan (
.ssand optional.ss_detvg):makess merged/$SUBDIRS/$OUTFILE_PREFIX.merged ss/$SUBDIRS/$OUTFILE_PREFIX.ss # If -d is specified: deTVG -digitizer_sample_shift $DETVG_SHIFT -in merged/$SUBDIRS/$OUTFILE_PREFIX.merged makess -use_deTVG merged/$SUBDIRS/$OUTFILE_PREFIX.merged ss/$SUBDIRS/$OUTFILE_PREFIX.ss_detvg -
Optional Companion
.wcdProcessing (-w): Ifraw/$SUBDIRS/$OUTFILE_PREFIX.wcdexists:RTlite -v4 -rescale_BSN -fix_wc_time -unpack_watercol \ -prefix $RAWDIR/$SUBDIRS/ -suffix .wcd -line $OUTFILE_PREFIX -out merged/$SUBDIRS/WCD_ moveOverWCinfo -tol 0.002 merged/$SUBDIRS/$OUTFILE_PREFIX.merged merged/$SUBDIRS/WCD_$OUTFILE_PREFIX.merged mv merged/$SUBDIRS/WCD_$OUTFILE_PREFIX.watercol merged/$SUBDIRS/$OUTFILE_PREFIX.watercol rm merged/$SUBDIRS/WCD_$OUTFILE_PREFIX.*
[!WARNING] Linux vs. macOS
statCompatibility: Line 145 ofbunravelusesstat -f '%z' $FILE(BSD/macOSstatsyntax for file size in bytes). On Linux (GNU coreutils),stat -freports filesystem status rather than file size (stat -c '%s' $FILEis the GNU equivalent). When runningbunravelon Linux, replacestat -f '%z'withstat -c '%s'so.rawfilesizecomparison works properly.