Skip to main content

PyCG-DTN

Build DTN contact graphs for deep-space networks from real ephemerides.

Give it a set of bodies and a number of days. It works out which SPICE kernels it needs, downloads them from NASA/NAIF, computes when every pair of nodes can actually see each other, and writes a contact plan.

from pycg_dtn import ContactGraph

cg = ContactGraph()
cg.AddCelestial("Earth")
cg.AddCelestial("Mars")
cg.AddCelestial("Phobos")

plan = cg.GenerateContactGraph(days=780)
plan.Write("out/")
out/contactGraph.csv     ION contact plan
out/contactGraph.json    full plan with metadata
out/summary.json         per-link statistics

Install

pip install pycg-dtn

Requires Python 3.10+.

What it computes

A contact is an interval during which two nodes can exchange data. Two things take a deep-space link away even when both endpoints are nominally in view:

Occultation — a third body sits in the line of sight. Mars hides Phobos; Jupiter hides Io.

Solar conjunction — the signal path passes close to the Sun, whose corona scatters and delays the signal badly enough that operators stand the link down. The threshold is the Sun–Earth–probe angle; below about 3° the link is treated as unusable, following DSN practice (DSN handbook 810-005).

Contact time is the analysed span minus the union of everything that blocks it. Each surviving interval is then cut into sub-contacts wherever the achievable data rate has drifted more than 10%, so no single contact misrepresents how much data fits through it.

Rates come from a Friis free-space path loss → SNR → Shannon capacity chain, with defaults modelling an X-band spacecraft high-gain dish talking to a DSN 70 m antenna (74.18 dBi, Rodemich 1989).

Bodies

AddCelestial accepts anything NAIF names, case-insensitively — or a NAIF integer ID code.

cg.AddCelestial("Titan")
cg.AddCelestial("Europa", eid="ipn:5.2")   # custom ION endpoint identifier
cg.AddCelestial("401")                      # Phobos, by ID

An unrecognised name raises UnknownCelestialBodyError.

Kernels

A kernel is NAIF's term for a SPICE data file. Only the ones your bodies need are downloaded, which matters — the Jovian satellite ephemeris alone is over a gigabyte, and an Earth–Mars scenario should never pay for it.

Check the cost before committing:

pycg kernels --bodies Earth Mars Phobos
kernel directory: /home/you/kernels
4 kernels, about 96 MB total

  [need] naif0012.tls          0.0 MB   leap seconds, for UTC <-> ET conversion
  [need] pck00011.tpc          0.1 MB   body radii and IAU body-fixed orientation
  [need] de440s.bsp           31.2 MB   planetary ephemeris DE440 (short), 1849-2150
  [need] mar099s.bsp          64.5 MB   Phobos and Deimos

All files come from NAIF's public generic-kernel archive.

Configuring the link budget

Every radio parameter has a getter and a setter. Setters chain and validate.

lb = cg.GetLinkBudget()
lb.SetFrequency(32.0e9)     # Ka-band instead of X-band
lb.SetRxGain(79.0)          # a larger ground antenna
lb.SetBandwidth(5.0e6)
lb.SetMinRate(1000.0)       # drop contacts below 1 kbps

print(lb.GetWavelength(), lb.GetNoisePower())
Parameter Getter / Setter Default
Transmit power, W GetTxPower / SetTxPower 100
Carrier, Hz GetFrequency / SetFrequency 8.42e9 (X-band)
Bandwidth, Hz GetBandwidth / SetBandwidth 1.0e6
Transmit gain, dBi GetTxGain / SetTxGain 48
Receive gain, dBi GetRxGain / SetRxGain 74.18
Noise PSD, dBm/Hz GetNoisePsd / SetNoisePsd −174
Rate floor, bits/s GetMinRate / SetMinRate 1

Configuring the geometry search

Same pattern on cg.GetGeometry():

geo = cg.GetGeometry()
geo.SetSepExclusion(2.0)     # tighter solar exclusion, degrees
geo.SetOccultStep(300.0)     # finer occultation search, seconds
geo.SetRateTolerance(0.05)   # split contacts on 5% rate drift

Choosing a span

Contact plans repeat on the synodic period — the time for two bodies to return to the same relative arrangement, which for planets with orbital periods Pa and Pb is 1 / |1/Pa − 1/Pb|.

Reading the results

plan = cg.GenerateContactGraph(days=780)

len(plan)                          # number of contacts
plan.ForLink("EARTH", "MARS")      # contacts on one link, time-ordered

for s in plan.LongestOutages(5):
    print(s.a, s.b, s.t_maxgap_days)

The CSV is the contact plan format ingested by ION, NASA JPL's reference DTN implementation. Each contact becomes four rows — a contact and a range line in each direction.

Command line

pycg kernels --bodies Earth Mars Phobos
pycg fetch   --bodies Earth Mars Phobos
pycg build   --bodies Earth Mars --days 780 --out out/
pycg build   --bodies Earth Mars --days 780 --frequency 32e9 --rx-gain 79

Roadmap

AddSatellite, for artificial spacecraft supplied as Keplerian orbital elements and propagated into the same geometry pipeline, is not implemented yet. It currently raises NotImplementedError.

License

GNU General Public License v3.0 or later. See LICENSE.

Download files

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

Source Distribution

pycg_dtn-0.1.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

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

pycg_dtn-0.1.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file pycg_dtn-0.1.0.tar.gz.

File metadata

  • Download URL: pycg_dtn-0.1.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.3

File hashes

Hashes for pycg_dtn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e01819ff7de9d4c2284c428502d2c7b601db3db4427b21f0bb56ab25c9c90012
MD5 fa718c92029d97d98b28d13dac28f399
BLAKE2b-256 f885bc884a90a7adc58e4b9253b5df9aaf42eafcca118529ff5f61bf1f3189c4

See more details on using hashes here.

File details

Details for the file pycg_dtn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pycg_dtn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.3

File hashes

Hashes for pycg_dtn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0716371f3218cc674d44c15f27d086e2c8db52b75cde093b2aec8299f6400d6
MD5 9e7c71c6a06454167a7c0a12d65375f0
BLAKE2b-256 9f997c3818eecd140e4996c2e5ac394948765e7217148e39e011add0b2960966

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.1.1

2 files

This release

0.1.0 This release

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