| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::GCN::Util; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
GCN::Util - utility routines |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use GCN::Util |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module contains a simple utility routines which are mission independant. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
7441
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
71
|
|
|
18
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
78
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
require Exporter; |
|
21
|
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
9
|
use vars qw/$VERSION @EXPORT_OK @ISA /; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1662
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
|
25
|
|
|
|
|
|
|
@EXPORT_OK = qw/ convert_ra_to_sextuplets |
|
26
|
|
|
|
|
|
|
convert_dec_to_sextuplets |
|
27
|
|
|
|
|
|
|
convert_burst_error_to_arcmin |
|
28
|
|
|
|
|
|
|
convert_ra_to_degrees |
|
29
|
|
|
|
|
|
|
convert_dec_to_degrees |
|
30
|
|
|
|
|
|
|
convert_burst_error_to_degrees /; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
'$Revision: 1.1.1.1 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub convert_ra_to_sextuplets { |
|
36
|
0
|
|
|
0
|
0
|
|
my $ra = shift; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# convert RA to sextuplets |
|
39
|
0
|
|
|
|
|
|
print "Converting R.A. to sextuplets...\n"; |
|
40
|
0
|
|
|
|
|
|
my $ra_deg = $ra/10000.0; |
|
41
|
0
|
|
|
|
|
|
$ra_deg = $ra_deg/15.0; |
|
42
|
0
|
|
|
|
|
|
my $period = index( $ra_deg, "."); |
|
43
|
0
|
|
|
|
|
|
my $length = length( $ra_deg ); |
|
44
|
0
|
|
|
|
|
|
my $ra_min = substr( $ra_deg, -($length-$period-1)); |
|
45
|
0
|
|
|
|
|
|
$ra_min = "0." . $ra_min; |
|
46
|
0
|
|
|
|
|
|
$ra_min = $ra_min*60.0; |
|
47
|
0
|
|
|
|
|
|
$ra_deg = substr( $ra_deg, 0, $period); |
|
48
|
0
|
|
|
|
|
|
$period = index( $ra_min, "."); |
|
49
|
0
|
|
|
|
|
|
$length = length( $ra_min ); |
|
50
|
0
|
|
|
|
|
|
my $ra_sec = substr( $ra_min, -($length-$period-1)); |
|
51
|
0
|
|
|
|
|
|
$ra_sec = "0." . $ra_sec; |
|
52
|
0
|
|
|
|
|
|
$ra_sec = $ra_sec*60.0; |
|
53
|
0
|
|
|
|
|
|
$ra_min = substr( $ra_min, 0, $period); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$ra = "$ra_deg $ra_min $ra_sec"; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $ra; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub convert_dec_to_sextuplets { |
|
61
|
0
|
|
|
0
|
0
|
|
my $dec = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
print "Converting Declination to sextuplets...\n"; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# repack Dec |
|
66
|
0
|
|
|
|
|
|
print "Repacking declination into a big-endian long...\n"; |
|
67
|
0
|
|
|
|
|
|
$dec = pack("N", $dec ); |
|
68
|
0
|
|
|
|
|
|
print "Repacking declination into a small-endian long...\n"; |
|
69
|
0
|
|
|
|
|
|
$dec = pack("V", unpack( "N", $dec ) ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$dec = unpack( "l", $dec); |
|
72
|
0
|
|
|
|
|
|
print "Unpacking to signed long integer ($dec)...\n"; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# convert Dec to sextuplets |
|
75
|
0
|
|
|
|
|
|
print "Converting to sextuplets...\n"; |
|
76
|
0
|
|
|
|
|
|
my $dec_deg = $dec; |
|
77
|
0
|
|
|
|
|
|
$dec_deg = $dec_deg/10000.0; |
|
78
|
0
|
|
|
|
|
|
my $sign = "pos"; |
|
79
|
0
|
0
|
|
|
|
|
if ( $dec_deg =~ "-" ) { |
|
80
|
0
|
|
|
|
|
|
$dec_deg =~ s/-//; |
|
81
|
0
|
|
|
|
|
|
$sign = "neg"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
|
|
|
|
|
my $period = index( $dec_deg, "."); |
|
84
|
0
|
|
|
|
|
|
my $length = length( $dec_deg ); |
|
85
|
0
|
|
|
|
|
|
my $dec_min = substr( $dec_deg, -($length-$period-1)); |
|
86
|
0
|
|
|
|
|
|
$dec_min = "0." . $dec_min; |
|
87
|
0
|
|
|
|
|
|
$dec_min = $dec_min*60.0; |
|
88
|
0
|
|
|
|
|
|
$dec_deg = substr( $dec_deg, 0, $period); |
|
89
|
0
|
|
|
|
|
|
$period = index( $dec_min, "."); |
|
90
|
0
|
|
|
|
|
|
$length = length( $dec_min ); |
|
91
|
0
|
|
|
|
|
|
my $dec_sec = substr( $dec_min, -($length-$period-1)); |
|
92
|
0
|
|
|
|
|
|
$dec_sec = "0." . $dec_sec; |
|
93
|
0
|
|
|
|
|
|
$dec_sec = $dec_sec*60.0; |
|
94
|
0
|
|
|
|
|
|
$dec_min = substr( $dec_min, 0, $period); |
|
95
|
0
|
0
|
|
|
|
|
if( $sign eq "neg" ) { |
|
96
|
0
|
|
|
|
|
|
$dec_deg = "-" . $dec_deg; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
$dec = "$dec_deg $dec_min $dec_sec"; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $dec; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub convert_burst_error_to_arcmin { |
|
105
|
0
|
|
|
0
|
0
|
|
my $error = shift; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
print "Converting error to arcminutes...\n"; |
|
108
|
0
|
|
|
|
|
|
$error = ($error*60.0)/10000.0; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return $error; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub convert_ra_to_degrees { |
|
114
|
0
|
|
|
0
|
0
|
|
my $ra = shift; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# convert RA to sextuplets |
|
117
|
0
|
|
|
|
|
|
print "Converting R.A. to sextuplets...\n"; |
|
118
|
0
|
|
|
|
|
|
my $ra_deg = $ra/10000.0; |
|
119
|
0
|
|
|
|
|
|
$ra_deg = $ra_deg/15.0; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $ra_deg; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub convert_dec_to_degrees { |
|
126
|
0
|
|
|
0
|
0
|
|
my $dec = shift; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
print "Converting Declination to sextuplets...\n"; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# repack Dec |
|
131
|
0
|
|
|
|
|
|
print "Repacking declination into a big-endian long...\n"; |
|
132
|
0
|
|
|
|
|
|
$dec = pack("N", $dec ); |
|
133
|
0
|
|
|
|
|
|
print "Repacking declination into a small-endian long...\n"; |
|
134
|
0
|
|
|
|
|
|
$dec = pack("V", unpack( "N", $dec ) ); |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
$dec = unpack( "l", $dec); |
|
137
|
0
|
|
|
|
|
|
print "Unpacking to signed long integer ($dec)...\n"; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# convert Dec to sextuplets |
|
140
|
0
|
|
|
|
|
|
print "Converting to sextuplets...\n"; |
|
141
|
0
|
|
|
|
|
|
my $dec_deg = $dec; |
|
142
|
0
|
|
|
|
|
|
$dec_deg = $dec_deg/10000.0; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return $dec_deg; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub convert_burst_error_to_degrees { |
|
148
|
0
|
|
|
0
|
0
|
|
my $error = shift; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
print "Converting error to arcminutes...\n"; |
|
151
|
0
|
|
|
|
|
|
$error = $error/10000.0; |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return $error; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 REVISION |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
$Id: Util.pm,v 1.1.1.1 2005/05/03 19:23:00 voevent Exp $ |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHORS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Copyright (C) 2003 Particle Physics and Astronomy Research |
|
170
|
|
|
|
|
|
|
Council. All Rights Reserved. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |