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

The query-catalog Command

query-catalog searches a catalog file from the shell. Use it to check a file you’ve downloaded, to look up the stars around a target, or to feed a list of stars to a script as JSON or CSV.

Install it with the cli feature, as Get a Catalog File shows. Every invocation names the catalog first, then a subcommand:

query-catalog --catalog <path> <subcommand>

There are two subcommands: info prints the file’s header, and search runs a cone search.

query-catalog --catalog catalog-small.bin info
HEALPix order: 6
nside: 64
npix: 49152
Total stars: 4915200
Epoch: J2016.0
Magnitude limit: 18.50
Average stars per pixel: 100.0
File size: 276037696 bytes (263.25 MB)

npix is the number of HEALPix cells, 12 × nside², and the epoch is the date of every position in the file. The standard and full files print order 8 and 786,432 cells. How the Catalog File Works explains the grid.

Search around a position

search takes a right ascension and a declination, then options. This is every star brighter than magnitude 4 within half a degree of Alcyone, in the Pleiades:

query-catalog --catalog catalog-small.bin search 3h47m24s +24d07m00s --radius 0.5 --mag-max 4
   1:    66714384142368256 RA=3ʰ 47ᵐ 29.0992ˢ Dec=+24° 6' 17.7896" Mag= 2.85 Dist=0.0227° Source=HIPPARCOS
   2:    66526127137440128 RA=3ʰ 49ᵐ 9.7653ˢ Dec=+24° 3' 11.5626" Mag= 3.62 Dist=0.4073° Source=GAIA
   3:    65283232316451328 RA=3ʰ 45ᵐ 49.6310ˢ Dec=+24° 22' 3.1491" Mag= 3.86 Dist=0.4376° Source=GAIA

Total results: 3

Results come nearest first. Each row has the source ID, the position, the magnitude, the distance from the search center and where the record came from. Alcyone’s row says HIPPARCOS but carries a Gaia source ID. Gaia has no 5- or 6-parameter astrometric solution for Alcyone, so the catalog keeps the Hipparcos record and labels it with the Gaia ID. A Hipparcos star with no Gaia match shows its HIP number negated, such as -17608.

RA and Dec take decimal degrees or sexagesimal. RA accepts 18h36m56s or 18:36:56, and Dec accepts +38d47m01s or -5:22:30.

Negative declinations

A declination such as -5:23:28 starts with a dash, so the argument parser reads it as a flag and stops:

error: unexpected argument '-5' found

  tip: to pass '-5' as a value, use '-- -5'

Put the options first and the position after --. Here are the three stars nearest the Trapezium in Orion:

query-catalog --catalog catalog-small.bin search --radius 0.2 --limit 3 -- 5h35m17s -5:23:28
   1:  3017364063331140224 RA=5ʰ 35ᵐ 16.7328ˢ Dec=-5° 23' 25.2252" Mag= 9.98 Dist=0.0014° Source=GAIA
   2:  3017364063330718080 RA=5ʰ 35ᵐ 16.4687ˢ Dec=-5° 23' 22.9059" Mag= 4.96 Dist=0.0026° Source=GAIA
   3:  3017364063330465152 RA=5ʰ 35ᵐ 17.2594ˢ Dec=-5° 23' 16.5645" Mag= 6.58 Dist=0.0034° Source=GAIA

Total results: 3

Move stars to a date

Positions in the file are at J2016.0. For a nearby star that’s a long time: Barnard’s Star moves more than 10″ a year. --date moves every star to 00:00 UTC on a calendar date before the search measures distances:

query-catalog --catalog catalog-small.bin search --radius 0.1 --mag-max 9 --date 2026-04-10 --raw 269.4485 4.7394
   1:  4472832130942575872 RA=269.446208° Dec=+4.768985° Mag= 8.19 Dist=0.0297° Source=GAIA

Total results: 1

The search center is Barnard’s Star’s catalog place, and by 2026 the star is 0.0297°, or 107″, away from it. --epoch does the same with a TT Julian Date, such as --epoch 2461140.5. The two flags conflict, so pass one or the other. --raw prints decimal degrees instead of sexagesimal.

Get JSON or CSV

--format json and --format csv print the same fields for a script to read:

query-catalog --catalog catalog-small.bin search --radius 0.2 --limit 2 --format json -- 5h35m17s -5:23:28
[
  {
    "source_id": 3017364063331140224,
    "ra_deg": 83.81971981441534,
    "dec_deg": -5.3903403413178115,
    "mag": 9.975762,
    "distance_deg": 0.0013502099081598566,
    "source": "GAIA"
  },
  {
    "source_id": 3017364063330718080,
    "ra_deg": 83.81861966629604,
    "dec_deg": -5.389696084726389,
    "mag": 4.9609604,
    "distance_deg": 0.0026190410447155922,
    "source": "GAIA"
  }
]
query-catalog --catalog catalog-small.bin search --radius 0.2 --limit 2 --format csv -- 5h35m17s -5:23:28
source_id,ra_deg,dec_deg,mag,distance_deg,source
3017364063331140224,83.81971981441534,-5.3903403413178115,9.975762,0.0013502099081598566,GAIA
3017364063330718080,83.81861966629604,-5.389696084726389,4.9609604,0.0026190410447155922,GAIA

In both formats, ra_deg and dec_deg are the moved position when you pass --date or --epoch.

Search options

FlagDefaultMeaning
--radius1.0Search radius in degrees
--mag-maxnoneLeave out stars fainter than this magnitude
--limitnoneReturn at most this many stars, nearest first
--datenoneMove stars to 00:00 UTC on this YYYY-MM-DD date
--epochnoneMove stars to this TT Julian Date
--formattabletable, json or csv
--rawoffPrint decimal degrees in the table instead of sexagesimal
--timingoffPrint how long the search took, to standard error

--timing measures the search alone, not opening the file.

Next steps