smoothTime
Description
smoothTime is a utility designed to apply a simple moving average filter to the timeOffset field within the profile headers of OMG-HDCS merged files. The goal is to smooth out any “jerky” or noisy time stamps, which can improve the accuracy of subsequent navigation interpolation or other time-sensitive processing.
The tool calculates an average timeOffset over a specified window (noav) of profiles and updates the central profile’s timeOffset with this averaged value.
Usage
smoothTime <OMG_HDCS_datafile(s)> [-noav <value>] [-v]
Arguments
| Option | Description | |
|---|---|---|
<OMG_HDCS_datafile(s)> | Required. One or more paths to OMG-HDCS merged files to be processed. These files are modified in place. | |
-noav <value> | Specifies the number of profiles (window size) to use for the moving average. It should be an odd number to have a clear center. | 3 |
-v | Enable verbose output. |
How It Works
- File Processing: The tool iterates through each specified merged file.
- Summary Header Reading: Reads the summary header to get
summary.numProfilesandsummary.timeScale. - Time Offset Extraction:
- Allocates memory for two double arrays:
timeOffset(to store originalprofile.timeOffsetvalues) andlow_timeOffset(for smoothed values). - Iterates through all profiles in the merged file, extracting and storing each
profile.timeOffsetinto thetimeOffsetarray.
- Allocates memory for two double arrays:
- Moving Average Smoothing:
- Copies the
timeOffsetarray tolow_timeOffset. - Iterates through profiles from
filtlentosummary.numProfiles - filtlen - 1(the range where a full window is available). - For each profile
i, it calculates the average oftimeOffsetvalues within the window[i - filtlen, i + filtlen - 1]. - This average is then stored in
low_timeOffset[i]. - The
Tshift(rescaled) is added tolow_timeOffset[i].
- Copies the
- Writing Changes:
- If
-testis not used, the tool iterates through all profiles again. - For each profile
i, it reads the original profile, updates itsprofile.timeOffsetwith the (integer cast of)low_timeOffset[i], and writes the modified profile back to the merged file.
- If
- Cleanup: Closes files and frees dynamically allocated memory.
Output Files
The input merged files are modified in-place.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.support.h: For general utility functions and error handling.
Notes
Smoothing timestamps can be beneficial for data from systems with imprecise time registration or for integrating data from multiple asynchronous sensors. The filter helps to remove high-frequency jitter while preserving the overall temporal trend. The tool modifies merged files in place, so backups are recommended. The -test option allows for previewing results before committing changes.