Repeated n-body propagation (optional)

Keep using orb, m_ng = sloc.fetch_orb(...) with sloc.SSOLocator or sloc.locator_twice. Add sloc.CachedOrbPropagator when you repeatedly propagate the same full catalog or share propagated-state caches across runs. No migration is required.

CachedOrbPropagator reuses prepared state tables and validates cached outputs; it does not replace the initial orbit-fetch step. orb remains the DataFrame used by locators.

Prerequisites and next actions

Stage Required inputs Result / Next action
Setup Kete, SPICE kernels, prepared fovs Construct sloc.FOVCollection(fovs) and choose target epoch
Catalog Full orb table and aligned m_ng mask Instantiate sloc.CachedOrbPropagator(orb, m_ng)
Propagation Target epoch (TDB Julian date), output path Call CachedOrbPropagator.propagate(...) to obtain SimultaneousStates
Locator fovc, orb, simstates=states, matching jd0 Pass to sloc.locator_twice or sloc.SSOLocator for field filtering

Fetch, prepare, and reuse

This example requires Kete, suitable kernels, and your prepared Kete FOVs in fovs. It does not execute during site builds.

import numpy as np
import skyloc as sloc

orb, m_ng = sloc.fetch_orb(output="orb_sbdb.parq")
fovc = sloc.FOVCollection(fovs)
target_jd = float(np.mean(fovc.fov_jds))  # TDB; first-stage epoch

catalog = sloc.CachedOrbPropagator(orb, m_ng)
states = catalog.propagate(target_jd, output="current.parq")
sl1, sl2 = sloc.locator_twice(
    fovc, orb, simstates=states, jd0=(target_jd, np.mean)
)
ephemeris = sl2.eph

File roles and outputs:

  • orb_sbdb.parq stores orbital elements.
  • current.parq stores propagated states.
  • states is a Kete SimultaneousStates, or None when no n-body rows remain.
  • A compatible state cache skips integration; otherwise the catalog recomputes it.

Lifecycle and filtering rules

Keep catalog outside a period loop and call propagate for each target epoch and output path. Construct a new catalog after changing orbital elements or force settings.

If you filter orb before construction, filter m_ng with the same row mask. orb['desig'] must contain unique strings.

The constructor options use_nongravs, include_asteroids, and suppress_errors all default to True and are fixed per catalog. Suppressed propagation failures may produce NaN states.

The example hands off the same orb and the fetched m_ng. A matching-epoch locator pass reuses the states; at another epoch it starts from orbital elements. The catalog includes asteroid perturbations by default, so a reused first stage includes them too.

Keep force settings consistent for each stage that reuses states. The locator does not check the catalog fingerprint and silently omits missing cached objects. Pass the catalog-validated object, not an unchecked cache path.

Choose the epoch-reuse tolerance

The default is 1e-5 days (0.864 seconds). Choose a tolerance per call; for example, 0.1 seconds expressed in days:

tol_days = 0.1 / 86400
states = catalog.propagate(target_jd, output="current.parq", jd_tol=tol_days)
sl1, sl2 = sloc.locator_twice(
    fovc, orb, simstates=states, jd0=(target_jd, np.mean), jd0_tol=tol_days
)

Tolerance rules:

  • CachedOrbPropagator.load_cache(path, jd=target_jd, jd_tol=tol_days) accepts the same tolerance.
  • Catalog tolerances must be finite and positive; use overwrite=True to force recomputation.
  • locator_twice uses the same jd0_tol for both stages. Setting it to 0 disables the in-memory epoch shortcut, but not loading an existing output disk cache.
  • Negative or nonfinite tolerance values raise an exception.

Reuse requires abs(stored_jd - requested_jd) < tol; reused states retain their stored epoch. The tolerance does not guarantee a position-error bound.

Cache states must also match their declared metadata epoch. That integrity check keeps its own 1e-5 day tolerance, regardless of your reuse setting.

Major perturbers

The major asteroids (the five asteroid perturbers of kete) are excluded by their exact SBDB numbers. The catalog rejects names and SPICE IDs for those five bodies; use SBDB numbers such as "1" for Ceres. Keep the full orbit table when passing states to locator_twice, which handles those asteroids separately with drop_major_asteroids=True.

Continue from a previous epoch (optional)

Catalog propagation starts from the orbital elements unless you supply initial_states. To start from a compatible saved cache:

cached = catalog.load_cache("previous.parq")
states = catalog.propagate(
    next_jd,
    output="next.parq",
    initial_states=None if cached is None else cached.states,
)

Continuation constraints:

  • next_jd is a TDB Julian date.
  • Explicit initial_states must cover the catalog exactly once; invalid coverage raises.
  • Use initial_states from matching orbital inputs and force settings. Coverage is checked, but bare vectors cannot establish provenance.
  • Suppressed NaN states remain failed through the continuation chain.

Move or copy one cache file

current.parq embeds both Kete states and the catalog fingerprint plus TDB epoch in its Parquet file metadata. You can move, rename, or copy that single file without companion JSON files or dedicated directories. Kete reads it directly.

Metadata and compatibility behaviors:

  • load_cache(path) accepts a compatible cache at its stored epoch.
  • load_cache(path, jd=target_jd) also requires the requested epoch within tolerance.
  • Missing or incompatible embedded metadata causes recomputation.
  • Permission and other I/O errors raise.
  • Files from the earlier sidecar implementation are rebuilt; old JSON companions are ignored.

Recover after interruption

Safe write and recovery behavior:

  • A private temporary directory beside the destination holds the staging file.
  • Kete creates the cache file inside with normal process-umask permissions; one replacement then publishes the complete file while keeping the old cache intact until replacement finishes.
  • Normal completion and Python exceptions remove the temporary directory.
  • A forced kill can leave the temporary directory behind; readers ignore it. Remove it only after its writer has stopped.
  • PyArrow rewrites the Kete state table to embed metadata, preserving numerical values and column types at the cost of one additional table read/write per generated cache.

Cache limits

  • Concurrency: exactly one writer per output path.
  • Durability: no power-loss durability guarantee.
  • Cache identity: includes Kete’s package version, but not kernel contents or unversioned local Kete edits. After changing kernels or unversioned Kete code, discard old caches before recomputing.

Choose a Kete version

Use pip install 'skyloc[kete]' for kete (>=3.3). The full extra includes it. From a Skyloc checkout, install the Caltech-IPAC fork at v1.1.4 with uv. The fork requires Python 3.9–3.13 and a Rust toolchain.

UV_PROJECT_ENVIRONMENT=.venv-ipac uv sync --python 3.13 --extra kete_ipac

For pip, use the explicit Git install in the installation guide. The published extra alone selects the kete_ipac (v1.x) package from PyPI. Both branches import as kete, so use one branch per environment.

In locator_twice, both stages find objects with the kete FOV check. The locator_twice docstring describes how this check moves the objects with each kete version.

kete_ipac (v1.x) applies non-gravitational forces when it propagates to the start epoch, but its FOV check does not apply them. With cached states, the requested forces apply only from the supplied start epoch onward. Use a cache built with the intended forces, or set jd0_tol=0 to propagate from the orbital elements again.

Native saved file formats are version-specific, and kete (>=3.3) cannot save or load an FOVList.