C/C++ source code for UCAC-2

Last updated 24 August 2003

I received my beta UCAC-2 disks on 12 May 2003, and have confirmed that my C/C++ source code to access them (written while waiting for them to arrive) works properly. Since then, I've altered it slightly to allow for changes in the final format. You can click here to download source code for final UCAC2, and/or you can click here for source code for beta UCAC2. Both files are about 27 KBytes.

This also includes files that allow the data to be displayed in Guide 8.0. (I'll rig it to be used for astrometry in Charon in a bit. For that purpose, the absence of brighter stars may be a problem; this confuses the pattern-matching algorithm.)

ucac2.h and ucac2.cpp show how one can process UCAC-2 binary data from C. The code will work in Linux and DOS/Windows. I've added in byte-reordering code that ought to let it work on "wrong-Endian" platforms, but I don't have one handy with which to test the matter.

As best I can tell, this code has no particular advantages (or disadvantages) relative to the FORTRAN source, so your choice should reflect only your prejudices in programming languages.

Compiled as

cl -W4 -Ox -DTEST_PROGRAM ucac2.cpp             (Microsoft C/C++,  DOS/Windows)
wcl386 -W4 -Ox -DTEST_PROGRAM ucac2.cpp         (Watcom C/C++,  DOS/Windows)
g++ -o ucac2 -DUNIX -DTEST_PROGRAM ucac2.cpp    (GNU C/C++,  Linux)

you'll get a program that can be run as

ucac2 <ra> <dec> <width> <height>

with all arguments in decimal degrees. UCAC-2 data will be extracted and written to a text file, ucac2.txt. Optionally, one can add a path:

ucac2 <ra> <dec> <width> <height> <path>

to have the data read from another directory or from CD. For example, if your CD-ROM is drive d:, you might put the CD in the drive and run

ucac2 50 -12 1.3 1.8 d:\u2

to extract a 1.3-degree wide, 1.8-degree high field around RA=3h20m00s (a.k.a. 50 degrees), declination -12. As you might expect, if you've not copied the data and are running straight off the CD, you need to be sure to have the correct CD in the drive: disk 1 for declinations -90 to -37, disk 2 for declinations -37 to +1, or disk 3 for areas north of declination +1.

The DOS executable is provided in the .zip file.

Persons wishing to use UCAC-2 in Guide 8.0 should look here for information on how to accomplish that.

Hope this is useful to you, or at least interesting. Please let me know if you've problems or thoughts.