libera_utils.l1a.data_time_extractors.extract_data_time_range#

libera_utils.l1a.data_time_extractors.extract_data_time_range(packet_file: PathLike | str, apid: int, *, skip_header_bytes: int | None = None) → tuple[datetime, datetime] | None#

Extract the min/max science data time span from a single packet file.

Uses XTCE packet parsing only: no sample-field expansion into L1A product form and no WFOV image stitching or NetCDF assembly.

Parameters:
  • packet_file (PathLike | str) – Path to a single-APID PDS or demuxed ground CCSDS packet file.

  • apid (int) – Application Process Identifier.

  • skip_header_bytes (int | None, optional) – Bytes to skip before each CCSDS primary header. When None, uses SKIP_PACKET_HEADER_BYTES from config (default 0, which is correct for flight PDS and for demuxed ground CCSDS).

Returns:

As extract_data_time_range_from_dataset. A None return means the caller should fall back to packet time, not that extraction failed.

Return type:

tuple[datetime, datetime] | None

Raises:
  • DataTimeUndeterminedError – As extract_data_time_range_from_dataset, and additionally if the file holds no packets for apid or cannot be parsed for a reason other than those below.

  • MemoryError – If memory runs out while the file is read or parsed. It is not wrapped.

  • OSError – If reading the file, including downloading a cloud file to the local cache, fails with ENOSPC, EDQUOT, EMFILE or ENFILE (see libera_utils.io.smart_open.is_resource_exhaustion). It is not wrapped.