File Coverage

blib/lib/Astro/Catalog/IO/GaiaPick.pm
Criterion Covered Total %
statement 22 24 91.6
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Astro::Catalog::IO::GaiaPick;
2              
3             =head1 NAME
4              
5             Astro::Catalog::IO::GaiaPick - Catalogue reader for GAIA Pick Object files
6              
7             =head1 SYNOPSIS
8              
9             $cat = Astro::Catalog::IO::GaiaPick->_read_catalog( \@lines );
10              
11             =head1 DESCRIPTION
12              
13             This class provides a read method for catalogues in the GAIA Pick
14             Object catalogue format. This format is written by the Starlink GAIA
15             application when a user requests the result of a "Pick Object" are to
16             be saved. The method is not public and should, in general, only be
17             called from the C C method.
18              
19             =cut
20              
21              
22 1     1   4679501 use 5.006;
  1         18  
  1         73  
23 1     1   5 use strict;
  1         9  
  1         119  
24 1     1   62 use warnings;
  1         2  
  1         107  
25 1     1   5 use warnings::register;
  1         2  
  1         426  
26 1     1   8 use vars qw/ $VERSION $DEBUG /;
  1         2  
  1         124  
27 1     1   6 use Carp;
  1         2  
  1         195  
28 1     1   1193 use Data::Dumper;
  1         7258  
  1         91  
29              
30 1     1   770 use Astro::Catalog;
  0            
  0            
31             use Astro::Catalog::Star;
32             use Astro::Coords;
33              
34             use base qw/ Astro::Catalog::IO::ASCII /;
35              
36             $DEBUG = 0;
37             $VERSION = '4.31';
38              
39             # Named Constants for column positions
40             use constant NAME => 0;
41             use constant XPIX => 1;
42             use constant YPIX => 2;
43             use constant RA => 3;
44             use constant DEC => 4;
45             use constant EQUINOX => 5;
46             use constant ANGLE => 6;
47             use constant PEAK => 7;
48             use constant BACKGROUND => 8;
49             use constant FWHM_X => 9;
50             use constant FWHM_Y => 11;
51              
52             =begin __PRIVATE_METHODS__
53              
54             =head1 Private Methods
55              
56             These methods are usually called automatically from the C
57             constructor.
58              
59             =over 4
60              
61             =item B<_read_catalog>
62              
63             Read contents of a GaiaPick log file.
64              
65             $cat = Astro::Catalog::IO::TST->_read_catalog( \@lines );
66              
67             =cut
68              
69             sub _read_catalog {
70             my $class = shift;
71             my $lines = shift;
72              
73             # Local copy of array [may be a problem for very large catalogues]
74             my @lines = @$lines;
75              
76             # Remove the first line from the array
77             # without trying to parse the column names
78             # We have defined indices at the top.
79             shift(@lines);
80              
81             # Somewhere to put the stars
82             my @stars;
83              
84             # Star ID [integer]
85             my $currid = 0;
86              
87             # Loop through the array until we run out of lines
88             # Expect lines to be read in pairs
89             while (scalar(@lines) >= 2) {
90             my $tstamp = shift(@lines);
91             my $pickline = shift(@lines);
92              
93             # Skip if we have a blank line [should be rare]
94             next unless defined $tstamp;
95             next unless defined $pickline;
96             next unless $pickline =~ /\d/;
97             next unless $tstamp =~ /\d/;
98              
99             # Parse the time stamp. Need to work out where to put the
100             # time since this is not an observation date (epoch).
101             # Think of a concept for Astro::Catalog::Star
102             # catalogDate ??
103              
104             # Parse the actual star information. Split on space.
105             my @chunks = split(/\s+/,$pickline);
106              
107             # The first column refers to the file name so is
108             # effectively the field ID.
109              
110             # We need to create our own unique star ID for now.
111             # Use an integer starting at 1.
112             $currid ++;
113              
114             # Coordinate object
115             my $c = new Astro::Coords( name => $currid,
116             ra => $chunks[RA],
117             dec => $chunks[DEC],
118             type => $chunks[EQUINOX],
119             units => 'sex',
120             );
121              
122             my $star = new Astro::Catalog::Star( ID => $currid,
123             Field => $chunks[0],
124             Coords => $c,
125             X => $chunks[XPIX],
126             Y => $chunks[YPIX],
127             );
128              
129             push(@stars, $star);
130             }
131              
132             my $cat = new Astro::Catalog( Stars => \@stars,
133             Origin => 'GaiaPick',
134             );
135              
136             }
137              
138             =back
139              
140             =end __PRIVATE_METHODS__
141              
142             =head1 REVISION
143              
144             $Id: GaiaPick.pm,v 1.2 2005/03/31 01:24:53 cavanagh Exp $
145              
146             =head1 FORMAT
147              
148             The GaiaPick format is extremely simple. First there is an informational
149             header that describes the subsequent columns. This is a single line:
150              
151             # name x y ra dec equinox angle peak background fwhm (X:Y)
152              
153             (white space has been compressed in this description to remove the
154             need for line wrapping). The results of the "Pick Object" are then
155             written to the following lines, using up two lines per pick as
156             follows:
157              
158             # Sunday February 08 2004 - 16:43:59
159             iras.sdf 153.3 151.5 00:42:45.757 +41:16:44.96 J2000 160.7 2.7 1.4 7.8 : 6.1
160              
161             The first line indicates the date of the pick. The second line
162             contains the parameters of the source.
163              
164             Currently the reader does not attempt to parse the first line in order
165             to derive the column information. The assumption is that the columns
166             are always in the same order.
167              
168             =head1 SEE ALSO
169              
170             The GAIA application can be obtained from Starlink (http://www.starlink.ac.uk).
171              
172             =head1 AUTHOR
173              
174             Tim Jenness Etjenness@cpan.orgE
175              
176             =head1 COPYRIGHT
177              
178             Copyright (C) 2004 Particle Physics and Astronomy Research Council.
179             All Rights Reserved.
180              
181             This module is free software; you can redistribute it and/or modify it
182             under the terms of the GNU Public License.
183              
184             =cut