File indexing completed on 2024-09-08 03:28:58
0001 #!/usr/bin/perl 0002 0003 use strict; 0004 0005 use Math::Trig qw/pi great_circle_distance/; 0006 use Getopt::Long; 0007 0008 my $CULL = 0.007; 0009 0010 my $ME = $0; $ME =~ s{.*/}{}; 0011 my $USAGE = <<USAGE; 0012 Usage: $ME <options> file 0013 Options: 0014 -c --cull X Cull points less than X radians apart (default: $CULL). 0015 -h --help Show this message. 0016 USAGE 0017 0018 @ARGV or die $USAGE; 0019 0020 GetOptions( 0021 "help" => sub { print $USAGE; exit}, 0022 "cull=f" => \$CULL, 0023 ) or die $USAGE; 0024 0025 0026 my ($ref, $last, $lastRa, $lastDec); 0027 0028 while (<>) { 0029 chomp; 0030 m/^#/ and next; 0031 m/^:(\w*)/ and do { 0032 $ref = $last = undef; 0033 print "$1\n"; 0034 next; 0035 }; 0036 m/(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(\d)/ or do { 0037 warn "Warning: line format? : $_"; 0038 }; 0039 my ($ra, $dec, $flag) = ($1, $2, $3); 0040 #print "[$ra] [$dec]\n"; 0041 my $point = [$ra, $dec]; 0042 0043 if ( defined $ref ) { 0044 my $dist = distance( $point, $ref); 0045 my $dRa = ($ra - $lastRa) * 15 * cos($dec); 0046 my $dDec = $dec - $lastDec; 0047 my $dir = atan2( $dDec, $dRa ) * 180. / pi; 0048 $dir < 0.0 and $dir += 360.0; 0049 printf( "%4d: %d %6.3f %6.3f %6.3f %7.3f \n", 0050 $., $flag, $dist, $dRa, $dDec, $dir ); 0051 } 0052 #$dist < $CULL and not $NODES{"$ra $dec"} and do { 0053 # #printf "CULL: $_ %6.4f\n", $dist; 0054 # $last = $_; 0055 # next; 0056 #}; 0057 #$dist > $SKIP and do { 0058 # $last and print "$last\n"; 0059 # s/^D/S/; # mark point to skip 0060 #}; 0061 0062 #print "$_\n"; 0063 #printf "$_ %6.4f\n", $dist; 0064 $last = $point; 0065 $ref = $point; 0066 $lastRa = $ra; 0067 $lastDec = $dec; 0068 } 0069 0070 sub distance { 0071 my ($p1, $p2) = @_; 0072 return 15 * great_circle_distance( 0073 $$p1[0] * pi / 12, 0074 pi/2 - $$p1[1] * pi / 180, 0075 $$p2[0] * pi / 12, 0076 pi/2 - $$p2[1] * pi / 180,); 0077 } 0078