coerce_increasing_time

coerce_increasing_time#

echopype.qc.coerce_increasing_time(ds: Dataset, time_name: str = 'ping_time', win_len: int = 100) None#

Coerce a time coordinate so that it always flows forward. If coercion is necessary, the input ds will be directly modified.

Parameters:
dsxr.Dataset

a dataset for which the time coordinate needs to be corrected

time_namestr

name of the time coordinate to be corrected

win_lenint

length of the local window before the reversed timestamp within which the median pinging interval is used to infer the next ping time

Returns:
the input dataset but with specified time coordinate coerced to flow forward

Notes

This is to correct for problems sometimes observed in EK60/80 data where a time coordinate (ping_time or time1) would suddenly go backward for one ping, but then the rest of the pinging interval would remain undisturbed.

Examples

>>> import xarray as xr
>>> from echopype.qc.api import exist_reversed_time, coerce_increasing_time
>>> ds = xr.open_dataset("my_dataset.nc")
>>> if exist_reversed_time(ds, "ping_time"):  # check for reversed time
...     coerce_increasing_time(ds, "ping_time")  # correct the time coordinate in place