Find the altitude and azimuth of a star
Use this when you have a catalog entry, such as a Gaia or Hipparcos star, and need to know where it appears in your sky at a given moment. The example finds Barnard’s Star from Mauna Kea at 14:00 UTC on 2026 April 10, with refraction for the summit’s weather:
use celestial_coords::astrom::earth::EarthRotation;
use celestial_coords::astrom::Astrom;
use celestial_coords::eop::EopProvider;
use celestial_coords::frames::icrs::ICRSPosition;
use celestial_coords::frames::topocentric::refraction::weather::Weather;
use celestial_coords::frames::topocentric::refraction::Refraction;
use celestial_coords::proper_motion::CatalogStar;
use celestial_core::angle::Angle;
use celestial_core::constants::{J2000_JD, MJD_ZERO_POINT};
use celestial_core::location::Location;
use celestial_time::julian::JulianDate;
use celestial_time::scales::conversions::{ToTAI, ToTT};
use celestial_time::scales::tt::TT;
use celestial_time::scales::utc::UTC;
// 1. The time, as TT and as a UTC Modified Julian Date
let utc: UTC = "2026-04-10T14:00:00Z".parse()?;
let tt = utc.to_tai()?.to_tt()?;
let jd = utc.to_julian_date();
let mjd = (jd.jd1() - MJD_ZERO_POINT) + jd.jd2();
// 2. Earth orientation for that moment
let eop = EopProvider::bundled()?.get(mjd)?;
println!("{eop}");
// 3. The star's place on the date
let barnard = CatalogStar {
ra: Angle::from_degrees(269.44850252543),
dec: Angle::from_degrees(4.73942005111),
pm_ra_cos_dec_mas_per_year: -801.551,
pm_dec_mas_per_year: 10362.394,
parallax_mas: 546.976,
radial_velocity_km_per_s: -110.47,
};
let j2016 = TT::from_julian_date(JulianDate::new(J2000_JD, 5844.0));
let on_date = barnard.propagate(&j2016, &tt)?;
let star = ICRSPosition::new(on_date.ra, on_date.dec)?;
// 4. The apparent place, seen from the site
let site = Location::from_degrees(19.8207, -155.4681, 4205.0)?;
let cirs = Astrom::for_site(&tt, &eop, &site)?.icrs_to_cirs(&star)?;
// 5. Turn it to the horizon
let horizon = EarthRotation::new(&tt, &eop)?
.cirs_to_hour_angle(&cirs, &site)?
.to_topocentric()?;
// 6. Add refraction
let weather = Weather::new(615.0, 2.0, 0.3, 0.55)?.with_location(&site)?;
let observed = horizon.with_refraction(&Refraction::from_weather(&weather)?);
println!("az {:.4}°, el {:.4}°", observed.azimuth().degrees(), observed.elevation().degrees());
// EOP(MJD=61140.6, xp=0.140612", yp=0.413757", UT1-UTC=0.0474262s)
// az 131.1203°, el 68.0376°
Azimuth runs from north through east, so 131° is southeast.
What each step needs
- The time. The coordinate models take Terrestrial Time (TT). The IERS tables are indexed by the UTC date, so you need the UTC Modified Julian Date as well. Converting from UTC goes through TAI, because TT is defined from TAI.
- Earth orientation.
EopProvider::bundled()reads the IERS tables built into the crate, so this works offline. Dates past the end of the table return an error. See Earth orientation parameters to load newer data. - The star’s place on the date. Skip
propagatefor a catalog that already gives positions at the date you want, or for a star whose proper motion you don’t care about. Gaia DR3 positions are at J2016.0, which is 5844 days after J2000.0. - The apparent place.
Astrom::for_siteapplies light deflection, annual and diurnal aberration, precession and nutation. - The horizon.
EarthRotationturns the Earth by the rotation angle for that UT1, andto_topocentricgives azimuth and elevation. - Refraction. Use the pressure and temperature at the telescope, not the sea-level values from a weather report. Atmospheric refraction explains the inputs.
A shorter version
If arcsecond-level accuracy is enough, the CoordinateFrame trait gets you there in
fewer lines:
use celestial_coords::eop::EopProvider;
use celestial_coords::frames::cirs::CIRSPosition;
use celestial_coords::frames::icrs::ICRSPosition;
use celestial_coords::transforms::CoordinateFrame;
use celestial_core::constants::MJD_ZERO_POINT;
use celestial_core::location::Location;
use celestial_time::scales::conversions::{ToTAI, ToTT};
use celestial_time::scales::utc::UTC;
let utc: UTC = "2026-04-10T14:00:00Z".parse()?;
let tt = utc.to_tai()?.to_tt()?;
let jd = utc.to_julian_date();
let eop = EopProvider::bundled()?.get((jd.jd1() - MJD_ZERO_POINT) + jd.jd2())?;
let site = Location::from_degrees(19.8207, -155.4681, 4205.0)?;
let star = ICRSPosition::from_degrees(269.4485, 4.7394)?;
let horizon = CIRSPosition::from_icrs(&star, &tt)?
.to_hour_angle(&site, &eop)?
.to_topocentric()?;
println!("{horizon}");
// Topocentric(Az=131.17° SE, El=68.01°)
This version skips three things. It uses the J2016.0 catalog position, which is 107″ from where Barnard’s Star is in 2026. It leaves out diurnal aberration, 0.29″ here. And it has no refraction, which at this elevation is 15″.
Many stars at the same moment
Astrom and EarthRotation hold everything that depends on the time and the site. Build
them once and reuse them for every star:
use celestial_coords::astrom::earth::EarthRotation;
use celestial_coords::astrom::Astrom;
use celestial_coords::eop::EopProvider;
use celestial_coords::frames::icrs::ICRSPosition;
use celestial_coords::frames::topocentric::refraction::weather::Weather;
use celestial_coords::frames::topocentric::refraction::Refraction;
use celestial_core::constants::MJD_ZERO_POINT;
use celestial_core::location::Location;
use celestial_time::scales::conversions::{ToTAI, ToTT};
use celestial_time::scales::utc::UTC;
let utc: UTC = "2026-04-10T14:00:00Z".parse()?;
let tt = utc.to_tai()?.to_tt()?;
let jd = utc.to_julian_date();
let eop = EopProvider::bundled()?.get((jd.jd1() - MJD_ZERO_POINT) + jd.jd2())?;
let site = Location::from_degrees(19.8207, -155.4681, 4205.0)?;
let weather = Weather::new(615.0, 2.0, 0.3, 0.55)?.with_location(&site)?;
let astrom = Astrom::for_site(&tt, &eop, &site)?;
let rotation = EarthRotation::new(&tt, &eop)?;
let air = Refraction::from_weather(&weather)?;
let stars = [
("Vega", 279.23473479, 38.78368896),
("Deneb", 310.35797975, 45.28033881),
("Regulus", 152.09296244, 11.96720878),
];
for (name, ra, dec) in stars {
let cirs = astrom.icrs_to_cirs(&ICRSPosition::from_degrees(ra, dec)?)?;
let horizon = rotation.cirs_to_hour_angle(&cirs, &site)?.to_topocentric()?;
if !horizon.is_above_horizon() {
println!("{name:8} below the horizon");
continue;
}
let observed = horizon.with_refraction(&air);
println!(
"{name:8} az {:8.4}° el {:7.4}°",
observed.azimuth().degrees(),
observed.elevation().degrees()
);
}
// Vega az 44.2397° el 60.5599°
// Deneb az 47.5402° el 36.8141°
// Regulus below the horizon
Refraction::from_weather runs a numerical ray trace, so build it once per change in the
weather, not once per star.
Edge cases
- The check for the horizon runs before refraction. A star a fraction of a degree below the true horizon can still be visible, because refraction near the horizon is about half a degree.
- Refraction on a
TopocentricPositionis held at its value for 2.9° elevation below that height. Don’t trust observed elevations under about 3°. - The result doesn’t include annual parallax or polar motion. For Barnard’s Star the first is up to 0.55″. What the chain leaves out has the details.
Where next
- From catalog to horizon explains each step.
- Earth orientation parameters covers the data behind step 2.
- Atmospheric refraction compares the refraction models.