line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Catalog::Query::SIMBAD; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::Catalog::Query::SIMBAD - A query request to the SIMBAD database |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$sim = new Astro::Catalog::Query::SIMBAD( RA => $ra, |
10
|
|
|
|
|
|
|
Dec => $dec, |
11
|
|
|
|
|
|
|
Radius => $radius, |
12
|
|
|
|
|
|
|
Target => $target, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $catalog = $sim->querydb(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The module is an object orientated interface to the online SIMBAD |
20
|
|
|
|
|
|
|
database. Designed to return information on a single object. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Target name overrides RA/Dec. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The object will by default pick up the proxy information from the |
25
|
|
|
|
|
|
|
HTTP_PROXY and NO_PROXY environment variables, see the LWP::UserAgent |
26
|
|
|
|
|
|
|
documentation for details. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
See L for the catalog-independent methods. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
8491050
|
use 5.006; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
127
|
|
33
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
96
|
|
34
|
1
|
|
|
1
|
|
65
|
use warnings; |
|
1
|
|
|
|
|
78
|
|
|
1
|
|
|
|
|
143
|
|
35
|
1
|
|
|
1
|
|
7
|
use base qw/ Astro::Catalog::Transport::REST /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1259
|
|
36
|
|
|
|
|
|
|
use vars qw/ $VERSION /; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Carp; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# generic catalog objects |
41
|
|
|
|
|
|
|
use Astro::Coords; |
42
|
|
|
|
|
|
|
use Astro::Catalog; |
43
|
|
|
|
|
|
|
use Astro::Catalog::Star; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$VERSION = '4.31'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=begin __PRIVATE_METHODS__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 Private methods |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
These methods are for internal use only. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item B<_default_remote_host> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _default_remote_host { |
61
|
|
|
|
|
|
|
return "simbad.u-strasbg.fr"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item B<_default_url_path> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _default_url_path { |
69
|
|
|
|
|
|
|
return "sim-id.pl?"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B<_get_allowed_options> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns a hash with keys, being the internal options supported |
75
|
|
|
|
|
|
|
by this subclass, and values being the key name actually required |
76
|
|
|
|
|
|
|
by the remote system (and to be included in the query). |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _get_allowed_options { |
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
return ( |
83
|
|
|
|
|
|
|
ra => 'ra', |
84
|
|
|
|
|
|
|
dec => 'dec', |
85
|
|
|
|
|
|
|
object => 'Ident', |
86
|
|
|
|
|
|
|
radmax => 'Radius', |
87
|
|
|
|
|
|
|
nout => "output.max", |
88
|
|
|
|
|
|
|
bibyear1 => "Bibyear1", |
89
|
|
|
|
|
|
|
bibyear2 => "Bibyear2", |
90
|
|
|
|
|
|
|
_protocol => "protocol", |
91
|
|
|
|
|
|
|
_nbident => "NbIdent", |
92
|
|
|
|
|
|
|
_catall => "o.catall", |
93
|
|
|
|
|
|
|
_mesdisp => "output.mesdisp", |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
radunits => "Radius.unit", # arcsec, arcmin or deg |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# These should not be published |
98
|
|
|
|
|
|
|
# Since we need to switch to Astro::Coords |
99
|
|
|
|
|
|
|
_coordframe => "CooFrame", # FK5 or FK4 |
100
|
|
|
|
|
|
|
_coordepoch => "CooEpoch", # 2000 |
101
|
|
|
|
|
|
|
_coordequi => "CooEqui", # 2000 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
_frame1 => "Frame1", |
104
|
|
|
|
|
|
|
_equi1 => "Equi1", |
105
|
|
|
|
|
|
|
_epoch1 => "Epoch1", |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
_frame2 => "Frame2", |
108
|
|
|
|
|
|
|
_equi2 => "Equi2", |
109
|
|
|
|
|
|
|
_epoch2 => "Epoch2", |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
_frame3 => "Frame3", |
112
|
|
|
|
|
|
|
_equi3 => "Equi3", |
113
|
|
|
|
|
|
|
_epoch3 => "Epoch3", |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item B<_get_default_options> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Get the default query state. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _get_default_options { |
125
|
|
|
|
|
|
|
return ( |
126
|
|
|
|
|
|
|
# Target information |
127
|
|
|
|
|
|
|
ra => undef, |
128
|
|
|
|
|
|
|
dec => undef, |
129
|
|
|
|
|
|
|
object => undef, |
130
|
|
|
|
|
|
|
radmax => 0.1, |
131
|
|
|
|
|
|
|
radunits => "arcmin", # For consistency |
132
|
|
|
|
|
|
|
nout => "all", |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
_protocol => "html", |
135
|
|
|
|
|
|
|
_coordepoch => "2000", |
136
|
|
|
|
|
|
|
_coordequi => "2000", |
137
|
|
|
|
|
|
|
_coordframe => "FK5", |
138
|
|
|
|
|
|
|
_nbident => "around", |
139
|
|
|
|
|
|
|
_nbident => "around", |
140
|
|
|
|
|
|
|
_catall => "on", |
141
|
|
|
|
|
|
|
_mesdisp => "A", |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
bibyear1 => 1983, |
144
|
|
|
|
|
|
|
bibyear2 => 2003, |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Frame 1, 2 and 3 |
147
|
|
|
|
|
|
|
# Frame 1 FK5 2000/2000 |
148
|
|
|
|
|
|
|
_frame1 => "FK5", |
149
|
|
|
|
|
|
|
_equi1 => "2000.0", |
150
|
|
|
|
|
|
|
_epoch1 => "2000.0", |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Frame 2 FK4 1950/1950 |
153
|
|
|
|
|
|
|
_frame2 => "FK4", |
154
|
|
|
|
|
|
|
_equi2 => "1950.0", |
155
|
|
|
|
|
|
|
_epoch2 => "1950.0", |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Frame 3 Galactic |
158
|
|
|
|
|
|
|
_frame3 => "G", |
159
|
|
|
|
|
|
|
_equi3 => "2000.0", |
160
|
|
|
|
|
|
|
_epoch3 => "2000.0", |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item B<_parse_query> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Private function used to parse the results returned in a SIMBAD query. |
168
|
|
|
|
|
|
|
Should not be called directly. Instead use the querydb() assessor |
169
|
|
|
|
|
|
|
method to make and parse the results. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$cat = $q->_parse_query(); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns an Astro::Catalog object. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub _parse_query { |
178
|
|
|
|
|
|
|
my $self = shift; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# get a local copy of the current BUFFER |
181
|
|
|
|
|
|
|
my @buffer = split( /\n/,$self->{BUFFER}); |
182
|
|
|
|
|
|
|
chomp @buffer; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
#open my $fh, ">xxx.html"; |
185
|
|
|
|
|
|
|
#print $fh $self->{BUFFER}. "\n"; |
186
|
|
|
|
|
|
|
#close($fh); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# create an Astro::Catalog object to hold the search results |
189
|
|
|
|
|
|
|
my $catalog = new Astro::Catalog(); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# loop round the returned buffer |
192
|
|
|
|
|
|
|
my @target; # raw HTML lines, one per object |
193
|
|
|
|
|
|
|
foreach my $line ( 0 ... $#buffer ) { |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# NUMBER OF OBJECTS FOUND IN ERROR CIRCLE |
196
|
|
|
|
|
|
|
if ($buffer[$line] =~ /(\d+)\s+objects: <\/b>/i) { |
197
|
|
|
|
|
|
|
# Number of objects found |
198
|
|
|
|
|
|
|
my $number = $1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# GRAB EACH OBJECT - starting from 2 lines after the |
201
|
|
|
|
|
|
|
# current position (since that is the table header and |
202
|
|
|
|
|
|
|
# table separator |
203
|
|
|
|
|
|
|
@target = map { $buffer[$_] } ($line+2 ... $line+$number+1); |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# DROP OUT OF FIRST LOOP |
206
|
|
|
|
|
|
|
last; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# ...and stuff the contents into Object objects |
211
|
|
|
|
|
|
|
foreach my $line ( @target ) { |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# create a temporary place holder object |
214
|
|
|
|
|
|
|
my $star = new Astro::Catalog::Star(); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# split each line using the "pipe" symbol separating |
217
|
|
|
|
|
|
|
# the table columns |
218
|
|
|
|
|
|
|
my @separated = split( /\|/, $line ); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
# FRAME |
221
|
|
|
|
|
|
|
# ----- |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# grab the current co-ordinate frame from the query object itself |
224
|
|
|
|
|
|
|
# Assume J2000 for now. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# URL |
227
|
|
|
|
|
|
|
# --- |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# grab the url based on quotes around the string |
230
|
|
|
|
|
|
|
my $start_index = index( $separated[0], q/"/ ); |
231
|
|
|
|
|
|
|
my $last_index = rindex( $separated[0], q/"/ ); |
232
|
|
|
|
|
|
|
my $url = substr( $separated[0], $start_index+1, |
233
|
|
|
|
|
|
|
$last_index-$start_index-1); |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# push it into the object |
236
|
|
|
|
|
|
|
$star->moreinfo( $url ); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# NAME |
239
|
|
|
|
|
|
|
# ---- |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# get the object name from the same section |
242
|
|
|
|
|
|
|
my $final_index = rindex( $separated[0], "A" ); |
243
|
|
|
|
|
|
|
my $name = substr($separated[0],$last_index+2,$final_index-$last_index-4); |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# push it into the object |
246
|
|
|
|
|
|
|
$star->id( $name ); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# TYPE |
249
|
|
|
|
|
|
|
# ---- |
250
|
|
|
|
|
|
|
my $type = $separated[1]; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# dump leading spaces |
253
|
|
|
|
|
|
|
$type =~ s/^\s+//g; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# push it into the object |
256
|
|
|
|
|
|
|
$star->startype( $type ); |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# RA |
259
|
|
|
|
|
|
|
# -- |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# remove leading spaces |
262
|
|
|
|
|
|
|
my $coords = $separated[2]; |
263
|
|
|
|
|
|
|
$coords =~ s/^\s+//g; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# split the RA and Dec line into an array elements |
266
|
|
|
|
|
|
|
my @radec = split( /\s+/, $coords ); |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
# ...and then rebuild it |
269
|
|
|
|
|
|
|
my $ra; |
270
|
|
|
|
|
|
|
unless( $radec[2] =~ '\+' || $radec[2] =~ '-' ) { |
271
|
|
|
|
|
|
|
$ra = "$radec[0] $radec[1] $radec[2]"; |
272
|
|
|
|
|
|
|
} else { |
273
|
|
|
|
|
|
|
$ra = "$radec[0] $radec[1] 00.0"; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# DEC |
277
|
|
|
|
|
|
|
# --- |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
# ...and rebuild the Dec |
280
|
|
|
|
|
|
|
my $dec; |
281
|
|
|
|
|
|
|
unless ( $radec[2] =~ '\+' || $radec[2] =~ '-' ) { |
282
|
|
|
|
|
|
|
$dec = "$radec[3] $radec[4] $radec[5]"; |
283
|
|
|
|
|
|
|
} else { |
284
|
|
|
|
|
|
|
$dec = "$radec[2] $radec[3] 00.0"; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# Store the coordinates |
288
|
|
|
|
|
|
|
$star->coords( new Astro::Coords( name => $name, |
289
|
|
|
|
|
|
|
ra => $ra, |
290
|
|
|
|
|
|
|
dec => $dec, |
291
|
|
|
|
|
|
|
type => "J2000", |
292
|
|
|
|
|
|
|
units => "s", |
293
|
|
|
|
|
|
|
)); |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# SPECTRAL TYPE |
296
|
|
|
|
|
|
|
# ------------- |
297
|
|
|
|
|
|
|
my $spectral = $separated[4]; |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# remove leading and trailing spaces |
300
|
|
|
|
|
|
|
$spectral =~ s/^\s+//g; |
301
|
|
|
|
|
|
|
$spectral =~ s/\s+$//g; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# push it into the object |
304
|
|
|
|
|
|
|
$star->spectype($spectral); |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# Add the target object to the Astro::Catalog::Star object |
307
|
|
|
|
|
|
|
# --------------------------------------------------------- |
308
|
|
|
|
|
|
|
$catalog->pushstar( $star ); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
# Field centre? |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
# return the catalog |
314
|
|
|
|
|
|
|
return $catalog; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=item B<_translate_one_to_one> |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Return a list of internal options (as defined in C<_get_allowed_options>) |
321
|
|
|
|
|
|
|
that are known to support a one-to-one mapping of the internal value |
322
|
|
|
|
|
|
|
to the external value. |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
%one = $q->_translate_one_to_one(); |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Returns a hash with keys and no values (this makes it easy to |
327
|
|
|
|
|
|
|
check for the option). |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
This method also returns, the values from the parent class. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub _translate_one_to_one { |
334
|
|
|
|
|
|
|
my $self = shift; |
335
|
|
|
|
|
|
|
# convert to a hash-list |
336
|
|
|
|
|
|
|
return ($self->SUPER::_translate_one_to_one, |
337
|
|
|
|
|
|
|
map { $_, undef }(qw/ |
338
|
|
|
|
|
|
|
bibyear1 bibyear2 radunits |
339
|
|
|
|
|
|
|
_protocol _catall _mesdisp _nbident |
340
|
|
|
|
|
|
|
_coordepoch _coordequi _coordframe |
341
|
|
|
|
|
|
|
_epoch1 _frame1 _equi1 |
342
|
|
|
|
|
|
|
_epoch2 _frame2 _equi2 |
343
|
|
|
|
|
|
|
_epoch3 _frame3 _equi3 |
344
|
|
|
|
|
|
|
/) |
345
|
|
|
|
|
|
|
); |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=end __PRIVATE_METHODS__ |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=head1 REVISION |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
$Id: SIMBAD.pm,v 1.2 2003/09/25 11:38:50 aa Exp $ |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=head1 SEE ALSO |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
L, L, L. |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
Derived from L on CPAN. |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=head1 COPYRIGHT |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
Copyright (C) 2001-2003 University of Exeter. All Rights Reserved. |
364
|
|
|
|
|
|
|
Some modifications copyright (C) 2003 Particle Physics and Astronomy |
365
|
|
|
|
|
|
|
Research Council. All Rights Reserved. |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
This program was written as part of the eSTAR project and is free software; |
368
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the terms of the GNU Public |
369
|
|
|
|
|
|
|
License. |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head1 AUTHORS |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE, |
374
|
|
|
|
|
|
|
Tim Jenness Etjenness@cpan.orgE |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=cut |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
1; |