time_axis
Provides two functions for correcting irregular ADCP timestamps. These are most
conveniently called via ProcessedDataset.apply_time_axis(), but can also be
used directly.
Functions
Function |
Description |
|---|---|
|
Round timestamps to the nearest regular interval |
|
Reindex to a regular grid, inserting NaN ensembles for gaps |
Usage
import pyadps
from pyadps.processing.time_axis import snap_time_axis, fill_time_gaps
ds = pyadps.read('deployment.000')
# Snap drifted timestamps to the nearest hour
ds_snapped, success, msg = snap_time_axis(ds, freq='h', tolerance='5min')
# Fill missing ensembles so the time axis is uniform
ds_filled = fill_time_gaps(ds_snapped, method='auto')
Via ProcessedDataset:
from pyadps.processing import ProcessedDataset
proc = ProcessedDataset(ds)
proc.apply_time_axis(snap=True, snap_freq='h', snap_tolerance='5min',
fill_gaps=True, fill_method='auto')
Non-Obvious Behaviors
snap_time_axis() returns a tuple (dataset, success, message). If any
timestamp requires a correction larger than tolerance, the function aborts and
returns (None, False, message) rather than silently over-correcting.
ds_snapped, success, msg = snap_time_axis(ds, freq='h', tolerance='5min')
if not success:
print(f"Snapping aborted: {msg}")
fill_time_gaps() forward-fills leader variables. Fixed and variable leader
fields (configuration metadata, sensor readings) are propagated from the last
known ensemble into gap-filled slots. Velocity, correlation, and echo data are
filled with RDI missing value codes.
method='auto' in fill_time_gaps() detects the interval from the median
spacing of existing timestamps — no need to specify frequency explicitly if the
data has a consistent sampling rate.