Skip to main content

Collection of Python tools for working with CCSDS Space Packets

Project description

SPaC-Kit

Lint, test, and release Publish new release

License Contributor Covenant

✨ Introduction

SpaC-Kit is a collection of Python tools for working with CCSDS Space Packets. It can generically:

  • Parse data files into Pandas DataFrames or Excel spreadsheets
  • Generate simulated CCSDS packets with randomized/zero-initialized fields for testing
  • Generate automatic documentation for packets with a Sphinx extension

SpaC-Kit supports mission or instrument-specific CCSDS packet structures via plugin packages built on the CCSDSPy library.

[!IMPORTANT] This library is currently in active development.

Some functions are placeholders and may not yet have full implementations. Expect ongoing updates and new features as the library evolves.

🔌 Available Mission/Instrument Plugins

Users

Requirement

Tested with python 3.12.

Optionally, but recommended, create a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Install

Install your plugin library first, for example Europa-Clipper CCSDS packets definitions:

git clone https://github.com/nasa-jpl/spac-kit-europa-clipper.git
cd spac-kit-europa-clipper
pip install .

Install the SPaC-Kit package:

pip install spac-kit

Use

SPaC-Kit provides three main capabilities for working with CCSDS packets:

1. 📄 Parsing CCSDS Packets (spac-parse)

The spac-parse command parses binary CCSDS packet files and outputs structured data in various formats.

Basic usage:

spac-parse --file {your_ccsds_file}

Output formats:

Export to Excel (default):

spac-parse --file packets.bin --output data.xlsx

Export to CSV:

spac-parse --file packets.bin --format csv --output data.csv

Export to Pandas DataFrame pickle:

spac-parse --file packets.bin --format pickle --output data.pkl

Filtering options:

Parse only specific APID(s):

spac-parse --file packets.bin --apid 100 200 --output filtered.xlsx

Advanced options:

See all available options:

spac-parse --help

Programmatic usage:

from spac_kit.parser import parse_packets

# Parse packets and get DataFrame
df = parse_packets("packets.bin", apids=[100, 200])

# Access parsed data
print(df.head())
print(df["temperature"].mean())

2. 🔧 Generating CCSDS Packets (spac-generate)

The spac-generate command creates simulated CCSDS packets for testing and development.

Basic usage:

Generate packets with random data for all installed packet definitions:

spac-generate --output packets.bin

Data initialization options:

Generate packets with zero-initialized data:

spac-generate --output packets.bin --zeros

Filtering and quantity:

Generate packets for specific APID(s):

spac-generate --output packets.bin --apid 100 200

Generate multiple packets per APID:

spac-generate --output packets.bin --count 10

Listing definitions:

List available packet definitions:

spac-ls

Advanced options:

See all available options:

spac-generate --help

Programmatic usage:

The packet generator creates valid CCSDS packets, useful for testing packet parsing pipelines.

import ccsdspy
from spac_kit.generator import PacketGenerator

# Define packet structure
fields = [
    ccsdspy.PacketField(name="status", data_type="uint", bit_length=8),
    ccsdspy.PacketField(name="temperature", data_type="float", bit_length=32),
]
packet_def = ccsdspy.VariableLength(fields, apid=100, name="SensorPacket")

# Generate packets with random data (default)
generator = PacketGenerator(packet_def)
with open("packets.bin", "wb") as f:
    generator.write_packet(f, count=5)  # Generate 5 packets

# Generate packets with zero-initialized data
with open("zeros.bin", "wb") as f:
    generator.write_packet(f, count=5, use_random=False)

3. 📚 Automatic Documentation (spac-autodocs)

SPaC-Kit includes a Sphinx extension for automatically generating documentation for CCSDS packet definitions.

Setup:

Add to your Sphinx conf.py:

extensions = [
    'spac_kit.sphinx_ext',
    # ... other extensions
]

Usage in documentation:

.. spac-autodocs::
   :apid: 100
   :name: SensorPacket

This will generate formatted documentation including field names, types, bit lengths, and descriptions from your packet definitions.

Developers

Requirements

Python 3.12

Create a virtual environment

SPaC-Kit handles development primarily via Poetry. To setup the repo, run:

poetry env use python3.12
poetry install --with dev

Then prefix your commands with poetry run to use the virtual environment, for example:

poetry run spac-parse --help

Deploy the project, for developers

Clone the repository

Install the package

pre-commit install && pre-commit install -t pre-push

Run an example:

python src/spac_kit/parser/downlink_to_excel.py

or

spac-parse --help

With poetry, update the poetry.lock before commiting and pushing to the github repository:

poetry lock

Build and publish the package

Update the version number in file pyproject.toml

Create a tag in the repository and push the changes.

git tag vX.Y.Z
git push origin main --tags

Locally, you can do the following steps to build and publish the package.

python3 -m pip install --upgrade build
rm -rf dist/
python3 -m build

Publish the project:

pip install twine
twine upload dist/*

Other reference information for developers

  • The package is released following Semantic Versioning.
  • We follow the trunk-based branching strategy since the development team is current reduced and we want to favor efficient of the releases. That mean we don't have a 'develop' branch.
  • The code follows the PEP-8 style guide using black for formatting and flake8 for linting.

Acknowledgments

The work being done here heavily relies on the CCSDSpy library. It has been started as part of the NASA Europa Clipper mission Science Data System development and it is being now funded by a NASA ROSES grant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spac_kit-1.0.1.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spac_kit-1.0.1-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file spac_kit-1.0.1.tar.gz.

File metadata

  • Download URL: spac_kit-1.0.1.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for spac_kit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 02ff97d44941c50af4c4f0a58581950fcf84c77ece33bdc75e2720336b949e62
MD5 0be4de8d5bb541e07a55a5f138b31577
BLAKE2b-256 642d40d5deae87e2578e4d2d78e6e7f7cb9c2c0f895fcbd960320fb2502520d4

See more details on using hashes here.

File details

Details for the file spac_kit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: spac_kit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for spac_kit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 afd700aaca3f6775835d2509b5658b9ed3d74331006864023aff128f39d572ec
MD5 de8e9addab33ddcc2320818aac3f207b
BLAKE2b-256 12362f1ed01f35dcb2a85b61ab609ec62b3fc0abcdec832acefda4665adc2bba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page