HipJ1991ToJ2000.v2.pl 3.17 KB
Newer Older
1 2
#!/usr/bin/perl -w

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# Copyright (C) 2013 Alexander Wolf
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 
# 02110-1335, USA.

21 22 23 24 25 26
# v.1
# This tool read original Hipparcos catalog (J1991.25) + Hipparcos from VizieR (J2000.0)
# and update coordinates in original catalog.
# v.2
# Get Hipparcos 2 from VizieR (cat. 2007 - I/311) and improve original catalog.
#
27
# All catalogs can be found here: http://astro.altspu.ru/~aw/stellarium/hipparcos/
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
#

# Original Hipparcos catalog (1997; J1991.25)
$HIPmain	= "./hip_main.dat";
$HIPcom		= "./h_dm_com.dat";

# Hipparcos from VizieR (2013; J2000.0)
$HIPmainV	= "./hip_main_j2000.dat";
$HIPmainVa	= "./hip_main_j2000a.dat";
$HIPcomV	= "./h_dm_com_j2000.dat";

# Hipparcos 2 from VizieR (2013)
$HIP2main	= "./hip2_main.dat";

# Result
$HIPmainR	= "./hip_main_r.dat";
$HIPcomR	= "./h_dm_com_r.dat";

# Hipparcos main catalog
open(oHIP, "<$HIPmain");
@catalog = <oHIP>;
close oHIP;

open(cHIP, "<$HIPmainV");
@catalogV = <cHIP>;
close cHIP;

open(vHIP, "<$HIPmainVa");
@catalogA = <vHIP>;
close vHIP;

open(tHIP, "<$HIP2main");
@catalogT = <tHIP>;
close tHIP;

for($i=0;$i<scalar(@catalogT);$i++) 
{
	@fixt = split('\|',$catalogT[$i]);
	$id = $fixt[0]+0;
	$Plx[$id] = $fixt[1]; 	# Plx from H2
	$pmRA[$id] = $fixt[2];	# pmRA from H2
	$pmDE[$id] = $fixt[3];	# pmDE from H2
	$Hpmag[$id] = $fixt[4]; # Hpmag from H2
	$BV[$id] = $fixt[5];	# B-V from H2
}

open(rHIP, ">$HIPmainR");
for($i=0;$i<scalar(@catalog);$i++) 
{
	@cat = split('\|',$catalog[$i]);
	@fix = split('\|',$catalogV[$i]);
	@fixa = split('\|',$catalogA[$i]);

	if ($cat[8] ne '            ' && $cat[9] ne '            ')
	{
		if ($fixa[0] ne '            ' && $fixa[1] ne '            ')
		{
			$cat[3] = substr($fixa[0],0,11); # RA
			$cat[4] = substr($fixa[1],0,11); # DE
		}
		$cat[8] = $fix[0]."00";
		$cat[9] = $fix[1]."00";
	}
	$id = $cat[1]+0;
	if ($Plx[$id] ne '') {
		$cat[11] = $Plx[$id]; # Plx from H2
	}
	if ($pmRA[$id] ne '') {
		$cat[12] = $pmRA[$id]; # pmRA from H2
	}
	if ($pmDE[$id] ne '') {
		$cat[13] = $pmDE[$id]; # pmDE from H2
	}
	if ($Hpmag[$id] ne '') {
		$cat[44] = $Hpmag[$id]; # Hpmag from H2
	}
	if ($BV[$id] ne '') {
		$cat[37] = $BV[$id]; # B-V from H2
	}
	print rHIP join('|', @cat);
}
close rHIP;

# Hipparcos binary stars catalog
open(oHIP, "<$HIPcom");
@catalog = <oHIP>;
close oHIP;

open(cHIP, "<$HIPcomV");
@catalogV = <cHIP>;
close cHIP;

open(rHIP, ">$HIPcomR");
for($i=0;$i<scalar(@catalog);$i++) 
{
	@cat = split('\|',$catalog[$i]);
	@fix = split('\|',$catalogV[$i]);
	$cat[20] = $fix[0]."00"; # RA
	$cat[21] = $fix[1]."00"; # DE
	print rHIP join('|', @cat);
}
close rHIP;