libera_utils.packet_configs#

Packet configurations for different LIBERA and JPSS packet types.

This module contains PacketConfiguration instances that define how to parse different types of spacecraft and instrument packets into L1A datasets.

Functions

get_packet_config(apid)

Get a PacketConfiguration instance by LiberaApid.

register_packet_config(cls)

Class decorator to register a PacketConfiguration subclass.

Classes

AggregationGroup(name, field_pattern, ...)

Configuration for aggregating multiple sequential fields into a single binary blob.

AxisPacketConfig(packet_apid, ...)

Configuration for ICIE Axis Sample packets.

CriticalHkPacketConfig(packet_apid, ...)

Configuration for ICIE Critical Housekeeping packets.

NominalHkPacketConfig(packet_apid, ...)

Configuration for ICIE Nominal Housekeeping packets.

PacketConfiguration(packet_apid, ...)

Abstract base class for packet configurations.

RadSamplePacketConfig(packet_apid, ...)

Configuration for ICIE Radiometer Sample packets.

SampleGroup(name, sample_count, ...[, ...])

Configuration for a group of samples within a packet.

SampleTimeSource(value)

Enumeration for sample timestamp sources.

ScPosPacketConfig(packet_apid, ...)

Configuration for JPSS Spacecraft Position packets.

TempHkPacketConfig(packet_apid, ...)

Configuration for ICIE Temperature Housekeeping packets.

TimeFieldMapping([day_field, s_field, ...])

Mapping of time field names to their roles in multipart timestamp conversion.

WfovSciPacketConfig(packet_apid, ...)

Configuration for ICIE WFOV Science packets.

class libera_utils.packet_configs.AggregationGroup(name: str, field_pattern: str, field_count: int, dtype: ~numpy.dtype = <factory>)#

Configuration for aggregating multiple sequential fields into a single binary blob.

This class defines how to combine multiple numbered fields (e.g., ICIE__WFOV_DATA_0 through ICIE__WFOV_DATA_971) into a single bytes object per packet.

name#

Name for the aggregated variable (e.g., “ICIE__WFOV_DATA”)

Type:

str

field_pattern#

Pattern with %i placeholder for field index (e.g., “ICIE__WFOV_DATA_%i”)

Type:

str

field_count#

Expected number of fields to aggregate (e.g., 972)

Type:

int

dtype#

Resulting numpy dtype for the aggregated data (e.g., np.dtype(’|S972’))

Type:

np.dtype

class libera_utils.packet_configs.AxisPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_axis_sample, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE Axis Sample packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.CriticalHkPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_crit_hk, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE Critical Housekeeping packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.NominalHkPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_nom_hk, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE Nominal Housekeeping packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.PacketConfiguration(packet_apid: ~libera_utils.constants.LiberaApid, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Abstract base class for packet configurations.

All packet configurations must subclass this and will be automatically registered when decorated with @register_packet_config.

This class defines how to parse packets that may contain multiple groups of samples with their own timestamps, allowing for proper expansion and reshaping of the data.

packet_apid#

The APID (Application Process Identifier) for the packet type

Type:

LiberaApid

packet_time_fields#

Mapping of packet timestamp fields to their time units for multipart_to_dt64 conversion.

Type:

TimeFieldMapping

sample_groups#

List of sample group configurations for this packet type.

Type:

list[SampleGroup]

aggregation_groups#

List of aggregation group configurations for this packet type.

Type:

list[AggregationGroup]

packet_definition_config_key#

Configuration key to fetch the packet definition path from config. Defaults to “LIBERA_PACKET_DEFINITION”.

Type:

str

packet_time_source#

The time source for packet timestamps.

Type:

SampleTimeSource

packet_generator_kwargs#

Additional keyword arguments passed to the packet generator in space_packet_parser. Default is no additional kwargs.

Type:

dict

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

get_sample_group(name: str) SampleGroup#

Get a sample group by name

property packet_time_coordinate: str#

Get the packet time coordinate name following the consistent pattern.

Returns:

The packet coordinate name, e.g. “PACKET_ICIE_TIME”

Return type:

str

class libera_utils.packet_configs.RadSamplePacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_rad_sample, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE Radiometer Sample packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.SampleGroup(name: str, sample_count: int, data_field_patterns: list[str], time_source: SampleTimeSource, time_field_patterns: TimeFieldMapping | None = None, epoch_time_fields: TimeFieldMapping | None = None, sample_period: timedelta | None = None)#

Configuration for a group of samples within a packet.

This class defines how to parse a specific group of related samples that share timing characteristics within a packet.

name#

Name of the sample group (e.g., “AXIS_SAMPLE”, “RAD_SAMPLE”, “ADGPS”). This is used to name coordinates and dimensions.

Type:

str

time_fields#

Mapping of time field patterns to their units for explicit per-sample timestamps. Use %i as placeholder for sample index in the field names.

Type:

TimeFieldMapping | None

epoch_time_fields#

Mapping of time fields to units for a single epoch timestamp. Used with sample_period to calculate sample times.

Type:

TimeFieldMapping | None

sample_period#

Fixed time period between samples, used with epoch_time_fields.

Type:

timedelta | None

data_field_patterns#

List of data field name patterns. Use %i for sample index if multiple samples.

Type:

list[str]

sample_count#

Number of samples per packet for this sample group.

Type:

int

time_source#

The source system for timestamps (e.g. ICIE, FPE, or SC).

Type:

SampleTimeSource

Attributes:
epoch_time_fields
sample_data_fields

Return the data field patterns with any %i placeholders removed (i.e.

sample_period
sample_time_dimension

Get the dimension name for this sample group.

time_field_patterns
property sample_data_fields: list[str]#

Return the data field patterns with any %i placeholders removed (i.e. convert patterns to clean field names)

For example, ICIE__AXIS_EL_FILT%i becomes ICIE__AXIS_EL_FILT

property sample_time_dimension: str#

Get the dimension name for this sample group.

Returns:

The dimension name, e.g. “AXIS_SAMPLE_ICIE_TIME”

Return type:

str

class libera_utils.packet_configs.SampleTimeSource(value)#

Enumeration for sample timestamp sources.

Methods

capitalize(/)

Return a capitalized version of the string.

casefold(/)

Return a version of the string suitable for caseless comparisons.

center(width[, fillchar])

Return a centered string of length width.

count(sub[, start[, end]])

Return the number of non-overlapping occurrences of substring sub in string S[start:end].

encode(/[, encoding, errors])

Encode the string using the codec registered for encoding.

endswith(suffix[, start[, end]])

Return True if S ends with the specified suffix, False otherwise.

expandtabs(/[, tabsize])

Return a copy where all tab characters are expanded using spaces.

find(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

format(*args, **kwargs)

Return a formatted version of S, using substitutions from args and kwargs.

format_map(mapping)

Return a formatted version of S, using substitutions from mapping.

index(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

isalnum(/)

Return True if the string is an alpha-numeric string, False otherwise.

isalpha(/)

Return True if the string is an alphabetic string, False otherwise.

isascii(/)

Return True if all characters in the string are ASCII, False otherwise.

isdecimal(/)

Return True if the string is a decimal string, False otherwise.

isdigit(/)

Return True if the string is a digit string, False otherwise.

isidentifier(/)

Return True if the string is a valid Python identifier, False otherwise.

islower(/)

Return True if the string is a lowercase string, False otherwise.

isnumeric(/)

Return True if the string is a numeric string, False otherwise.

isprintable(/)

Return True if the string is printable, False otherwise.

isspace(/)

Return True if the string is a whitespace string, False otherwise.

istitle(/)

Return True if the string is a title-cased string, False otherwise.

isupper(/)

Return True if the string is an uppercase string, False otherwise.

join(iterable, /)

Concatenate any number of strings.

ljust(width[, fillchar])

Return a left-justified string of length width.

lower(/)

Return a copy of the string converted to lowercase.

lstrip([chars])

Return a copy of the string with leading whitespace removed.

maketrans(x[, y, z])

Return a translation table usable for str.translate().

partition(sep, /)

Partition the string into three parts using the given separator.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

replace(old, new[, count])

Return a copy with all occurrences of substring old replaced by new.

rfind(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rindex(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rjust(width[, fillchar])

Return a right-justified string of length width.

rpartition(sep, /)

Partition the string into three parts using the given separator.

rsplit(/[, sep, maxsplit])

Return a list of the substrings in the string, using sep as the separator string.

rstrip([chars])

Return a copy of the string with trailing whitespace removed.

split(/[, sep, maxsplit])

Return a list of the substrings in the string, using sep as the separator string.

splitlines(/[, keepends])

Return a list of the lines in the string, breaking at line boundaries.

startswith(prefix[, start[, end]])

Return True if S starts with the specified prefix, False otherwise.

strip([chars])

Return a copy of the string with leading and trailing whitespace removed.

swapcase(/)

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title(/)

Return a version of the string where each word is titlecased.

translate(table, /)

Replace each character in the string using the given translation table.

upper(/)

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

class libera_utils.packet_configs.ScPosPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.jpss_sc_pos, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'JPSS_GEOLOCATION_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.JPSS, packet_generator_kwargs: dict = <factory>)#

Configuration for JPSS Spacecraft Position packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.TempHkPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_temp_hk, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE Temperature Housekeeping packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

class libera_utils.packet_configs.TimeFieldMapping(day_field: str | None = None, s_field: str | None = None, ms_field: str | None = None, us_field: str | None = None)#

Mapping of time field names to their roles in multipart timestamp conversion.

This class defines which packet fields correspond to different time units (days, seconds, milliseconds, microseconds) and provides a property to generate the appropriate kwargs for the multipart_to_dt64 function.

Attributes:
day_field
ms_field
multipart_kwargs

Return kwargs dict for multipart_to_dt64 function.

s_field
us_field
property multipart_kwargs: dict[str, str]#

Return kwargs dict for multipart_to_dt64 function.

Returns:

Dictionary with field parameter names as keys and field names as values, excluding any None values.

Return type:

dict[str, str]

class libera_utils.packet_configs.WfovSciPacketConfig(packet_apid: ~libera_utils.constants.LiberaApid = LiberaApid.icie_wfov_sci, packet_time_fields: ~libera_utils.packet_configs.TimeFieldMapping = <factory>, sample_groups: list[~libera_utils.packet_configs.SampleGroup] = <factory>, aggregation_groups: list[~libera_utils.packet_configs.AggregationGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: ~libera_utils.packet_configs.SampleTimeSource = SampleTimeSource.ICIE, packet_generator_kwargs: dict = <factory>)#

Configuration for ICIE WFOV Science packets.

Attributes:
packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

Methods

get_sample_group(name)

Get a sample group by name

libera_utils.packet_configs.get_packet_config(apid: LiberaApid) PacketConfiguration#

Get a PacketConfiguration instance by LiberaApid.

Parameters:

apid (LiberaApid) – The APID to look up the configuration for

Returns:

The configuration for the given APID

Return type:

PacketConfiguration

Raises:

KeyError – If no configuration is registered for the given APID

libera_utils.packet_configs.register_packet_config(cls: type[PacketConfiguration]) type[PacketConfiguration]#

Class decorator to register a PacketConfiguration subclass.

Instantiates the class and registers it in the global registry.

Parameters:

cls (type[PacketConfiguration]) – The PacketConfiguration subclass to register

Returns:

The same class (unchanged)

Return type:

type[PacketConfiguration]

Raises:

ValueError – If a configuration with the same APID is already registered