« Make grids of images | Main | Talking GALFACTS Calibration »

Awk sexigesimal to decimal

Ages ago I put on here some awk scripts to convert between decimal numbers and sexigesimal (i.e. very useful with astronomical catalogues) and I think I've also gone the other way... anyway here is an updated and a more useful bash script todo this, still using awk at the heart of it (this goes from sexigesimal to decimal):


#!/bin/bash
filein=$1
fileout=$2

cat $filein | awk '{if ($4>= 0) {h=($1*15)+($2/60)*15+($3/3600)*15; h2=$4+($5/60)+($6/3600); print h,h2,$7,$8,$9}; if ($4< 0) {h=($1*15)+($2/60)*15+($3/3600)*15; h2=$4-($5/60)-($6/3600); print h,h2,$7,$8,$9,$10} }' > $fileout

put this in whateveryoulike.sh and there you go.

TrackBack

TrackBack URL for this entry:
http://www.krioma.net/cgi-bin/mt_new/mt-tb.cgi/457

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on August 14, 2010 11:02 PM.

The previous post in this blog was Make grids of images.

The next post in this blog is Talking GALFACTS Calibration.

Many more can be found on the main index page or by looking through the archives.

Get Firefox! Valid XHTML 1.0! Valid CSS! RSS Feed BlogUniverse - listed Powered by Apache Creative Commons License ringsofsaturnrock's Most Interesting Photos on Flickriver

Powered by
Movable Type 3.33