Perl script to build cross-index files from SIMBAD data.
parent
9774ae1d8b
commit
a55877d9d5
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# buildcrossidx.pl by Andrew Tribick
|
||||
# version 1.0 - 2008-08-26
|
||||
|
||||
open XIDS, '<', 'crossids.txt';
|
||||
|
||||
@HDtoHIP = ();
|
||||
@HDlevels = ();
|
||||
@SAOtoHIP = ();
|
||||
|
||||
while($curLine = <XIDS>) {
|
||||
chomp $curLine;
|
||||
|
||||
# get Hipparcos designation
|
||||
$HIP = '';
|
||||
$HIP = $2 if($curLine =~ m/(^|:)HIP ([0-9]+)(:|$)/);
|
||||
next if($HIP eq ''); # ignore entries which are not Hipparcos stars
|
||||
|
||||
@dList = split(/:/, $curLine);
|
||||
for($i = 0; $i <= $#dList; $i++) {
|
||||
# no component identifiers on SAO designations - makes things easy...
|
||||
$SAOtoHIP{$1} = $HIP if($dList[$i] =~ m/^SAO ([0-9]+)$/);
|
||||
|
||||
# only use HD designations with component identifiers A,J or none
|
||||
if($dList[$i] =~ m/^HD ([0-9]+)([AJ]?)$/) {
|
||||
$HDnum = $1;
|
||||
$Level = HDlevel($2);
|
||||
if(!exists($HDtoHIP{$HDnum})) {
|
||||
# if this HD number is not already assigned, add it to list
|
||||
$HDtoHIP{$HDnum} = $HIP;
|
||||
$HDlevels{$HDnum} = $Level;
|
||||
} elsif($Level > $HDlevels{$HDnum}) {
|
||||
# otherwise we prefer A over none over J.
|
||||
$HDtoHIP{$HDnum} = $HIP;
|
||||
$HDlevels{$HDnum} = $Level;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close XIDS;
|
||||
|
||||
# write out HD index file
|
||||
open HDX, '>', 'hdxindex.dat';
|
||||
binmode HDX;
|
||||
print HDX pack('a8S', 'CELINDEX', 0x0100);
|
||||
foreach $HD (sort { $a <=> $b } keys %HDtoHIP) {
|
||||
print HDX pack('LL', $HD, $HDtoHIP{$HD});
|
||||
}
|
||||
close HDX;
|
||||
|
||||
# write out SAO index file
|
||||
open SAOX, '>', 'saoxindex.dat';
|
||||
binmode SAOX;
|
||||
print SAOX pack('a8S', 'CELINDEX', 0x0100);
|
||||
foreach $SAO (sort { $a <=> $b } keys %SAOtoHIP) {
|
||||
print SAOX pack('LL', $SAO, $SAOtoHIP{$SAO});
|
||||
}
|
||||
close SAOX;
|
||||
|
||||
# ---END OF MAIN PROGRAM---
|
||||
|
||||
sub HDlevel {
|
||||
# return a score based on component identifier
|
||||
my $d = shift;
|
||||
return 0 if($d eq 'J');
|
||||
return 1 if($d eq '');
|
||||
return 2 if($d eq 'A');
|
||||
return -999;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
BUILDXINDICES.PL
|
||||
|
||||
This script builds the HD and SAO cross-indices (hdxindex.dat and
|
||||
saoxindex.dat). It takes as its input a file containing a colon-separated list
|
||||
of star designations called crossids.txt. Each star's designations should be on
|
||||
one line. This file can be created using script queries to the SIMBAD database
|
||||
(SIMBATCH, at http://simbad.u-strasbg.fr/simbad/sim-fscript).
|
||||
|
||||
Because of the limited number of output rows, the crossids.txt file must be
|
||||
assembled from the results of several SIMBATCH queries. It is probably best to
|
||||
use a query size of 20000. For example, to return all stars with HIP IDs
|
||||
between 20000 and 39999, the following SIMBATCH script may be used:
|
||||
|
||||
format object "%IDLIST[%*(S):]"
|
||||
set limit 20000
|
||||
query id wildcard HIP [23]????
|
||||
|
||||
The header of each returned file should be discarded. The resultant files can
|
||||
then be concatenated to produce the crossids.txt file.
|
Loading…
Reference in New Issue