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";
32
my $dmin = 1000000000000;
41
# print("$f[1] : $f[3] : $f[4] : $f[5] : $f[76]\n");
46
if($hp > $high) { $high = $hp; } # data isn't contiguous...
49
if( $f[3] =~ /(\-*)(\d\d) (\d\d) (\d\d\.\d\d)/ ) {
50
$ra = $2 + $3/60 + $4/3600;
51
if($1 eq "-") { $ra *= -1; }
53
print "error with ra on hp $hp\n";
57
if( $f[4] =~ /(\-*)(\d\d) (\d\d) (\d\d.\d)/ ) {
58
$de = $2 + $3/60 + $4/3600;
61
print "error with de on hp $hp\n";
100
} elsif($sptype == 12) {
104
# print "$hp\t$ra\t$de\t$f[5]\t$f[76] ($sptype)\n";
108
# printf( "%d\t%d\t%.4f\t%.4f\t%s\n", $hp, $x, $ra, $de, $spcode);
113
print "No parallax for hp $hp\n";
115
$ly = abs(3.2616/($f[11]/1000));
117
if($ly<$dmin) {$dmin = $ly;}
118
if($ly>$dmax) {$dmax = $ly;}
122
$out{int($hp)} = pack("ffSCf", $ra, $de, $x, $sptype, $ly);
123
# $out{int($hp)} = pack("ffSxC", $ra, $de, $x, $sptype);
131
print "Highest hp = $high\n";
132
print "ly min: $dmin\tlymax: $dmax\n";
134
print OUT pack("L", $high+1); # hp numbers start at 1
136
# data isn't sorted or contiguous in source file!
137
for( $a=0; $a<=$high; $a++) {
139
if($out{$a} eq "" ) {
140
print OUT pack("xxxxxxxxxxxxxxx");