line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Catalog::IO::FINDOFF; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::Catalog::IO::FINDOFF - Catalogue I/O for Astro::Catalog for Starlink |
6
|
|
|
|
|
|
|
FINDOFF. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$cat = Astro::Catalog::IO::FINDOFF->_read_catalog( \@lines ); |
11
|
|
|
|
|
|
|
$arrref = Astro::Catalog::IO::FINDOFF->_write_catalog( $cat, %options ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class provides read and write methods for catalogues in the Starlink |
16
|
|
|
|
|
|
|
FINDOFF input and output file format. The methods are not public and should, |
17
|
|
|
|
|
|
|
in general only be called from the C C and |
18
|
|
|
|
|
|
|
C methods. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
1691562
|
use 5.006; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
104
|
|
23
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
91
|
|
24
|
1
|
|
|
1
|
|
77
|
use warnings::register; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
364
|
|
25
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
198
|
|
26
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
787
|
use Astro::Catalog; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Astro::Catalog::Star; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use base qw/ Astro::Catalog::IO::ASCII /; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use vars qw/ $VERSION $DEBUG /; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$VERSION = '4.31'; |
36
|
|
|
|
|
|
|
$DEBUG = 0; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 Private 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::FINDOFF->_read_catalog( \@lines, %options ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
There are currently no supported options. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _read_catalog { |
56
|
|
|
|
|
|
|
my $class = shift; |
57
|
|
|
|
|
|
|
my $lines = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
croak "Must supply catalogue contents as a reference to an array" |
60
|
|
|
|
|
|
|
unless ref( $lines ) eq 'ARRAY'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Create the Astro::Catalog object. |
63
|
|
|
|
|
|
|
my $catalog = new Astro::Catalog(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Chew up the lines. For position list files in FINDOFF, the first |
66
|
|
|
|
|
|
|
# three columns are ID, X, and Y. Any columns after that could be |
67
|
|
|
|
|
|
|
# anything, really, so put them in the Star's comment string. |
68
|
|
|
|
|
|
|
my @lines = @$lines; # Dereference, make own copy. |
69
|
|
|
|
|
|
|
for ( @lines ) { |
70
|
|
|
|
|
|
|
my $line = $_; |
71
|
|
|
|
|
|
|
next unless $line =~ /^\s*([\w\-.]+)\s+([\w\-.]+)\s+([\w\-.]+)(?:\s+(.+))*$/; |
72
|
|
|
|
|
|
|
my $id = $1; |
73
|
|
|
|
|
|
|
my $x = $2; |
74
|
|
|
|
|
|
|
my $y = $3; |
75
|
|
|
|
|
|
|
my $comment = $4; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Create the Astro::Catalog::Star object. |
78
|
|
|
|
|
|
|
my $star = new Astro::Catalog::Star( ID => $id, |
79
|
|
|
|
|
|
|
X => $x, |
80
|
|
|
|
|
|
|
Y => $y, |
81
|
|
|
|
|
|
|
Comment => $comment ); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# And push the star onto the catalogue. |
84
|
|
|
|
|
|
|
$catalog->pushstar( $star ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Set the catalogue's origin. |
88
|
|
|
|
|
|
|
$catalog->origin( 'IO::FINDOFF' ); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# And return; |
91
|
|
|
|
|
|
|
return $catalog; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item B<_write_catalog> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Create an output catalogue in the Starlink FINDOFF format and return |
97
|
|
|
|
|
|
|
the lines in an array. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$ref = Astro::Catalog::IO::FINDOFF->_write_catalog( $catalog ); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The sole mandatory argument is an C object. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
As the Starlink FINDOFF is ID in column 1, X position in column 2, |
104
|
|
|
|
|
|
|
Y position in column 3, and miscellaneous information in the remaining |
105
|
|
|
|
|
|
|
columns that gets carried through to the output file, this method |
106
|
|
|
|
|
|
|
writes a new ID, X, and Y in the first three columns. A new ID is |
107
|
|
|
|
|
|
|
formed by removing any non-numbers from the original ID because |
108
|
|
|
|
|
|
|
FINDOFF cannot understand non-integer IDs. This ID is also written |
109
|
|
|
|
|
|
|
to the fourth column because FINDOFF trounces the original input |
110
|
|
|
|
|
|
|
ID when doing matching, and being able to have the original ID |
111
|
|
|
|
|
|
|
is a good thing. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _write_catalog { |
116
|
|
|
|
|
|
|
my $class = shift; |
117
|
|
|
|
|
|
|
my $catalog = shift; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
croak "Must supply catalogue contents as a reference to an array" |
120
|
|
|
|
|
|
|
unless UNIVERSAL::isa( $catalog, "Astro::Catalog" ); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Set up variables for output. |
123
|
|
|
|
|
|
|
my @output; |
124
|
|
|
|
|
|
|
my $output_line; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $newid = 1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Loop through the stars. |
129
|
|
|
|
|
|
|
foreach my $star ( $catalog->stars ) { |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# We need at a bare minimum the X, Y, and ID. |
132
|
|
|
|
|
|
|
next if ( ! defined( $star->x ) || |
133
|
|
|
|
|
|
|
! defined( $star->y ) || |
134
|
|
|
|
|
|
|
! defined( $star->id ) ); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
( my $comment = $star->id ) =~ s/[^\d]//g; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Start off the output string. |
139
|
|
|
|
|
|
|
$output_line = join( ' ', $newid, $star->x, $star->y, $newid ); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# And push this string to the output array. |
142
|
|
|
|
|
|
|
push @output, $output_line; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$newid++; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# All done looping through the stars, so return the array reference. |
149
|
|
|
|
|
|
|
return \@output; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 REVISION |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$Id: FINDOFF.pm,v 1.5 2007/05/31 01:42:34 cavanagh Exp $ |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L, L |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Starlink User Note 139 (http://www.starlink.ac.uk/star/docs/sun139.htx/sun139.html) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COYPRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright (C) 2005 Particle Physics and Astronomy Research Council. |
167
|
|
|
|
|
|
|
All Rights Reserved. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
170
|
|
|
|
|
|
|
under the terms of the GNU Public License. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 AUTHORS |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Brad Cavanagh Eb.cavanagh@jach.hawaii.eduE |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |