filtnav
Description
filtnav filters a binary 48-byte OMG navigation file (jcu_nav_rec, .nav) and writes the cleaned output to <filename>.filtered.
It operates in one of two modes:
-
Outlier Rejection & Packing Mode (default): Iteratively removes flagged records ( packem), then scans consecutive fixes (checkem) to flag and reject duplicate positions, large time jumps ($\Delta t > 15\text{ s}$), negative time jumps, and excessive vessel speeds ($> 10\text{ m/s}$, ~19.4 knots). By default it runs 1pass, orNpasses if-times <N>is specified. - Moving-Window Smoothing Mode (
-smooth): Applies a $\pm 5$-record moving average (flen = 5, including neighbors within 10 seconds of the center fix) tolatandlon, and recomputes vesselvelocity(m/s) andazi(degrees $0^\circ..360^\circ$) from the smoothed track.
Usage
filtnav [OPTIONS] <filename.nav>
Common Workflow Examples
1. Filter out duplicate fixes, time jumps, and speed spikes (3 iterative passes):
filtnav -times 3 raw_line01.nav
# Writes raw_line01.nav.filtered
2. Smooth positions over a $\pm 5$-fix window and recompute course and speed:
filtnav -smooth raw_line01.nav
# Writes raw_line01.nav.filtered
Arguments
| Option | Description | Default | Â | Â |
|---|---|---|---|---|
<filename> | Required. Input binary .nav file (jcu_nav_rec format). Output is automatically written to <filename>.filtered. | None | Â | Â |
-times <N> | Number of iterative pack-and-check rejection passes to execute in default outlier-rejection mode. Note: because checkem() flags bad fixes after packem() compacts unflagged fixes, running -times 2 (or higher) is necessary to physically remove records newly flagged during pass 1. | 1 | Â | Â |
-smooth | Run smoothnav() instead of packem()/checkem(): smooths lat and lon over a $\pm 5$-record window (for neighbors with $ | \Delta t | < 10\text{ s}$) and updates azi (degrees) and velocity (m/s). | Disabled (outlier rejection mode) |
-v | Enable verbose output (prints pre-smoothed velocity and heading in -smooth mode). | Disabled | Â | Â |
Rejection Criteria (Default Mode)
In each pass j of 0 .. times - 1, filtnav first compacts the array by discarding any record with flag[3] != 0 (packem), and then evaluates every adjacent pair (Record[i], Record[i+1]) in checkem():
| Condition | Threshold | Action Taken |
|---|---|---|
| Duplicate Position | Record[i+1].lat == Record[i].lat && Record[i+1].lon == Record[i].lon | Prints identical fix and sets Record[i+1].flag[3] = 1. |
| Large Time Gap | fabs(dtime) > 15 seconds | Sets Record[i+1].flag[3] = 1. |
| Speed Spike | speed > 10 m/s (where dy = dlat * 60 * 1853, dx = dlon * 60 * 1853 * cos(lat)) | Prints <i > speed flag <speed> and sets both Record[i].flag[3] = 1 and Record[i+1].flag[3] = 1. |
Whenever a fix pair is rejected, checkem() prints the inter-fix time step, distance, speed, and full record dumps (nav_show) for Record[i] and Record[i+1].
[!TIP] Because
packem()is called beforecheckem()inside thefor (j = 0; j < times; j++)loop, a single pass (-times 1) flags bad records (flag[3] = 1) in the output.filteredfile without removing them from the record array. Pass-times 2(or more) if you want the flagged records physically stripped from<filename>.filtered, or use-goodonlyinappendNav.
How It Works
- Opens
<filename>for reading and<filename>.filteredfor writing. - Computes
length = ftell(glofile) / JCU_BINNAV_RECLEN(48 bytes), allocatesRecord[]in memory, and reads all records vianav_read(). - If
-smoothis NOT set: Runstimesiterations ofupto = packem(length)followed bycheckem(upto, 1). - If
-smoothIS set: Loops from indexi = 5tolength - 5, averageslatandlonacross neighbors $j \in [-5, 4]$ whose timestamp is within $10\text{ s}$ ofRecord[i].time, computes smoothed azimuth (getazi) and speed (dist / dtime), and stores them inRecord[i].aziandRecord[i].velocity. - Writes the resulting
lengthrecords to<filename>.filteredvianav_write().