line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Coords::Interpolated; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Astro::Coords::Interpolated - Specify astronomical coordinates using two reference positions |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$c = new Astro::Coords::Interpolated( ra1 => '05:22:56', |
11
|
|
|
|
|
|
|
dec1 => '-26:20:44.4', |
12
|
|
|
|
|
|
|
mjd1 => 52440.5, |
13
|
|
|
|
|
|
|
ra2 => '05:23:56', |
14
|
|
|
|
|
|
|
dec2 => '-26:20:50.4', |
15
|
|
|
|
|
|
|
mjd2 => 52441.5,); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This class is used by C<Astro::Coords> for handling coordinates |
20
|
|
|
|
|
|
|
for moving sources specified as two coordinates at two epochs. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
19
|
|
|
19
|
|
2050967
|
use 5.006; |
|
19
|
|
|
|
|
104
|
|
25
|
19
|
|
|
19
|
|
121
|
use strict; |
|
19
|
|
|
|
|
64
|
|
|
19
|
|
|
|
|
483
|
|
26
|
19
|
|
|
19
|
|
95
|
use warnings; |
|
19
|
|
|
|
|
82
|
|
|
19
|
|
|
|
|
1124
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
29
|
|
|
|
|
|
|
|
30
|
19
|
|
|
19
|
|
122
|
use base qw/ Astro::Coords /; |
|
19
|
|
|
|
|
50
|
|
|
19
|
|
|
|
|
3162
|
|
31
|
|
|
|
|
|
|
|
32
|
19
|
|
|
19
|
|
137
|
use overload '""' => "stringify"; |
|
19
|
|
|
|
|
42
|
|
|
19
|
|
|
|
|
134
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 Constructor |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item B<new> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Instantiate a new object using the supplied options. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$c = new Astro::Coords::Interpolated( ra1 => '05:22:56', |
45
|
|
|
|
|
|
|
dec1 => '-26:20:44.4', |
46
|
|
|
|
|
|
|
mjd1 => 52440.5, |
47
|
|
|
|
|
|
|
ra2 => '05:23:56', |
48
|
|
|
|
|
|
|
dec2 => '-26:20:50.4', |
49
|
|
|
|
|
|
|
mjd2 => 52441.5, |
50
|
|
|
|
|
|
|
units => |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns undef on error. The positions are assumed to be apparent |
54
|
|
|
|
|
|
|
RA/Dec for the telescope location. Units are optional (see |
55
|
|
|
|
|
|
|
C<Astro::Coords::Equatorial>). |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
60
|
4
|
|
|
4
|
1
|
12
|
my $proto = shift; |
61
|
4
|
|
33
|
|
|
24
|
my $class = ref($proto) || $proto; |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
17
|
my %args = @_; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Sanity check |
66
|
4
|
|
|
|
|
13
|
for (qw/ ra1 dec1 mjd1 ra2 dec2 mjd2 /) { |
67
|
24
|
50
|
|
|
|
54
|
return undef unless exists $args{$_}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
4
|
100
|
|
|
|
22
|
my ($unit_c1, $unit_c2) = (ref $args{'units'}) ? @{$args{'units'}} : ($args{'units'}) x 2; |
|
1
|
|
|
|
|
3
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Convert input args to objects |
73
|
4
|
|
|
|
|
20
|
$args{ra1} = new Astro::Coords::Angle::Hour($args{ra1}, units => $unit_c1, |
74
|
|
|
|
|
|
|
range => '2PI' ); |
75
|
4
|
|
|
|
|
14
|
$args{dec1} = new Astro::Coords::Angle($args{dec1}, units => $unit_c2 ); |
76
|
4
|
|
|
|
|
18
|
$args{ra2} = new Astro::Coords::Angle::Hour($args{ra2}, units => $unit_c1, |
77
|
|
|
|
|
|
|
range => '2PI' ); |
78
|
4
|
|
|
|
|
15
|
$args{dec2} = new Astro::Coords::Angle($args{dec2}, units => $unit_c2 ); |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
20
|
return bless \%args, $class; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 Accessor Methods |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item B<ra1> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Apparent Right Ascension of first reference position. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$ra = $c->ra1( %opts ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See L<Astro::Coords/"NOTES"> for details on the supported format |
98
|
|
|
|
|
|
|
specifiers and default calling convention. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub ra1 { |
103
|
3
|
|
|
3
|
1
|
14
|
my $self = shift; |
104
|
3
|
|
|
|
|
91
|
my %opt = @_; |
105
|
3
|
|
|
|
|
53
|
my $retval = $self->{ra1}->in_format( $opt{format} ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Tidy up array |
108
|
3
|
50
|
|
|
|
14
|
shift(@$retval) if ref($retval) eq "ARRAY"; |
109
|
3
|
|
|
|
|
16
|
return $retval; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item B<dec1> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Apparent declination of first reference position. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$dec = $c->dec1( format => "sexagesimal" ); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
See L<Astro::Coords/"NOTES"> for details on the supported format |
119
|
|
|
|
|
|
|
specifiers and default calling convention. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub dec1 { |
124
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
125
|
3
|
|
|
|
|
11
|
my %opt = @_; |
126
|
3
|
|
|
|
|
14
|
return $self->{dec1}->in_format( $opt{format} ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item B<mjd1> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Time (MJD) when the first reference position was valid. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub mjd1 { |
136
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
137
|
2
|
|
|
|
|
5
|
return $self->{mjd1}; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item B<ra2> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Apparent Right Ascension of second reference position. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$ra = $c->ra2( format => 'rad' ); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
See L<Astro::Coords/"NOTES"> for details on the supported format |
147
|
|
|
|
|
|
|
specifiers and default calling convention. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub ra2 { |
152
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
153
|
3
|
|
|
|
|
7
|
my %opt = @_; |
154
|
3
|
|
|
|
|
74
|
my $retval = $self->{ra2}->in_format( $opt{format} ); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Tidy up array |
157
|
3
|
50
|
|
|
|
14
|
shift(@$retval) if ref($retval) eq "ARRAY"; |
158
|
3
|
|
|
|
|
13
|
return $retval; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item B<dec2> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Apparent declination of second reference position. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
$dec = $c->dec2( format => "sexagesimal" ); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
See L<Astro::Coords/"NOTES"> for details on the supported format |
168
|
|
|
|
|
|
|
specifiers and default calling convention. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub dec2 { |
173
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
174
|
3
|
|
|
|
|
8
|
my %opt = @_; |
175
|
3
|
|
|
|
|
14
|
return $self->{dec2}->in_format( $opt{format} ); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item B<mjd2> |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Time (MJD) when the second reference position was valid. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub mjd2 { |
185
|
2
|
|
|
2
|
1
|
15
|
my $self = shift; |
186
|
2
|
|
|
|
|
7
|
return $self->{mjd2}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 General Methods |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=over 4 |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item B<array> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Return back 11 element array with first element containing the |
198
|
|
|
|
|
|
|
string "INTERP", the next ten elements as undef. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This method returns a standardised set of elements across all |
201
|
|
|
|
|
|
|
types of coordinates. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
The original design did not contain this type of coordinate specification |
204
|
|
|
|
|
|
|
and so the array returned can not yet include it. Needs more work to integrate |
205
|
|
|
|
|
|
|
into the other coordinate systems. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub array { |
210
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
211
|
0
|
|
|
|
|
0
|
return ( $self->type, undef, undef, |
212
|
|
|
|
|
|
|
undef,undef,undef,undef,undef,undef,undef,undef); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item B<type> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Returns the generic type associated with the coordinate system. |
218
|
|
|
|
|
|
|
For this class the answer is always "INTERP". |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This is used to aid construction of summary tables when using |
221
|
|
|
|
|
|
|
mixed coordinates. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
It could be done using isa relationships. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub type { |
228
|
0
|
|
|
0
|
1
|
0
|
return "INTERP"; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item B<stringify> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Stringify overload. Just returns the type. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub stringify { |
238
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
239
|
0
|
|
|
|
|
0
|
return $self->type; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item B<summary> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Return a one line summary of the coordinates. |
245
|
|
|
|
|
|
|
In the future will accept arguments to control output. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
$summary = $c->summary(); |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub summary { |
252
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
253
|
0
|
|
|
|
|
0
|
my $name = $self->name; |
254
|
0
|
0
|
|
|
|
0
|
$name = '' unless defined $name; |
255
|
0
|
|
|
|
|
0
|
return sprintf("%-16s %-12s %-13s INTERP",$name,'',''); |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item B<apparent> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Return the apparent RA and Dec (as two C<Astro::Coords::Angle> objects) for the current |
261
|
|
|
|
|
|
|
coordinates and time. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
($ra,$dec) = $c->apparent(); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Apparent RA/Dec is obtained by linear interpolation from the reference |
266
|
|
|
|
|
|
|
positions. If the requested time lies outside the reference times |
267
|
|
|
|
|
|
|
the position will be extrapolated. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub apparent { |
272
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
273
|
|
|
|
|
|
|
|
274
|
2
|
|
|
|
|
7
|
my $mjd1 = $self->mjd1; |
275
|
2
|
|
|
|
|
9
|
my $mjd2 = $self->mjd2; |
276
|
|
|
|
|
|
|
|
277
|
2
|
|
|
|
|
6
|
my ($ra_app, $dec_app); |
278
|
|
|
|
|
|
|
|
279
|
2
|
100
|
|
|
|
8
|
if ($mjd1 == $mjd2) { |
280
|
|
|
|
|
|
|
# special case when times are identical |
281
|
|
|
|
|
|
|
|
282
|
1
|
|
|
|
|
4
|
$ra_app = $self->{ra1}; |
283
|
1
|
|
|
|
|
2
|
$dec_app = $self->{dec1}; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
else { |
286
|
|
|
|
|
|
|
# else linear interpolation |
287
|
|
|
|
|
|
|
|
288
|
1
|
|
|
|
|
4
|
my $mjd = $self->datetime->mjd; |
289
|
1
|
|
|
|
|
43
|
my $ra1 = $self->ra1->radians; |
290
|
1
|
|
|
|
|
6
|
my $ra2 = $self->ra2->radians; |
291
|
1
|
|
|
|
|
5
|
my $dec1 = $self->dec1->radians; |
292
|
1
|
|
|
|
|
5
|
my $dec2 = $self->dec2->radians; |
293
|
|
|
|
|
|
|
|
294
|
1
|
|
|
|
|
4
|
$ra_app = $ra1 + ( $ra2 - $ra1 ) * ( $mjd - $mjd1 ) / ( $mjd2 - $mjd1 ); |
295
|
1
|
|
|
|
|
5
|
$dec_app = $dec1 + ( $dec2 - $dec1 ) * ( $mjd - $mjd1 ) / ( $mjd2 - $mjd1 ); |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
2
|
|
|
|
|
10
|
$ra_app = new Astro::Coords::Angle::Hour($ra_app, units => 'rad', range => '2PI'); |
299
|
2
|
|
|
|
|
10
|
$dec_app = new Astro::Coords::Angle($dec_app, units => 'rad'); |
300
|
|
|
|
|
|
|
|
301
|
2
|
|
|
|
|
16
|
$self->_cache_write( "RA_APP" => $ra_app, "DEC_APP" => $dec_app ); |
302
|
|
|
|
|
|
|
|
303
|
2
|
|
|
|
|
7
|
return ($ra_app, $dec_app); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=item B<apply_offset> |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Overrided method to warn if C<Astro::Coords::apply_offset> is |
309
|
|
|
|
|
|
|
called on this subclass. |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub apply_offset { |
314
|
1
|
|
|
1
|
1
|
17
|
my $self = shift; |
315
|
1
|
|
|
|
|
11
|
warn "apply_offset: applying offset to interpolated position for a specific time.\n"; |
316
|
1
|
|
|
|
|
17
|
return $self->SUPER::apply_offset(@_); |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=back |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=head1 NOTES |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
Usually called via C<Astro::Coords>. This is the coordinate style |
324
|
|
|
|
|
|
|
used by SCUBA for non-sidereal sources instead of using orbital elements. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Apparent RA/Decs suitable for use in this class can be obtained |
327
|
|
|
|
|
|
|
from http://ssd.jpl.nasa.gov/. |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head1 SEE ALSO |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
L<Astro::Coords::Elements> |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Does not use any external PAL routines. |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=head1 AUTHOR |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
Tim Jenness E<lt>tjenness@cpan.orgE<gt> |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head1 COPYRIGHT |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
Copyright (C) 2012 Science and Technology Facilities Council. |
344
|
|
|
|
|
|
|
Copyright (C) 2001-2005 Particle Physics and Astronomy Research Council. |
345
|
|
|
|
|
|
|
All Rights Reserved. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
348
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
349
|
|
|
|
|
|
|
Foundation; either version 3 of the License, or (at your option) any later |
350
|
|
|
|
|
|
|
version. |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
353
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
354
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
357
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
358
|
|
|
|
|
|
|
Place,Suite 330, Boston, MA 02111-1307, USA |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=cut |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
1; |