libera_utils.l1a.packet_slicing.select_packets#
- libera_utils.l1a.packet_slicing.select_packets(dataset: Dataset, keep_packets: slice | ndarray) Dataset#
Subset a decoded L1A Dataset along
PACKET, carrying its sample axes along.Every sample of a selected packet is kept and every sample of an unselected packet is dropped, so whole packets survive. Each
*_packet_indexvariable, andCAMERA_PACKET_INDEX, is renumbered from 0 against the surviving packet axis. ACAMERA_TIMErow survives when its SOP packet does; keeping an image’s other packets is the caller’s job, asslice_l1a_dataset_to_time_window()does.PACKET_IMAGE_IDis renumbered from 0 against the survivingCAMERA_TIMEaxis; a kept packet whose image row was dropped gets-1.Packet order is preserved; an unordered integer indexer is sorted rather than applied as a reordering.
- Parameters:
dataset (xr.Dataset) – Decoded L1A Dataset with a
PACKETdimension.keep_packets (slice or np.ndarray) – Packets to keep, as a
slice, a boolean mask overPACKET, or an integer array of packet indices.
- Returns:
Subset Dataset. May be empty along
PACKETif nothing was selected; callers decide whether that is an error.- Return type:
xr.Dataset
- Raises:
ValueError – If
datasethas noPACKETdimension, or if a sample axis cannot be mapped back to the packet axis.