File Coverage

blib/lib/Astro/Coords/Calibration.pm
Criterion Covered Total %
statement 23 40 57.5
branch 1 8 12.5
condition 1 3 33.3
subroutine 9 13 69.2
pod 8 8 100.0
total 42 72 58.3


line stmt bran cond sub pod time code
1             package Astro::Coords::Calibration;
2              
3             =head1 NAME
4              
5             Astro::Coords::Calibration - calibrations that do not have coordinates
6              
7             =head1 SYNOPSIS
8              
9             $c = new Astro::Coords::Calibration();
10              
11             =head1 DESCRIPTION
12              
13             Occasionally observations do not have any associated coordinates. In
14             particular calibration observations such as DARKs and ARRAY TESTS do
15             not require the telescope to be in any particular location. This class
16             exists in order that these types of observation can be processed in
17             similar ways to other observations (from a scheduling viewpoint
18             calibration observations always are an available target).
19              
20             =cut
21              
22 19     19   13923847 use 5.006;
  19         97  
23 19     19   109 use strict;
  19         47  
  19         485  
24 19     19   122 use warnings;
  19         50  
  19         668  
25 19     19   151 use Carp;
  19         62  
  19         1846  
26              
27             our $VERSION = '0.21';
28              
29 19     19   134 use base qw/ Astro::Coords::Fixed /;
  19         38  
  19         9943  
30              
31              
32             =head1 METHODS
33              
34             This class inherits from C<Astro::Coords::Fixed>.
35              
36             =head2 Constructor
37              
38             =over 4
39              
40             =item B<new>
41              
42             Simply instantiates an object with an Azimuth of 0.0 degrees and an
43             elevation of 90 degrees. The exact values do not matter.
44              
45             A label can be associated with the calibration (for example, to
46             include the type).
47              
48             $c = new Astro::Coords::Calibration( name => 'DARK' );
49              
50             =cut
51              
52             sub new {
53 2     2 1 5 my $proto = shift;
54 2   33     11 my $class = ref($proto) || $proto;
55 2         6 my %args = @_;
56              
57 2         19 my $self = $class->SUPER::new( az => 0.0, el => 90.0, units => 'deg' );
58 2 50       11 $self->name( $args{name} ) if exists $args{name};
59              
60 2         7 return $self;
61             }
62              
63             =back
64              
65             =head2 General Methods
66              
67             =over 4
68              
69             =item B<type>
70              
71             Return the coordinate type. In this case always return "CAL".
72              
73             =cut
74              
75             sub type {
76 1     1 1 8 return "CAL";
77             }
78              
79             =item B<array>
80              
81             Returns a summary of the object in an 11 element array. All elements
82             are undefined except the first. This contains "CAL".
83              
84             =cut
85              
86             sub array {
87 0     0 1 0 my $self = shift;
88 0         0 return ($self->type,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef);
89             }
90              
91             =item B<status>
92              
93             Return a status string describing the current coordinates. For calibration
94             objects this is very simple.
95              
96             =cut
97              
98             sub status {
99 0     0 1 0 my $self = shift;
100 0         0 my $string;
101              
102 0         0 $string .= "Coordinate type:CAL\n";
103 0 0       0 if (defined $self->telescope) {
104 0         0 $string .= "Telescope: " . $self->telescope->fullname . "\n";
105 0 0       0 if ($self->isObservable) {
106 0         0 $string .= "The target is currently observable\n";
107             } else {
108 0         0 $string .= "The target is not currently observable\n";
109             }
110             }
111              
112 0         0 return $string;
113              
114             }
115              
116             =item B<isObservable>
117              
118             Determines whether the observation is observable. Since a calibration
119             observation (defined as an observation that does not move the telescope)
120             is always observable this methods always returns true.
121              
122             =cut
123              
124             sub isObservable {
125 1     1 1 4 return 1;
126             }
127              
128             =item B<stringify>
129              
130             Returns stringified summary of the object. Always returns the
131             C<type()>.
132              
133             =cut
134              
135             sub stringify {
136 0     0 1 0 my $self = shift;
137 0         0 return $self->type;
138             }
139              
140             =item B<summary>
141              
142             Return a one line summary of the coordinates.
143             In the future will accept arguments to control output.
144              
145             $summary = $c->summary();
146              
147             =cut
148              
149             sub summary {
150 0     0 1 0 my $self = shift;
151 0         0 my $name = $self->name;
152 0 0       0 $name = '' unless defined $name;
153 0         0 return sprintf("%-16s %-12s %-13s CAL",$name,'','');
154             }
155              
156             =item B<apply_offset>
157              
158             Overrided method to prevent C<Astro::Coords::apply_offset> being
159             called on this subclass.
160              
161             =cut
162              
163             sub apply_offset {
164 1     1 1 113 croak 'apply_offset: attempting to apply an offset to a calibration';
165             }
166              
167             =back
168              
169             =head1 NOTES
170              
171             Usually called via C<Astro::Coords>.
172              
173             =head1 REQUIREMENTS
174              
175             C<Astro::PAL> is used for all internal astrometric calculations.
176              
177             =head1 AUTHOR
178              
179             Tim Jenness E<lt>tjenness@cpan.orgE<gt>
180              
181             =head1 COPYRIGHT
182              
183             Copyright (C) 2001-2005 Particle Physics and Astronomy Research Council.
184             All Rights Reserved.
185              
186             This program is free software; you can redistribute it and/or modify it under
187             the terms of the GNU General Public License as published by the Free Software
188             Foundation; either version 3 of the License, or (at your option) any later
189             version.
190              
191             This program is distributed in the hope that it will be useful,but WITHOUT ANY
192             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
193             PARTICULAR PURPOSE. See the GNU General Public License for more details.
194              
195             You should have received a copy of the GNU General Public License along with
196             this program; if not, write to the Free Software Foundation, Inc., 59 Temple
197             Place,Suite 330, Boston, MA 02111-1307, USA
198              
199             =cut
200              
201             1;