libera_utils.l1a.l1a_packet_configs.PacketConfiguration#

class libera_utils.l1a.l1a_packet_configs.PacketConfiguration(*, packet_apid: LiberaApid, packet_time_fields: TimeFieldMapping, day_coverage: DayCoveragePolicy, sample_groups: list[SampleGroup] = <factory>, aggregation_groups: list[AggregationGroup] = <factory>, array_groups: list[ArrayGroup] = <factory>, packet_definition_config_key: str = 'LIBERA_PACKET_DEFINITION', packet_time_source: SampleTimeSource = SampleTimeSource.ICIE)#

Bases: BaseModel

Base class for packet configurations.

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.

Configurations are loaded from YAML and cached for performance.

Variables:
  • packet_apid (LiberaApid) – The APID (Application Process Identifier) for the packet type

  • packet_time_fields (TimeFieldMapping) – Mapping of packet timestamp fields to their time units for multipart_to_dt64 conversion.

  • sample_groups (list[SampleGroup]) – List of sample group configurations for this packet type.

  • aggregation_groups (list[AggregationGroup]) – List of aggregation group configurations for this packet type.

  • array_groups (list[ArrayGroup]) – List of array group configurations for this packet type.

  • packet_definition_config_key (str) – Configuration key to fetch the packet definition path from config. Defaults to “LIBERA_PACKET_DEFINITION”.

  • packet_time_source (SampleTimeSource) – The time source for packet timestamps.

  • day_coverage (DayCoveragePolicy) – Completeness rule L1A day assembly applies to one day of this APID.

__init__(**data: Any) → None#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Methods

get_sample_group(name)

Get a sample group by name.

Attributes

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

packet_time_coordinate

Get the packet time coordinate name following the consistent pattern.

classmethod _convert_packet_apid(v: Any) → LiberaApid#

Convert packet_apid from string to LiberaApid enum.

classmethod _convert_packet_time_source(v: Any) → SampleTimeSource#

Convert packet_time_source from string to SampleTimeSource enum.

get_sample_group(name: str) → SampleGroup#

Get a sample group by name.

Parameters:

name (str) – The name of the sample group to retrieve

Returns:

The sample group with the given name

Return type:

SampleGroup

Raises:

KeyError – If no sample group with the given name exists

model_computed_fields = {}#
model_config = {'frozen': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property model_extra: Dict[str, Any] | None#

Get extra fields set during validation.

Returns:

A dictionary of extra fields, or None if config.extra is not set to “allow”.

model_fields = {'aggregation_groups': FieldInfo(annotation=list[AggregationGroup], required=False, default_factory=list), 'array_groups': FieldInfo(annotation=list[ArrayGroup], required=False, default_factory=list), 'day_coverage': FieldInfo(annotation=DayCoveragePolicy, required=True), 'packet_apid': FieldInfo(annotation=LiberaApid, required=True), 'packet_definition_config_key': FieldInfo(annotation=str, required=False, default='LIBERA_PACKET_DEFINITION'), 'packet_time_fields': FieldInfo(annotation=TimeFieldMapping, required=True), 'packet_time_source': FieldInfo(annotation=SampleTimeSource, required=False, default=<SampleTimeSource.ICIE: 'ICIE'>), 'sample_groups': FieldInfo(annotation=list[SampleGroup], required=False, default_factory=list)}#
property model_fields_set: set[str]#

Returns the set of fields that have been explicitly set on this model instance.

Returns:

A set of strings representing the fields that have been set,

i.e. that were not filled from defaults.

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