Skip to main content

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. read_interval accepts both dialects from the AGI spec: quoted ISO-YMD or UTCG dates, and epoch-seconds files with a ScenarioEpoch header.

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

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-1.0.0.tar.gz (94.3 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-1.0.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stk_files-1.0.0.tar.gz
  • Upload date:
  • Size: 94.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a9a119147666740f3d15d7ab21b7bea2bc97b5ab56a822330a0cf50d864a20c9
MD5 a8ae5f940e8b9444f41ad3bda5c807da
BLAKE2b-256 864812280d49b701c2821a1ec4a7e911429af6da4d1f122a0df1130d91c6e1b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stk_files-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f62644bad518ed4a5ed5fef6057b05ccf9571ba491bce38ff2161e6c64221064
MD5 a7ee1b0089c0be33c8faa4c428cf3122
BLAKE2b-256 52491118e06fd356011a5aad9ce645be50493a85abb79ba354a70b2be14fa435

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page