3
# Creates hipparcos data file for use with Stellarium
4
# from source hip_main.dat data file available at
5
# http://cdsweb.u-strasbg.fr/viz-bin/Cat?I/239
7
# Copyright 2005 Robert Spearman
9
# This program is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License
11
# as published by the Free Software Foundation; either version 2
12
# of the License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program; if not, write to the Free Software
21
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
print "\nConverting hip_main.dat to hipparcos.fab\n\n";
24
print "WARNING: This script has only been tested on x86 Linux.\n";
25
print "It may produce incorrect results on other platforms.\n\n";
29
open(IN, "hip_main.dat") || die "Can't find hip_main.dat\n";
30
open(OUT, ">hipparcos.fab") || die "Can't write hipparcos.fab\n";
38
# print("$f[1] : $f[3] : $f[4] : $f[5] : $f[76]\n");
43
if($hp > $high) { $high = $hp; } # data isn't contiguous...
46
if( $f[3] =~ /(\-*)(\d\d) (\d\d) (\d\d\.\d\d)/ ) {
47
$ra = $2 + $3/60 + $4/3600;
48
if($1 eq "-") { $ra *= -1; }
50
print "error with ra on hp $hp\n";
53
if( $f[4] =~ /(\-*)(\d\d) (\d\d) (\d\d.\d)/ ) {
54
$de = $2 + $3/60 + $4/3600;
57
print "error with de on hp $hp\n";
95
} elsif($sptype == 12) {
99
# print "$hp\t$ra\t$de\t$f[5]\t$f[76] ($sptype)\n";
103
# printf( "%d\t%d\t%.4f\t%.4f\t%s\n", $hp, $x, $ra, $de, $spcode);
105
$out{int($hp)} = pack("ffSxC", $ra, $de, $x, $sptype);
113
print "Highest hp = $hp\n";
115
print OUT pack("L", $high+1); # hp numbers start at 1
117
# data isn't sorted or contiguous in source file!
118
for( $a=0; $a<=$high; $a++) {
120
if($out{$a} eq "" ) {
121
print OUT pack("xxxxxxxxxxxx");