Utilities#

Pure-function helpers with no I/O or state. May be used from any layer.

Time normalization helpers shared across Adapt modules.

adapt.utils.time.from_scan_iso(s)#

Parse a canonical scan-time string (see to_scan_iso) to a UTC datetime.

The inverse of to_scan_iso. Kept here so the scan-time format is defined in exactly one place — both serialization and parsing share _SCAN_ISO_FORMAT.

Return type:

datetime

Parameters:

s (str)

adapt.utils.time.normalize_time_scalar(time_val)#

Normalize xarray/cftime/numpy time representations to a scalar.

adapt.utils.time.to_scan_iso(dt)#

Canonical scan-time string — ordering/display metadata, one format everywhere.

Rows join on scan_id; scan_time orders and labels them. Matches cells_by_scan (track_store _to_iso) so every table’s time strings compare consistently. Whole-second resolution.

Return type:

str

adapt.utils.time.to_scan_unix(dt)#

Machine-readable scan time: UTC epoch seconds for the SAME instant as to_scan_iso.

Whole seconds (sub-second dropped, matching the ISO format) so the string and integer representations are always consistent. Every derived table carries both.

Return type:

int