Going from sexigesimal to decimal…

I decided (and since I had todo this today) that for consistency (see [my post from there other day]) I should post how to convert between astronomical sexigesimal and decimal coordinates in awk:

awk ‘{h=($2*15)+($3/60)*15+($4/3600)*15; h2=$5+($6/60)+($7/3600); print $1,h,h2}’ input > output

see its nice and simple really… the input file given here simply as “input” should contain a list of Source Name (which is $1, not necessary but you normally have it…), RA (in H M S, all separated by spaces) and DEC (D M S, again space separated)…. enjoy.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: