libera_utils.l1a.packet_slicing#

Subset decoded L1A Datasets along PACKET, carrying sample axes with their packets.

Decoded L1A products carry a PACKET axis holding one row per CCSDS packet and one sample axis per sample group (e.g. RAD_FULL_FPE_TIME) holding the samples expanded out of those packets. Each sample belongs to exactly one packet, recorded in the {sample_group}_packet_index variable written by parse_packets_to_l1a_dataset().

This module is the supported way to subset such a product; subsetting either axis directly leaves the two out of correspondence. The packet axis is the driver:

  • packets are selected first, and every sample of a selected packet is kept while every sample of an unselected packet is dropped, so whole packets survive or none of them does;

  • {sample_group}_packet_index is renumbered from 0 against the surviving packet axis, which keeps it usable as the sample-to-packet validation link in derived products.

The sample axis is stored in sample-time order, which is almost but not exactly packet order: where two adjacent packets’ sample clocks skew by less than a sample interval their sample blocks interleave, and {sample_group}_packet_index steps backwards at those few positions. The index is applied element-wise throughout, so an interleaved run is sliced correctly and logged.

WFOV SCI (APID 1040) carries a CAMERA_TIME axis with one row per stitched image. Each row records its SOP packet in CAMERA_PACKET_INDEX and owns every packet whose PACKET_IMAGE_ID matches that SOP’s, SOP through EOP. CAMERA_PACKET_INDEX is renumbered like a *_packet_index variable, and PACKET_IMAGE_ID is renumbered against the surviving CAMERA_TIME axis, so PACKET_IMAGE_ID[CAMERA_PACKET_INDEX[i]] == i holds after a subset.

slice_l1a_dataset_to_time_window() selects on sample time where sample axes exist and on the packet time coordinate otherwise. Whole packets survive either way, so a selected packet contributes samples on both sides of the window boundary. A packet in no image (PACKET_IMAGE_ID == -1) has no data time and is never selected.

Functions

data_time_axes(dataset)

Return the axes that place a decoded L1A Dataset's packets in time.

find_sample_dims(dataset)

Identify the sample axes of a decoded L1A Dataset.

sample_to_packet_index(dataset, sample_dim)

Map every row of sample_dim to its originating row of PACKET.

select_packets(dataset, keep_packets)

Subset a decoded L1A Dataset along PACKET, carrying its sample axes along.

slice_l1a_dataset_to_time_window(dataset, t0, t1)

Subset a decoded L1A Dataset to the packets covering the time window [t0, t1].