libera_utils.l1a.wfov_image_metadata.enhance_wfov_l1a_dataset#
- libera_utils.l1a.wfov_image_metadata.enhance_wfov_l1a_dataset(packet_ds: Dataset) Dataset#
Stitch complete WFOV images, drop raw packet payloads, and attach CAMERA_TIME metadata.
Raises if no image completes, before dropping anything, so a granule that produces nothing keeps its raw payload for diagnosis instead of being silently emptied.
ICIE__WFOV_DATAis dropped from the returned dataset entirely, for every packet regardless of completeness: content folded into a complete image is already duplicated (compressed) onCAMERA_TIMEasWFOV_COMPRESSED_IMAGE, and content that never completed an image (edge truncation or a mid-stream anomaly) cannot be assembled from this granule alone — the raise above guarantees at least one image did complete before any payload is discarded, andPacketCountNotUsedInImagesplusPACKET_IMAGE_ID == -1record what was dropped.PACKET_IMAGE_IDremains the only per-packet trace-back to a stitched image (-1if none). Dropping the whole variable, rather than zeroing it row by row, avoids a second full-size copy of the ~GB-scale raw array: zeroing in place would corrupt the caller’s dataset, sincecopy(deep=False)shares the buffer. Note thatdrop_varshere does not itself free that buffer —parse_packets_to_l1a_datasetstill holds the originalpacket_dsacross this call, so the array survives until the caller rebinds on return.- Parameters:
packet_ds (xarray.Dataset) – APID 1040 packet-level L1A dataset containing mem-dump flag/offset/length fields and
ICIE__WFOV_DATA.- Returns:
Input dataset merged with
CAMERA_TIMEmetadata,PACKET_IMAGE_ID, and file-level stitch quality attributes;ICIE__WFOV_DATAis absent.- Return type:
- Raises:
ValueError – If required WFOV packet variables are missing from
packet_ds, or if no complete image could be stitched from the packet stream. In the latter casepacket_dsis left untouched, so the caller still holds the raw payloads.