Skip to main content

Generate STK external data files

Project description

stk-files

Python library and CLI for generating and reading STK external data files.

Supports attitude (.a), ephemeris (.e), sensor pointing (.sp), and interval list (.int) file formats.

Installation

pip install stk-files

Optional DataFrame support:

pip install stk-files[pandas]
pip install stk-files[polars]

Quick start

Write an ephemeris file

import numpy as np
from stk_files import EphemerisConfig, write_ephemeris

times = np.array(["2024-01-01T00:00:00", "2024-01-01T00:01:00"], dtype="datetime64[ms]")
data = np.array([
    [7000.0, 0.0, 0.0, 0.0, 7.5, 0.0],
    [6999.0, 100.0, 0.0, -0.1, 7.5, 0.0],
])

config = EphemerisConfig(format="TimePosVel", coordinate_system="ICRF")

with open("satellite.e", "w") as f:
    write_ephemeris(f, config, times, data)

Write an attitude file

import numpy as np
from stk_files import AttitudeConfig, write_attitude

times = np.array(["2024-01-01T00:00:00", "2024-01-01T00:01:00"], dtype="datetime64[ms]")
quats = np.array([
    [0.0, 0.0, 0.0, 1.0],
    [0.0, 0.0, 0.1, 0.995],
])

config = AttitudeConfig(format="Quaternions")

with open("satellite.a", "w") as f:
    write_attitude(f, config, times, quats)

Read a file back

from stk_files import read_ephemeris

with open("satellite.e") as f:
    config, times, data = read_ephemeris(f)

read_attitude, read_sensor, and read_interval work the same way.

Streaming writes

For large datasets that don't fit in memory, use the chunked writer context managers:

from stk_files import EphemerisConfig, ephemeris_writer

config = EphemerisConfig(format="TimePosVel")

with open("satellite.e", "w") as f, ephemeris_writer(f, config) as writer:
    for times_chunk, data_chunk in data_source:
        writer.write_chunk(times_chunk, data_chunk)

Interval lists

import numpy as np
from stk_files import Interval, write_interval

intervals = [
    Interval(
        start=np.datetime64("2024-01-01T00:00:00", "ms"),
        end=np.datetime64("2024-01-01T01:00:00", "ms"),
    ),
]

with open("access.int", "w") as f:
    write_interval(f, intervals)

Availability detection

Detect contiguous data spans and write them as an interval file:

import numpy as np
from stk_files import detect_availability, write_availability

spans = detect_availability(times, max_gap=np.timedelta64(60, "s"))

with open("availability.int", "w") as f:
    write_availability(f, times, max_gap=np.timedelta64(60, "s"))

Pandas and Polars

Pass DataFrame columns directly -- they are coerced to numpy automatically:

import pandas as pd
from stk_files import EphemerisConfig, write_ephemeris

df = pd.read_csv("orbit.csv", parse_dates=["time"])
config = EphemerisConfig(format="TimePosVel")

with open("satellite.e", "w") as f:
    write_ephemeris(f, config, df["time"], df[["x", "y", "z", "vx", "vy", "vz"]])

Validation

Data is validated before writing. Use strict=True to raise on invalid rows, or leave the default (strict=False) to silently filter them:

# Raises ValueError on non-unit quaternions
write_attitude(f, config, times, quats, strict=True)

# Filters out non-unit quaternions and continues
write_attitude(f, config, times, quats, strict=False)

Set max_rate to flag excessive angular/position rates:

write_attitude(f, config, times, quats, max_rate=10.0)

CLI

The stk-files CLI reads whitespace-delimited data from stdin.

# Ephemeris
cat orbit.txt | stk-files ephemeris TimePosVel -o satellite.e

# Attitude quaternions
cat attitude.txt | stk-files attitude Quaternions -o satellite.a --axes ICRF

# Sensor pointing
cat pointing.txt | stk-files sensor AzElAngles -o sensor.sp -s 323

# Interval list
cat intervals.txt | stk-files interval -o access.int

Use stk-files --help or stk-files <command> --help for full option details.

Documentation

Supported formats

Attitude (AttitudeFormat): Quaternions, QuatScalarFirst, EulerAngles, YPRAngles, DCM, ECFVector, ECIVector

Ephemeris (EphemerisFormat): TimePos, TimePosVel, TimePosVelAcc, LLATimePos, LLATimePosVel

Sensor (SensorFormat): All attitude formats plus AzElAngles

License

MIT

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

stk_files-0.0.2.tar.gz (103.1 kB view details)

Uploaded Source

Built Distribution

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

stk_files-0.0.2-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file stk_files-0.0.2.tar.gz.

File metadata

  • Download URL: stk_files-0.0.2.tar.gz
  • Upload date:
  • Size: 103.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stk_files-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5ecd45e1f017ed0da52e3a499affa7b981e6173f9c66be8f87be110853c42f77
MD5 7820e896e9c8538c2fd8dc82095a37a6
BLAKE2b-256 6dac778b1bd3e353759a35d530dba0ce3327d92ca17a2673f300717ddb4c1ffe

See more details on using hashes here.

File details

Details for the file stk_files-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: stk_files-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stk_files-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d83aebeb7b2e0dafca9768c86a2105b6f9655f4a1e677df8261433a47789459
MD5 813aa32863acb665de4679853a695965
BLAKE2b-256 f7a63cf696385701794dd3746fca2c9a0f11160889ded9a5c19f6e4f3fa36994

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