use std::path::PathBuf;
use supernovas::{
Accuracy, AniseEphemeris, CatalogEntry, EphemerisProvider, Frame, Observer, Planet,
ReferenceSystem, Source, Time,
};
fn ephemeris_path() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("data")
.join("de440s.bsp")
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
AniseEphemeris::open(ephemeris_path())?.install()?;
let jd = 2_460_676.5_f64;
let time = Time::from_tt_jd_auto_eop(jd)?;
let observer = Observer::Geocenter;
let frame_full = Frame::with_auto_polar_motion(Accuracy::Full, &observer, &time)?;
let frame_red = Frame::new(Accuracy::Reduced, &observer, &time)?;
let stars: &[(&str, CatalogEntry)] = &[
(
"Vega",
CatalogEntry::icrs("Vega", "18:36:56.336".parse()?, "+38:47:01.28".parse()?)?,
),
(
"Sirius",
CatalogEntry::icrs("Sirius", "06:45:08.917".parse()?, "-16:42:58.02".parse()?)?,
),
(
"Arcturus",
CatalogEntry::icrs("Arcturus", "14:15:39.672".parse()?, "+19:10:56.67".parse()?)?,
),
];
println!("── Catalog stars (ICRS apparent, Accuracy::Full, J2025.0) ───────────────");
for (name, star) in stars {
let app_full = star.apparent_in(&frame_full, ReferenceSystem::Icrs)?;
let app_red = star.apparent_in(&frame_red, ReferenceSystem::Icrs)?;
let sep_mas = app_full
.equatorial()
.distance_to(app_red.equatorial())
.mas();
let eq_full = app_full.equatorial();
println!(" {name:<10} {eq_full}");
println!(" Full–Reduced: {sep_mas:.4} mas");
}
let planets: &[(&str, Planet)] = &[
("Mars", Planet::mars()?),
("Jupiter", Planet::jupiter()?),
("Saturn", Planet::saturn()?),
];
println!("\n── Solar-system bodies (ICRS apparent, Accuracy::Full, J2025.0) ─────────");
for (name, planet) in planets {
let app_full = planet.apparent_in(&frame_full, ReferenceSystem::Icrs)?;
let app_red = planet.apparent_in(&frame_red, ReferenceSystem::Icrs)?;
let sep_mas = app_full
.equatorial()
.distance_to(app_red.equatorial())
.mas();
let dist_au = app_full.distance().au();
let light_s = dist_au * 499.004_848;
let eq_full = app_full.equatorial();
println!(" {name:<10} {eq_full}");
println!(
" dist {dist_au:.4} AU ({light_s:.1} s light time) \
Full–Reduced: {sep_mas:.4} mas"
);
}
Ok(())
}