How the Catalog File Works
The full catalog file is 6.2 GB, yet opening it reads only 12.6 MB, and a 1° cone search of it returns in under a millisecond once its pages are in memory. How does a search know where to look without reading the rest of the file?
The answer is that the file is sorted by position. The sky is cut into cells of equal area, every star is filed under its cell, and a small index at the front of the file says where each cell’s stars start. A search works out which cells its circle touches, looks them up in the index and reads those cells’ stars, and nothing else.
Cells on the sky
The cells come from HEALPix (Górski et al. 2005), the grid that Gaia and Planck use. It starts with 12 base cells, and each step of refinement splits every cell into four. The number of steps is the order, so a grid of order N has 12 × 4^N cells, all with the same area:
| Order | Cells | Cell size | Cell area |
|---|---|---|---|
| 6 | 49,152 | 55′ | 0.84 deg² |
| 8 | 786,432 | 13.7′ | 0.052 deg² |
| 10 | 12,582,912 | 3.4′ | 0.0033 deg² |
The file numbers its cells in HEALPix’s nested scheme. In that scheme the four children of cell p are cells 4p to 4p + 3, so cells that are close in number are close on the sky. A cone search uses this: it starts from the 12 base cells, keeps the ones that might overlap the circle, splits those, and repeats down to the file’s order. What’s left is every cell that touches the circle, plus a few near its edge that turn out not to.
A 1° search at order 8 covers about 60 cells’ worth of area, plus the cells its edge crosses. The search reads those cells’ stars and drops the ones outside the circle.
Inside the file
The file has three parts, one after the other:
- A 64-byte header: the magic bytes
CCAT, the format version, the order, nside, the number of cells, the number of stars, the epoch as a Julian year and the magnitude limit. - The cell index: 16 bytes per cell, giving the byte offset of the cell’s first star and how many stars it has. At order 8 that’s 12.6 MB, and at order 6 it’s 786 KB.
- The star records: 56 bytes each, grouped by cell, and brightest first within each cell.
You can check the arithmetic on the small file: 64 bytes, plus 49,152
cells at 16 bytes, plus 4,915,200 stars at 56 bytes, is 276,037,696
bytes, the size that query-catalog info prints.
Everything is little-endian, and each record has the same layout as the
StarRecord struct in memory. The library maps the file into memory and
treats the records as a &[StarRecord] slice in place, so reading a star
costs a memory access and nothing more. The same layout means the crate
only builds for little-endian targets, which covers x86-64 and the
64-bit ARM machines in common use.
Catalog::open checks the header, checks that the file is exactly as
long as the header says, and checks that every index entry points inside
the star data at its own run of records. A damaged or truncated file fails
there, so a search never reads past the end of the map. Opening a version
1 file fails with a message to rebuild it: version 1 numbered some cells
wrongly, and its stars would land in the wrong places.
What the order and the cap trade
A catalog to magnitude 18.5 has more than 419 million stars. Almost all of them are
faint stars along the Milky Way, and few uses need them all. forge
thins them with a cap: each cell keeps only its brightest N stars.
Two settings then decide what’s in the file: the order sets the cell
size, and the cap sets how many stars each cell keeps.
The cap sets the most stars any patch of sky can have, the cap divided by the cell area:
| File | Order | Cap | Most stars per deg² |
|---|---|---|---|
catalog-small.bin | 6 | 100 | 119 |
catalog-standard.bin | 8 | 50 | 953 |
catalog-full.bin | 8 | 200 | 3,812 |
The order decides how evenly those stars are spread. Take one 55′ cell of the small file. It’s the same patch of sky as 16 cells of the standard file. The small file keeps the 100 brightest stars of the whole patch, so if a bright cluster is in one corner, the cluster can take most of the 100 and leave the rest of the patch nearly empty. The standard file keeps 50 in each of the 16 smaller cells, 800 in all, and every corner of the patch gets its share. A narrow field sees about the same number of stars wherever it points.
Higher orders cost little at search time. Their price is a larger index:
Catalog::open checks every entry, and each entry takes 16 bytes of disk
whether or not its cell holds stars. forge stops at order 10, where the
index is already 201 MB.
Where the cap cuts in
Away from the Milky Way, many cells hold fewer stars than the cap, all the way to magnitude 18.5. Those cells keep everything. Along the galactic plane the cap fills with bright stars, and the cell’s faintest kept star can be magnitude 10 to 12. The depth of the catalog therefore changes across the sky. Choose a size lists the depth of each pre-built file.
For plate solving, that’s the right trade. A solver matches the brightest
stars it detects, so it needs the brightest catalog stars in every part
of the field, and it has little use for a dense list of faint stars in
one cell. If you need completeness to a fixed magnitude everywhere, build
a file without --max-per-cell, or with a cap high enough that no cell
reaches it.
Where the stars come from
forge builds the file from two sources:
- Gaia DR3, every star brighter than the magnitude limit, G 18.5 for the pre-built files. Positions, proper motions and parallaxes are at J2016.0.
- Hipparcos, from the new reduction of van Leeuwen (2007), for stars
brighter than Hp 7.5. Gaia has no 5- or 6-parameter astrometry for some
of the brightest stars, and Hipparcos fills them in.
forgemoves each Hipparcos position from J1991.25 to J2016.0, so the whole file has one epoch.
A star in both catalogs keeps its Gaia record when Gaia has a 5- or
6-parameter solution for it, and its Hipparcos record otherwise. forge
finds the stars in both through Gaia’s Hipparcos cross-match table. The
table has no entry for about 4,200 of the 23,270 Hipparcos stars, and
forge pairs about 4,100 of those with the nearest Gaia record within 2″
of the right magnitude. Build a Catalog with forge
gives the limits.
Edge cases
- A whole-sky search holds every star in memory. A radius of 180° or
more searches the whole sky, and for the full file that’s 111 million
results at 80 bytes each, about 8.9 GB. To visit every star, loop over
the cells with
Catalog::stars_in_pixelinstead. - Fast-moving stars near the edge of a search. A search picks cells by the stored J2016.0 positions, then matches on the moved ones. A star that was outside every cell the circle touches in 2016, but has moved inside the circle by your date, isn’t returned. Barnard’s Star, the fastest, moves 10.4″ a year, so even ten years from the catalog epoch this needs a fast star within about 2′ of the circle’s edge.
- One magnitude system per record. Gaia records have G and Hipparcos
records have Hp. The two agree to a few tenths of a magnitude for most
stars, but a red star’s G can be up to 2 mag brighter than its Hp. A
max_magcut near a star’s magnitude can keep or drop it depending on which catalog its record came from.
Next steps
- To pick a file, read Get a Catalog File.
- To build a file with your own order and cap, read Build a Catalog with forge.
- For how the plate solver uses the catalog, see The Star Catalog.