Regenerating the Tables
The coefficient tables in the crate are truncated copies of VSOP2013 and ELP/MPP02. Regenerate them when you want a different trade between accuracy and size: more terms for a body you care about, or fewer to shrink the crate. Accuracy explains how the shipped thresholds were chosen.
Two tools behind the cli feature do the work:
| Tool | Writes |
|---|---|
vsop2013-gen | celestial-ephemeris/src/planetary_coefficients/, one file per body and mod.rs |
elpmpp02-gen | celestial-ephemeris/src/lunar_coefficients/moon.rs |
Both tools have the same three subcommands:
downloadfetches the authors’ data files.analyzereports how many terms a threshold keeps.generatewrites Rust source.
Download the data files
VSOP2013 comes as VSOP2013p1.dat to VSOP2013p9.dat, one file per body,
from IMCCE at https://ftp.imcce.fr/pub/ephem/planets/vsop2013/solution/.
Each file’s number is the body’s number in the thresholds
table below, so 3 is the Earth-Moon barycenter. ELP/MPP02 comes as
ELP_MAIN.S1 to ELP_MAIN.S3 and ELP_PERT.S1 to ELP_PERT.S3, from
http://cyrano-se.obspm.fr/pub/2_lunar_solutions/2_elpmpp02/.
cargo run --release -p celestial-ephemeris --features cli --bin vsop2013-gen -- \
download --output vsop2013
cargo run --release -p celestial-ephemeris --features cli --bin elpmpp02-gen -- \
download --output elpmpp02
The nine VSOP2013 files total about 305 MB. If you only need one body,
vsop2013-gen download --planet 5 fetches that body alone.
Choose a threshold
A threshold keeps only the terms whose amplitude passes it:
- VSOP2013:
sqrt(S² + C²) > threshold. Units follow the variable: AU for the semi-major axis, radians for the mean longitude, and none for the four eccentricity and inclination variables. - ELP/MPP02:
amplitude >= threshold. For main-problem terms the amplitude is the absolute value of the first coefficient. For perturbation terms it issqrt(S² + C²). Units are arcseconds for longitude and latitude, and km for distance.
The shipped tables were cut at these thresholds:
| Body | Threshold | Terms kept | Terms in the series |
|---|---|---|---|
| 1 Mercury | 1e-9 | 1,434 | 272,360 |
| 2 Venus | 1e-10 | 5,242 | 289,647 |
| 3 Earth-Moon barycenter | 1e-10 | 7,813 | 294,426 |
| 4 Mars | 1e-10 | 16,287 | 309,140 |
| 5 Jupiter | 1e-9 | 7,592 | 324,608 |
| 6 Saturn | 3e-10 | 27,689 | 350,525 |
| 7 Uranus | 3e-8 | 5,124 | 330,581 |
| 8 Neptune | 1e-8 | 4,870 | 322,572 |
| 9 Pluto | 1e-7 | 7,729 | 114,088 |
| Moon (ELP/MPP02) | 1e-4 | 10,754 | 35,901 |
The generators use these thresholds unless --threshold overrides them.
Before you change one, check how many terms it keeps:
cargo run --release -p celestial-ephemeris --features cli --bin vsop2013-gen -- \
analyze --input vsop2013 --planet 4 --threshold 3e-11
cargo run --release -p celestial-ephemeris --features cli --bin elpmpp02-gen -- \
analyze --input elpmpp02 --threshold 1e-5
Generate the source
cargo run --release -p celestial-ephemeris --features cli --bin vsop2013-gen -- \
generate --input vsop2013 --output celestial-ephemeris/src/planetary_coefficients
cargo run --release -p celestial-ephemeris --features cli --bin elpmpp02-gen -- \
generate --input elpmpp02 --output celestial-ephemeris/src/lunar_coefficients
rustfmt --edition 2021 celestial-ephemeris/src/planetary_coefficients/*.rs \
celestial-ephemeris/src/lunar_coefficients/moon.rs
vsop2013-gen generate --planet N regenerates a single body. The new
mod.rs still lists the bodies already in the output directory, so the
others stay in the build.
Each generated file starts with the command and threshold that produced it:
//! VSOP2013 coefficients for Mercury
//!
//! Generated from VSOP2013p1.dat by
//! `vsop2013-gen generate --input <dir> --output <dir> --planet 1 --threshold 1e-9`
//! Terms retained: 1434 of 272360 (0.5%)
The output is deterministic. Running the commands above with the default
thresholds, then rustfmt, reproduces the shipped files byte for byte.
Ship new thresholds
The tests pin the shipped tables, so a new threshold means updating each of
the following. Paths are relative to celestial-ephemeris/.
default_thresholdinsrc/bin/vsop2013_gen/generate/mod.rs, orDEFAULT_THRESHOLDinsrc/bin/elpmpp02_gen/generate/mod.rs. A test checks that these match the headers of the shipped files.- The exact values in
src/planets/tests/state.rs. - The bounds in
src/planets/tests/ctl.rsandsrc/planets/tests/de432s.rs. Each bound is the largest miss of the shipped table, rounded up. - For the Moon, the vectors in
src/moon/tests/authors/vectors.rs. They come from the authors’ Fortran, run on the same truncated series. - The numbers on the Accuracy page, and the term counts in
celestial-ephemeris/README.md.