Awk sexigesimal to decimal… again

This is the third update to my bash/awk script for turning coordinates given often into something useful. [The old version] didn’t give a large precision in the output coordinates, this is better:

#!/bin/bash
filein=$1
fileout=$2
cat $filein | awk ‘{if ($4>= “‘”0.0″‘”) {h=($1*15.0)+($2/60.0)*15+($3/3600.0)*15; h2=$4+($5/60.0)+($6/3600.0); printf(“%10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8f %10.8fn”, h,h2,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18)}; if ($4 $fileout

Stick the above in whateveryoulike.sh, chmod it so it runable (say chmod 700 whateveryoulike.sh) and run it as: whateveryoulike.sh input.dat output.dat – where input.dat has a list of sexigesimal RAs and DECs.

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: