lunaspace
The Python client of Luna Space's orbit determination service: its public API without the plumbing. Your key, the errors, the queued jobs waited for, the uploads and the downloads, as a few objects.
from lunaspace import Client
client = Client() # the key from LUNA_API_KEY
satellite = client.assets.get("SWARM-B")
client.tracking.upload(satellite, "fixes_2026-11-15.csv")
run = client.runs.request(
satellite, arc_start="2026-11-15T00:00:00Z", arc_end="2026-11-16T00:00:00Z"
).wait()
print(run.status, run.weighted_rms, run.accepted)
run.download("oem", "swarm-b.oem")
pip install lunaspace # Python 3.10 or newer
pip install 'lunaspace[pandas]' # with the data frames
Documentation: docs.lunaspace.eu: the quickstart, a guide to each part of the service, and the API reference. You need an API key for your organisation: write to info@lunaspace.eu.
Custom settings and groups
Where the profile's named settings are not enough, an expert gives the estimation's
settings with a run or a schedule (a feature of your tier, od_custom_settings in
client.me().features; without it FeatureNotIncluded):
for setting in next(p for p in client.profiles() if p.default).custom_settings:
print(setting.name, setting.value, setting.minimum, setting.maximum)
run = client.runs.request(
satellite,
"2026-11-15T00:00:00Z",
"2026-11-16T00:00:00Z",
custom={"segment_minutes": 45, "along_track_sigma_m_s2": 5e-9, "gravity_degree": 90},
).wait()
print(run.setting, run.custom) # "custom", the settings given
client.schedules.set(satellite, custom={"drag_coefficient_sigma": 0.5})
A satellite may be kept in a group (a constellation, a mission), a name its satellites
share; client.me().tier is your organisation's tier.
client.assets.update(satellite, group="Polar ring")
print([asset.name for asset in client.assets.list() if asset.group == "Polar ring"])
The products
orbit = client.orbits.get(satellite) # None before the first accepted run
client.orbits.ephemeris(satellite, "orbits/") # the current CCSDS OEM
(site,) = client.stations.catalogue("kiruna")[:1] # open sources, to fill a station in
kiruna = client.stations.create(
"KIRUNA", latitude_deg=site.latitude_deg, longitude_deg=site.longitude_deg, height_m=402
)
client.stations.assign(satellite, [kiruna], passes_days=3, light_time="receive")
passes = client.passes.request(satellite).wait() # or .get(satellite) for the latest
for station in passes.stations:
for p in station.passes:
print(station.name, p.aos, p.max_elevation_deg)
passes.download("pointing", "pointing.csv")
client.assets.update(satellite, norad_id=39451, international_designator="2013-067A")
tle = client.tle.request(satellite).wait()
print("\n".join(tle.lines), tle.fit.rms_m)
plan = client.plans.request(satellite, semi_major_axis={"delta_m": 50}).wait()
client.manoeuvres.report(
satellite, plan.burns[0].epoch, along_track_m_s=plan.burns[0].along_track_m_s
)
comparison = client.comparisons.request(satellite, arc_start, arc_end).wait()
print(comparison.recommended, comparison.recommended_reason)
The orbit's events, files and history
# Eclipses, crossings of the equator with the beta angle, the orbits one by one:
client.assets.update(satellite, orbit_events_enabled=True) # with every new orbit, or
events = client.events.request(satellite).wait() # now, for the current one
for eclipse in events.eclipses:
print(eclipse.start, eclipse.duration_s, eclipse.umbra_duration_s)
print(events.nodes[0].local_solar_time_h, events.nodes[0].beta_deg)
track = events.ground_track() # a data frame; or events.download("ground_track", "track.csv")
# A run as a report to read and pass on (one HTML page):
run.report("reports/")
# A run's orbit in another form: its ephemeris in the Earth-fixed frame every 30 s
# without covariances, and its state at an epoch as a CCSDS OPM.
fixed = run.orbit_file(frame="ITRF", step_s=30, covariance=False).wait()
fixed.download("orbits/")
state = run.orbit_file("opm", epoch="2026-11-17T06:00:00Z").wait()
print(state.elements, state.covariances, state.manoeuvres)
state.download("state.opm")
# The reconstructed orbit: the fitted arcs of the accepted runs joined, never a
# prediction; two arcs that overlap meet in the middle, a gap stays a gap.
orbit = client.orbits.reconstructed(
satellite, "2026-11-10T00:00:00Z", "2026-11-17T00:00:00Z"
).wait()
print([(piece.run_id, piece.start, piece.end) for piece in orbit.pieces], orbit.gaps)
orbit.download("orbits/")
# What each accepted run estimated for the drag coefficient:
history = client.orbits.drag_coefficients(satellite)
frames.drag_coefficients(history)["drag_coefficient"].plot() # lunaspace.frames, with pandas
A run's ephemeris holds its fitted arc and its prediction (run.product("oem").start,
.stop); a run on request made before 2026-11-18 holds its prediction alone, and gives
the reconstructed orbit nothing.
The mass a burn spends
# The propellant spent, as your bookkeeping has it; or the thruster's specific impulse.
client.manoeuvres.report(
satellite, "2026-11-18T06:00:00Z", along_track_m_s=0.02, delta_mass_kg=-0.004
)
client.manoeuvres.report(
satellite, "2026-11-19T06:00:00Z", along_track_m_s=0.02, specific_impulse_s=220
)
run = client.runs.request(satellite, arc_start, arc_end).wait()
print(run.mass_kg) # the mass at the arc's start
for burn in run.manoeuvres:
print(burn.epoch, burn.along_track_m_s, burn.planned, burn.delta_mass_kg, burn.mass_kg)
The satellite is lighter from a burn on, so drag and radiation pressure move it more. The
mass counts down from the spacecraft properties by the burns reported after their
valid_from; a burn reported with neither leaves it as it is. An OPM gives the mass at its
epoch and the run's burns after it, each with its mass change.
Diagnostics and trends
diagnostics = run.diagnostics() # a finished run's
print(diagnostics.radial.sd, diagnostics.along_track.sd) # residuals over sigma: 1 is right
drag = diagnostics.parameter("drag_coefficient").values[0]
print(drag.value, drag.sigma)
print(diagnostics.correlations.strongest[:3])
for horizon in diagnostics.prediction_check: # the run before's prediction, over its sigma
print(horizon.after_hours, horizon.position_error_m, horizon.z)
for point in diagnostics.prediction_series: # the same every five minutes, in metres
print(point.epoch, point.error_m.along_track, point.sigma_m and point.sigma_m.along_track)
for row in client.runs.trends(satellite, limit=60): # oldest arc first
print(row.arc_end, row.weighted_rms, row.drag_coefficient, row.at(24))
Both are features of a tier: an organisation without them gets FeatureNotIncluded.
As data frames
With pandas (pip install 'lunaspace[pandas]'), lunaspace.frames turns them into data
frames, in SI units with UTC time indexes:
from lunaspace import frames
trend = frames.trends(client.runs.trends(satellite)) # one row per run, by arc end
trend[["weighted_rms", "drag_coefficient"]].plot(subplots=True)
residuals = run.residuals() # every fix, metres, by epoch
residuals[residuals.used].groupby(residuals.index.hour)["along_track_m"].std()
diagnostics = run.diagnostics()
frames.parameter(diagnostics, "along_track_acceleration") # value, sigma, a priori
frames.correlations(diagnostics) # the matrix, named
prediction = diagnostics.prediction() # the run before's prediction against this fit
prediction[["along_track_m", "sigma_along_track_m"]].plot() # the error and its 1 sigma
Webhooks
hook = client.webhooks.create("https://example.com/luna") # keep hook.secret: shown once
# In the handler, with the body exactly as received:
from lunaspace.webhooks import verify
event = verify(secret, body, headers["Luna-Signature"]) # InvalidSignature otherwise
Configuration
| Variable | Default | |
|---|---|---|
LUNA_API_KEY |
none | Your organisation's API key (lsk_...) |
LUNA_API_URL |
https://api.lunaspace.eu |
The API's address |
Both can be given to Client(api_key=..., base_url=...) instead.
Errors
Every error of the API is a LunaError carrying the HTTP status, the API's code where it
gives one, and its message. The common ones have their own class: AuthenticationError
(401), FeatureNotIncluded (403, a feature your tier does not include), NotFound
(404), InvalidRequest (422), ServerError (5xx). wait() raises JobFailed (RunFailed
for a run) for a job that failed, with the API's error code (invalid_tracking_data,
estimation_failed, fit_failed, ...), and WaitTimeout when it is not finished in
time.
Versions
0.x while the client is built; 1.x then follows the API's /v1. Published under the
Apache License 2.0.
Metadata
Release files for lunaspace 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lunaspace-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for lunaspace-0.12.0-py3-none-any.whl |
Release files / lunaspace-0.12.0-py3-none-any.whl
| Download URL | lunaspace-0.12.0-py3-none-any.whl |
|---|---|
| Size | 36.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
acb1652dfcbf4688b2ac2a00fdeaeeec2d567d75bac54128997cc041cb6fe5ba
|
|
BLAKE2b-256 checksum How to use checksums |
62795cc31ad3f5b8e9014faf4c7713277a439de734558d50b226a074cdb98a54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for lunaspace 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.