Build a Catalog with forge
forge builds a catalog file from the Gaia DR3 and Hipparcos source
data. Use it when the pre-built files don’t fit: you
want a different magnitude limit, a different HEALPix order or cap, or a
catalog you built and checked yourself.
Before you start
The build is slow and needs a lot of disk, almost all of it for Gaia:
- The download is 701 GB in 3,386 compressed CSV files from ESA. At a steady 100 Mbit/s that’s about 16 hours.
- The build needs about 800 GB of disk: the 701 GB of source files,
plus about 75 GB of working files at magnitude 18.5. The Gaia ingest and
the merged file are 23.5 GB each, and
build-indexwrites a third file of that size while it sorts. - The Gaia ingest reads every byte of the 701 GB, decompressing and parsing about 1.8 billion rows. It uses every core by default.
Once the merged file exists, the last step is quick. Building each of the three pre-built files from it took 74 to 89 seconds on a 16-core Mac. You can try several orders and caps without repeating the slow steps.
The steps
Install forge with the cli feature, as Get a Catalog
File shows. The build
runs in five steps:
download-gaiafetches the Gaia DR3 source files.ingest-gaiareads them and keeps the stars brighter than a magnitude limit.ingest-hipparcosreads the Hipparcos catalog and moves its positions to the Gaia epoch, J2016.0.mergecombines the two and drops the Gaia or Hipparcos copy of each star that’s in both.build-indexsorts the stars into HEALPix cells, applies the cap and writes the catalog file.
The ingest steps write to one working directory, and merge and
build-index read from it. Every subcommand takes --help and
--verbose (-v). The examples use /data/gaia for the Gaia files,
/data/hip for the Hipparcos files and /data/work for the working
directory.
Download Gaia DR3
forge download-gaia --output /data/gaia
download-gaia lists the files on ESA’s server and downloads four at a
time. Change that with --concurrency. Each failed file is retried up to
three times (--retries), and --limit 10 downloads only the first ten
files, which is enough to try the later steps on a patch of sky. Pass
--allow-partial-sky to ingest-gaia for such a patch.
The command records each verified file in gaia_manifest.json in the
output directory, so you can stop it and run it again: the rerun skips
every file that the manifest lists with the same size and ETag. If you got
the files some other way, there’s no manifest. The command then hashes each
local file of the right size, skips the ones whose MD5 matches ESA’s
_MD5SUM.txt, and adds them to the manifest. Hashing all 3,386 files reads
all of the roughly 750 GB once, which is limited by disk speed but takes far less
time than downloading it again. A file that doesn’t match is downloaded
again.
Each file name gives the range of HEALPix level-8 pixels that the file
holds: GaiaSource_000000-003111.csv.gz holds pixels 0 to 3111, and the
3,386 files cover pixels 0 to 786431 once each. Unless you pass --limit,
the command checks that ESA’s listing covers the sky that way and stops
if it doesn’t, because a listing cut short would leave files out.
--allow-partial-sky downloads such a listing anyway.
Ingest Gaia
forge ingest-gaia --path /data/gaia --output /data/work --mag-limit 18.5
This keeps every Gaia star brighter than G 18.5 and writes them to
/data/work/gaia_ingest.bin. The pre-built files used 18.5, which keeps
more than 419 million stars. The default limit is 15.0. Each half magnitude fainter
adds a lot of stars, so pick the faintest limit you need rather than the
faintest you can store.
The command processes files in parallel, one per core unless you pass
--threads. It writes a part file for each input file and joins them at
the end, deleting the parts. If a run stops partway, the next run skips
every input file that already has a part file. If a file fails to
decompress or parse, the command lists it in failed_files.log and
doesn’t write gaia_ingest.bin, so a damaged download can’t produce an
incomplete catalog.
Before it reads any file, the command checks the file names. If a file is missing, it lists the pixels that no file covers and stops:
Error: The .csv.gz files in "/data/gaia" do not cover the sky once. GaiaSource_AAAAAA-BBBBBB.csv.gz holds HEALPix level-8 pixels AAAAAA to BBBBBB, and the 3,386 Gaia DR3 files cover pixels 000000-786431 once each:
pixels 467168-467207 have no file
pixels 467355-467400 have no file
Add or remove files until they cover the sky once, then rerun. To build a catalog of part of the sky, pass --allow-partial-sky.
Those two gaps are four files in Ophiuchus, about 4.5 deg² of sky. The
join at the end checks the part file names the same way, so part files
left over from another set of input files can’t add a second copy of a
patch of sky. To build from part of the sky on purpose, pass
--allow-partial-sky. With --no-concat, a gap is only a warning,
because the run that joins the parts checks them.
To change the magnitude limit after an interrupted run, delete the
gaia_part_*.bin files first. They hold the old limit’s stars, and the
join refuses parts with a different limit.
Ingest Hipparcos
forge ingest-hipparcos --workdir /data/hip --output /data/work --mag-limit 7.5
Gaia DR3 has no usable astrometry for some of the brightest stars, so
the catalog takes them from Hipparcos. The command reads hip2.dat, the
Hipparcos new reduction (van Leeuwen 2007), and Gaia’s Hipparcos
cross-match table Hipparcos2BestNeighbour.csv from --workdir. When a
file is missing, it downloads the compressed copy from CDS or ESA and
unpacks it, so the first run fetches about 11 MB.
The pre-built files used --mag-limit 7.5, which keeps 23,270 Hipparcos
stars. The default is 7.0. The command moves each star from the Hipparcos
epoch, J1991.25, to J2016.0, and writes hipparcos_ingest.bin and
hipparcos_shared_matches.bin to --output.
Merge
forge merge --workdir /data/work
merge writes merged.bin with every star from both ingests, once. For a
star in both, it keeps the Gaia record when Gaia has a 5- or 6-parameter
astrometric solution for it, and the Hipparcos record otherwise.
It finds most stars in both through the cross-match table. The table has
no entry for about 4,200 of the 23,270 Hipparcos stars, so merge pairs
each of those by position. It takes the nearest Gaia record within 2″
whose G is at most 2.0 mag brighter or 1.0 mag fainter than the star’s
Hp. Both places are at J2016.0. The limits come from these sources of
difference:
- Position. The Hipparcos place has moved 24.75 years from J1991.25. The catalog errors give 18 mas of uncertainty for the median star, but a binary’s orbit curves its path, and an acceleration of 6.5 mas/yr² moves it 2″ off the straight line in that time.
- Magnitude. Hp and G are different bands. G reaches further into the red, so a red giant’s G is up to about 2 mag brighter than its Hp. G is fainter than Hp when Gaia splits a pair that Hipparcos measured as one star: each star of an equal pair is 0.75 mag fainter than both.
At the pre-built files’ magnitude limits this pairs about 4,100 stars. For about 40 of them a second Gaia record also qualifies, usually the other star of a pair, and that record stays. A Gaia record that two Hipparcos stars pick is dropped, and both Hipparcos records stay, as for a Gaia source that the cross-match table gives to two stars. About a dozen stars keep both records, because the two magnitudes differ by more than the limits allow.
Build the index
build-index is where the three pre-built files differ. These are the
commands that made them, each from the same merged.bin:
forge build-index --workdir /data/work --output catalog-full.bin --healpix-order 8 --max-per-cell 200
forge build-index --workdir /data/work --output catalog-standard.bin --healpix-order 8 --max-per-cell 50
forge build-index --workdir /data/work --output catalog-small.bin --healpix-order 6 --max-per-cell 100
--healpix-order sets the grid: nside = 2^order, and the default is 8.
The largest order is 10, because above it the index grows past 805 MB and
wide cone searches fail. --max-per-cell keeps that many of the
brightest stars in each cell. Leave it out and every star is kept, which
at magnitude 18.5 gives a 23.5 GB file. How the Catalog File
Works explains how to
choose the two.
The command prints its plan, then statistics about the result. This is
the end of the run that built catalog-small.bin:
=== Index Statistics ===
HEALPix order: 6
nside: 64
npix: 49152
Epoch: J2016
Magnitude limit: 18.50
Total stars before cap: 419445381
Total stars after cap: 4915200
Stars removed by cap: 414530181
Cells at cap: 49152 / 49152 non-empty (100.0%)
Empty pixels: 0
Stars per pixel (non-empty): min=100, max=100, mean=100.0, median=100
Output file size: 276037696 bytes (0.26 GB)
Elapsed time: 88.64s
Validating output...
Pixel 0: 100 stars verified
Pixel 24576: 100 stars verified
Pixel 49151: 100 stars verified
Validation passed.
Written "catalog-small.bin"
“Cells at cap” is the share of cells where the cap cut stars. In those cells the catalog is shallower than the magnitude limit. Here every cell was cut. The full file’s build reports 46.1%, so more than half of its cells keep every star to 18.5.
The command builds into a temporary file beside --output, opens it with
the library to check it, and only then renames it into place. A failed
build leaves an earlier catalog at that path untouched. The temporary
file is as large as merged.bin, so the output’s disk needs that much
free space.
Next steps
- To check the new file, run
query-catalog --catalog <file> info, as The query-catalog Command shows. - To compare your file’s depth with the pre-built ones, see Choose a size.