line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Catalog::IO::Northstar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::Catalog::IO::Northstar - NorthStar format catalogue parser |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$cat = Astro::Catalog::IO::Northstar->_read_catalog( \@lines ); |
10
|
|
|
|
|
|
|
$arrref = Astro::Catalog::IO::Northstar->_write_catalog( $cat, %options ); |
11
|
|
|
|
|
|
|
$filename = Astro::Catalog::IO::Northstar->_default_file(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class provides read and write methods for catalogues in the |
16
|
|
|
|
|
|
|
format used by the NorthStar proposal submission system. The methods |
17
|
|
|
|
|
|
|
are not public and should, in general, only be called from the |
18
|
|
|
|
|
|
|
C C and C methods. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
3002867
|
use 5.006; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
109
|
|
23
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
115
|
|
24
|
1
|
|
|
1
|
|
74
|
use warnings::register; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
398
|
|
25
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
267
|
|
26
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
964
|
use Astro::Telescope; |
|
1
|
|
|
|
|
19479
|
|
|
1
|
|
|
|
|
74
|
|
29
|
1
|
|
|
1
|
|
548
|
use Astro::Coords; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Astro::Catalog; |
31
|
|
|
|
|
|
|
use Astro::Catalog::Star; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use base qw/ Astro::Catalog::IO::ASCII /; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use vars qw/$VERSION $DEBUG /; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$VERSION = '4.31'; |
38
|
|
|
|
|
|
|
$DEBUG = 0; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item B<_read_catalog> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Parses the catalogue lines and returns a new C |
47
|
|
|
|
|
|
|
object containing the catalog entries. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$cat = Astro::Catalog::IO::Northstar->_read_catalog( \@lines, %options ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Supported options (with defaults) are: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
telescope => Name of telescope to associate with each coordinate entry |
54
|
|
|
|
|
|
|
(defaults to JCMT). If the telescope option is specified |
55
|
|
|
|
|
|
|
but is undef or empty string, no telescope is used. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _read_catalog { |
60
|
|
|
|
|
|
|
my $class = shift; |
61
|
|
|
|
|
|
|
my $lines = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Default options |
64
|
|
|
|
|
|
|
my %defaults = ( telescope => 'JCMT', |
65
|
|
|
|
|
|
|
incplanets => 1); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my %options = (%defaults, @_); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
croak "Must supply catalogue contents as a reference to an array" |
70
|
|
|
|
|
|
|
unless ref($lines) eq 'ARRAY'; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Create a new telescope to associate with this |
73
|
|
|
|
|
|
|
my $tel; |
74
|
|
|
|
|
|
|
$tel = new Astro::Telescope( $options{telescope} ) |
75
|
|
|
|
|
|
|
if $options{telescope}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Go through each line and parse it |
78
|
|
|
|
|
|
|
my @stars; |
79
|
|
|
|
|
|
|
for my $line (@$lines) { |
80
|
|
|
|
|
|
|
$line =~ s/^\s*//; |
81
|
|
|
|
|
|
|
$line =~ s/\s*$//; |
82
|
|
|
|
|
|
|
next unless $line =~ /\w/; |
83
|
|
|
|
|
|
|
my ($name, $c1, $c2, $system, $comment) = split (/\s+/,$line,5); |
84
|
|
|
|
|
|
|
next unless (defined $c1 && defined $c2 && defined $system); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# skip "OTHER" since we do not know what to do with it |
87
|
|
|
|
|
|
|
next if $system =~ /other/i; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my ($ctype1, $ctype2); |
90
|
|
|
|
|
|
|
if ($system =~ /gal/i) { |
91
|
|
|
|
|
|
|
$ctype1 = "long"; |
92
|
|
|
|
|
|
|
$ctype2 = "lat"; |
93
|
|
|
|
|
|
|
} else { |
94
|
|
|
|
|
|
|
$ctype1 = "ra"; |
95
|
|
|
|
|
|
|
$ctype2 = "dec"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $c = new Astro::Coords( $ctype1 => $c1, |
99
|
|
|
|
|
|
|
$ctype2 => $c2, |
100
|
|
|
|
|
|
|
type => $system, |
101
|
|
|
|
|
|
|
name => $name, |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
$c->telescope($tel) if defined $tel; |
104
|
|
|
|
|
|
|
$c->comment($comment) if (defined $comment && $comment =~ /\w/); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Field name should simply be linked to the telescope |
107
|
|
|
|
|
|
|
my $field = (defined $tel ? $tel->name : '' ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# now need the Item |
110
|
|
|
|
|
|
|
my $item = new Astro::Catalog::Item( id => $name, |
111
|
|
|
|
|
|
|
field => $field, |
112
|
|
|
|
|
|
|
coords => $c, |
113
|
|
|
|
|
|
|
comment => $comment ); |
114
|
|
|
|
|
|
|
push(@stars, $item); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
return Astro::Catalog->new( Stars => \@stars, Origin => 'NorthStar' ); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NOTES |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The NorthStar (http://proposal.astron.nl) catalogue format is: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
TargetName hh:mm:ss dd:mm:ss system misc |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
TargetName can not include spaces. The "system" should be "J2000", |
131
|
|
|
|
|
|
|
"B1950", "Jxxxx", "Bxxxx" or "GALACTIC". |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The misc field will be stored as a comment. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 GLOBAL VARIABLES |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The following global variables can be modified to control the state of the |
139
|
|
|
|
|
|
|
module: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over 4 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item $DEBUG |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Controls debugging messages. Default state is false. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright (C) 2007 Particle Physics and Astronomy Research Council. |
152
|
|
|
|
|
|
|
All Rights Reserved. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
155
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
156
|
|
|
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later |
157
|
|
|
|
|
|
|
version. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
160
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
161
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
164
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
165
|
|
|
|
|
|
|
Place,Suite 330, Boston, MA 02111-1307, USA |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHORS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Tim Jenness Etjenness@cpan.orgE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |