libera_utils.l1a.packet_slicing.sample_to_packet_index#
- libera_utils.l1a.packet_slicing.sample_to_packet_index(dataset: Dataset, sample_dim: str) ndarray#
Map every row of
sample_dimto its originating row ofPACKET.Prefers the stored
{sample_group}_packet_indexvariable, which stays correct when duplicate samples have been dropped. ForCAMERA_TIMEthis isCAMERA_PACKET_INDEX, each image’s SOP packet. Falls back to positional arithmetic (sample i -> packet i // samples_per_packet) only when no index variable is present.The mapping is not necessarily monotonically non-decreasing: sample axes are sorted by sample time, so skew between two adjacent packets’ sample clocks interleaves their sample blocks and the mapping steps backwards at those positions. Interleaving is logged, not raised.
- Parameters:
dataset (xr.Dataset) – Decoded L1A Dataset.
sample_dim (str) – Name of the sample dimension.
- Returns:
int64array of lengthdataset.sizes[sample_dim].- Return type:
np.ndarray
- Raises:
ValueError – If a stored packet index is out of range of the
PACKETaxis, which means the packet and sample axes describe different sets of packets.