charm2simbatch.pl
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:1k
- #!/usr/bin/perl
- # Builds a SIMBATCH script to get HIP identifiers for CHARM2 stars
- # should be run in the same folder as charm2.dat
- open CHARM2, '<', 'charm2.dat' or die "Could not open file charm2.datn";
- %Sources = ();
- %SAOs = ();
- while($curLine = <CHARM2>) {
- chomp $curLine;
- next if($curLine eq '');
- $Type = Trim(substr($curLine, 25, 4));
- next if($Type eq 'UR');
- $UD = Trim(substr($curLine, 143, 6));
- $LD = Trim(substr($curLine, 162, 6));
- next if(($UD eq '') && ($LD eq ''));
- @Ids = (
- Trim(substr($curLine, 30, 24)),
- Trim(substr($curLine, 54, 24)),
- Trim(substr($curLine, 79, 24)),
- Trim(substr($curLine, 104, 24))
- );
- $Source = $Ids[$0];
- $Source =~ s/s//g;
- if(!exists $Sources{$Source}) {
- $numStars++;
- $Sources{$Source} = $Ids[$0];
- } else {
- $Sources{$Source} = $Ids[$0] if($Source ne $Ids[$0]);
- }
- }
- close CHARM2;
- open SIMSCRIPT, '>', 'charm2.simbatch' or die "Could not write script file to charm2.simbatchn";
- open IDLIST, '>', 'idlist.txt' or die "Could not write identifiers list to idlist.txtn";
- print SIMSCRIPT "format obj "%IDLIST(S;HIP)\n"nn";
- foreach $s (sort keys %Sources) {
- print SIMSCRIPT "$Sources{$s}n";
- print IDLIST "$sn";
- }
- close SIMSCRIPT;
- close IDLIST;
- sub Trim {
- $st = shift;
- $st =~ s/^s+//;
- $st =~ s/s+$//;
- return $st;
- }