Skip to content

Support Muxed Non-CCSDS Packets in create_dataset #187

@medley56

Description

@medley56

Summary

Currently, create_dataset uses APID in a pretty hard-coded way to assign dict keys to the dictionary that is returned by create_dataset such that the key is APID and the value is an xarray Dataset containing all the packets for that APID. For non-CCSDS packets, we just force the APID to be 0, which implicitly requires all packets to be the same (so they can be represented in an array-shaped Dataset object).

It would be cool if we could allow create_dataset to create those dict keys based off of a custom attribute of a parsed packet object.

Implementation Suggestion

This is how we make the dict key for the output dict currently:

# Try to get APID from CCSDS packets, default to 0 for non-CCSDS packets
try:
    apid = packet.binary_data.apid
except AttributeError:
    apid = 0

This is a little clunky because for non-CCSDS packets, you always get a dict with a single key that is 0, i.e. {0: xarray.Dataset(...)}

We could accept an optional kwarg to create_dataset called packet_type_key. If it's None, then we assume all packets are the same type and use key 0 (maybe this could also be improved). If it's a string, we assume that string is a parameter name in your packet definition that uniquely maps to a packet type (just like an APID does for CCSDS packets) and thus can be used as a key in the output dict to separate packet types which likely require different representations in a Dataset.

The result would be something like:

if packet_type_key:
    # If you pass a packet_type_key that is not present in the packet, you get an exception here
    dict_key = packet[packet_type_key]
else:
    # Try to get APID from CCSDS packets, default to 0 for non-CCSDS packets with no explicit key given
    try:
        apid = packet.binary_data.apid
    except AttributeError:
        apid = 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions