Coordinate and Conversion Software in Support of Astronomy Projects

Astronomical Coordinate Transformations

I have a nice unix command-line program that can convert astronomical coordinates from any standard frame (e.g. equatorial, ecliptic, galactic) to any other (e.g. azimuth & elevation). This program converts coordinates between any pair of 22 astronomical coordinate systems, in either direction. Amazing!

Angle and Time Conversions

Over the years I've collected a bunch of unix command-line programs that, together, do all sorts of mundane conversions of angles (radians, degrees, hours) and times (Julian dates, etc). If you know how these little gems work, you can use them yourself on the command line, or embed them in shell scripts.

Each program expects one input on its command line, and prints one thing (the conversion) on standard output. The inputs can be of various types and formats, and the program's name tells you what it wants and what you get. First a few examples, and then a complete description.

Example 1: Convert decimal radians to decimal degrees. Typing return produces the output.

> r2d 2.3

Example 2: Convert hours, minutes and seconds to decimal hours:

> hms2h 15 30 10

Example 3: Convert civil time to decimal Julian date:

> ymd2j 2009 4 10 15 30 10

Input and Output Conventions

The programs have names of the form x2y, where the form of x tells you what to supply and y tells you what you get. Here's the list:

notation meaning example
d angle in decimal degrees
dms angle in degrees minutes seconds (3 numbers)
15 30 10
h time in decimal hours
hms time in hours minutes seconds (3 numbers)
15 30 10
r angle in decimal radians
j decimal julian date
jd julian day number (integer) hour minute second (4 numbers)
2454932 3 30 10
y decimal year
ymd year month day hour minute second (6 numbers)
2009 4 10 15 30 10

Decimal and Un-normalized Inputs

Year and month numbers are always whole numbers. Each varies in length (e.g. February and July), so a fractional amount of one doesn't always represent the same amount of time. Half of February depends on which year it is!

Other than year and month numbers, all the other inputs can be decimal values. And they can be out of their normalized range. For example, the ymd time of "2009 1 100 15 30 10" can be used to specify the 100th day of the year (January one-hundreth!) If you're converting a list of old observation data that uses decimal days, then being able to specify "2009 4 10.64594907 0 0 0" can help. Another example is shell scripts: if you are iterating over days, you don't have to manage keeping everything in its normal range. e.g. "2009 1 x 0 0 0" where x ranges from 1 to 365 will work just fine.

For each data type above, there is a program to normalize it (x2x) and a program to format it in normalized form (fmt_x).

Table of Conversion Programs

The x marks show which programs exist. The marks on the diagonal (e.g. r2r or hms2hms) indicate programs that normalize their inputs. For example, r2r will map an angle greater than 2pi into an angle within 2pi. hms2hms will map an un-normalized "25 0 0" to "1 0 0".

d dms h hms r j jd y ymd
d x x x x x

dms x x x x x

h x x x x x

hms x x x x x

r x x x x x


x x x x

x x x x

x x x x

x x x x

There is a formatting program for each data type, which prints out the input in a standard, normalized way. The names come from the data types, like fmt_d and fmt_ymd.