Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Star Catalog

celestial-catalog searches a star catalog built from Gaia DR3 and Hipparcos. The catalog is one file, and you search it by sky position.

The problem it solves

A plate solver, a pointing run and a finder chart all ask the same question: which stars are within this radius of this position, and how bright are they? Gaia DR3 can answer it, but the full release is 701 GB of compressed CSV in 3,386 files. Cut to magnitude 18.5 it’s still more than 419 million stars and 23 GB, far too much to load at startup. Most of those stars are faint ones along the Milky Way, which you’d throw away anyway.

The crate’s forge tool cuts the survey down to the brightest stars in each patch of sky and writes them to one file, sorted by position. The library memory-maps that file, so opening it reads a header and an index, and a search reads only the patches of sky it touches. Opening the 6.2 GB catalog reads 12.6 MB of it.

Here are the four stars brighter than magnitude 4 within a degree of the Pleiades:

use celestial_catalog::query::catalog::Catalog;
use celestial_catalog::query::cone::{cone_search, ConeSearchParams};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let catalog = Catalog::open("catalog-small.bin")?;

    // The Pleiades: every star brighter than magnitude 4 within 1 degree.
    let stars = cone_search(&catalog, &ConeSearchParams {
        ra_deg: 56.75,
        dec_deg: 24.1167,
        radius_deg: 1.0,
        max_mag: Some(4.0),
        max_results: None,
        epoch: None,
    })?;

    for s in &stars {
        println!(
            "{:>20}  RA {:9.5}°  Dec {:+9.5}°  mag {:5.2}  {:.3}° away",
            s.star.source_id, s.ra_deg, s.dec_deg, s.star.mag, s.distance_deg
        );
    }
    Ok(())
}
   66714384142368256  RA  56.87125°  Dec +24.10494°  mag  2.85  0.111° away
   65283232316451328  RA  56.45680°  Dec +24.36754°  mag  3.86  0.367° away
   65271996684817280  RA  56.21900°  Dec +24.11313°  mag  3.70  0.485° away
   66526127137440128  RA  57.29069°  Dec +24.05321°  mag  3.62  0.498° away

Those are Alcyone, Maia, Electra and Atlas, nearest first. The long numbers are Gaia DR3 source IDs. Positions are ICRS degrees at the catalog epoch, J2016.0, unless you ask for another date.

What you get

  • Searches that read only what they need. The file is memory-mapped, and Catalog::stars_in_pixel hands back a slice that points into the map. Nothing is parsed per star, so a 1° search around the Trapezium returns 7,668 stars from the 6.2 GB file in under a millisecond once the pages are in memory.
  • Proper motion to your date. Give a search an epoch and it moves each star from J2016.0 to that date before it measures the distance. Barnard’s Star moves 107″ between 2016 and 2026, so this matters for nearby stars.
  • Gaia’s quality flags. Each record says whether it has a proper motion and parallax, whether Gaia’s astrometry for it is suspect, and whether it came from Hipparcos. You can drop doubtful stars before you use them.
  • Three ready-made sizes. Pre-built files run from 276 MB to 6.2 GB. You can download one and start searching without touching the survey data.
  • Two command-line tools. query-catalog searches a file from the shell, and forge builds a new file from the survey data.

Limits

  • The catalog is thinned in crowded regions. Each patch of sky keeps a fixed number of its brightest stars. Away from the Milky Way that’s often every star to magnitude 18.5. Along the galactic plane the cut can fall near magnitude 10 in the smallest file. Get a Catalog File has the numbers for each size.
  • One magnitude, no colors. Each record has one magnitude: Gaia G, or Hipparcos Hp for stars brighter than about 7.5 that came from Hipparcos. There are no BP/RP colors and no radial velocities.
  • A few bright stars appear twice. Gaia’s Hipparcos cross-match table has no entry for some bright stars, and forge merge pairs those by position and magnitude. About a dozen keep both records, within 2″ of each other, because their Hp and G differ by more than the pairing allows. Build a Catalog with forge gives the limits.
  • Catalog places only. A search returns ICRS positions. Aberration, precession and refraction, the steps that turn a catalog place into where the star appears, are celestial-coords’ job.
  • A fixed file format. The library reads format version 2 files from forge. You can’t add stars or columns to a file after it’s built.

If you need Gaia’s other columns, such as colors or radial velocities, query the Gaia archive directly. This file gives up those columns to run offline and fast.

Where to start