Posted first version 2014 December 23
Links to other source code on this site
I've written C/C++ code to access URAT1 data. (Where 'C/C++' means the code will work correctly with either language.) It borrows a great deal from the code I wrote for UCAC4 (which, in turn, borrowed from UCAC3 and UCAC2 code.) In each case, I took the previous version and tweaked things a bit to allow for changes in formatting, indexing, and file naming conventions. You can click here for the source code for URAT1 access.
urat1.h and urat1.c show how one can process URAT1 binary data from C or C++. The code will work in Linux and DOS/Windows. I've added in byte-reordering code that ought to let it work on "big-Endian" (non-Intel, such as Sun and PowerPC) platforms, but I don't have one handy with which to test the matter.
Essentially, two functions are provided. One allows you to extract the data for a particular URAT1 star, stored in a structure. The second allows one to extract all URAT1 stars in a given RA/dec rectangle. The data is stored in an ASCII file.
Also provided is urat1_t.c, which both shows how the functions are used and can serve as a command-line utility for extracting a rectangle of URAT1 data or getting data on a specific URAT1 star.
A makefile is provided for GNU C/C++ (this also works with MinGW). After building the software, one can run
./urat1_t <ra> <dec> <width> <height>
with all arguments in decimal degrees. URAT1 data will be extracted and written to a text file, urat1.txt. Optionally, one can add a path:
./urat1_t <ra> <dec> <width> <height> <path>
to have the data read from another directory or from DVD. For example, if your DVD drive is d:, you might put the DVD in the drive and run (in Windows)
u4test 50 -12 1.3 1.8 d:
to extract a 1.3-degree wide, 1.8-degree high field around RA=3h20m00s (a.k.a. 50 degrees), declination -12. On Linux/Unix systems, this would become something like
./u4test 50 -12 1.3 1.8 /media/cdrom/
Some warnings: this currently assumes the URAT1 files are in the current directory, or the specified directory. It doesn't look beyond that, the way the UCAC4 code did. It also makes some assumptions about file naming which may not be true in the released version of URAT1. If you run into trouble, I'd suggest you come back to this page and look for updated software. If that fails, please give me a nudge via e-mail.
Also, one can run the program in the folder containing URAT1 data with a URAT1 star number. The output will be a text version of the URAT1 record for that star. For example,
u4test 314-159265
would cause the program to display the basic data for star 159265 in zone 314. (I don't know what the desired designation scheme might be.)
./u4test 314-159265 /media/cdrom
would do the same thing, but tell u4test where to look for the data files (going through the same possible paths as above).
To any of these, one may add command line options -h to include a header line, and/or -f4 to get the same output as from the FORTRAN code.
Hope this is useful to you, or at least interesting. Please let me know if you've problems or thoughts, at pôc.otulpťcéjôřp@otúlm (making changes that I hope will be obvious to non-spammers!)
• (2015 March 18) The final version of the data, as posted at ftp://cdsarc.u-strasbg.fr/pub/cats/I/329/URAT1/v12/, had a file name change from u1index.unf to v1index.unf. (I believe this was done to avoid the fact that UCAC-x had files with the same name.) I modified urat1.c to find the correct file. Note that both the old and new code can work without an index file, or a misnamed index file, but it may be a hair slower. (The index speeds up the search for data slightly.)
I also made some small changes to remove compiler warning messages and added a few comments about the FORTRAN output format.