Astro/Catalog/Item.pm

filter: Statementstmt 61.0% 221 / 362 Branchbran 44.6% 84 / 188 Conditioncond 25.8% 15 / 58 MC/DCmcdc 3.3% 1 / 30 Subroutinesub 79.1% 38 / 48 Podpod 87.1% 34 / 39 totaltotal 54.2% 393 / 725 CC 117 SCAR 33.3
CC
117
Cov
53%
configure
113.4
get_flux_quantity
42.0
get_flux_error
42.0
CRAP 27.9
« Astro/Catalog/Query/SIMBAD.pm ↑ Summary Astro/Catalog/Query/SkyCat.pm »
1 package Astro::Catalog::Item;
2  
3 =head1 NAME
4  
5 Astro::Catalog::Item - A generic star object in a stellar catalog
6  
7 =head1 SYNOPSIS
8  
9 $star = new Astro::Catalog::Item(
10 ID => $id,
11 Coords => new Astro::Coords(),
12 Morphology => new Astro::Catalog::Item::Morphology(),
13 Fluxes => new Astro::Fluxes(),
14 Quality => $quality_flag,
15 Field => $field,
16 GSC => $in_gsc,
17 Distance => $distance_to_centre,
18 PosAngle => $position_angle,
19 X => $x_pixel_coord,
20 Y => $y_pixel_coord,
21 WCS => new Starlink::AST(),
22 Comment => $comment_string
23 SpecType => $spectral_type,
24 StarType => $star_type,
25 LongStarType => $long_star_type,
26 MoreInfo => $url,
27 InsertDate => new Time::Piece(),
28 Misc => $hash_ref,
29 );
30  
31 =head1 DESCRIPTION
32  
33 Stores generic meta-data about an individual stellar object from a catalog.
34  
35 If the catalog has a field center the Distance and Position Angle properties
36 should be used to store the direction to the field center, e.g. a star from the
37 USNO-A2 catalog retrieived from the ESO/ST-ECF Archive will have these
38 properties.
39  
40 =cut
41  
42  
43 60 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 60 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 60 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 60 ▶use Astro::Coords 0.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 60 ▶use Astro::Catalog::Item::Morphology;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 60 ▶use Astro::Fluxes;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 60 ▶use Astro::Flux;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 60 ▶use Astro::FluxColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 # Register an Astro::Catalog::Item warning category
53 60 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 60 our $VERSION = '4.38';
56  
57 # Internal lookup table for Simbad star types
58 60 my %STAR_TYPE_LOOKUP = (
59 'vid' => 'Underdense region of the Universe',
60 'Er*' => 'Eruptive variable Star',
61 'Rad' => 'Radio-source',
62 'Q?' => 'Possible Quasar',
63 'IR' => 'Infra-Red source',
64 'SB*' => 'Spectrocopic binary',
65 'C*' => 'Carbon Star',
66 'Gl?' => 'Possible Globular Cluster',
67 'DNe' => 'Dark Nebula',
68 'GlC' => 'Globular Cluster',
69 'No*' => 'Nova',
70 'V*?' => 'Star suspected of Variability',
71 'LeG' => 'Gravitationnaly Lensed Image of a Galaxy',
72 'mAL' => 'metallic Absorption Line system',
73 'LeI' => 'Gravitationnaly Lensed Image',
74 'WU*' => 'Eclipsing binary of W UMa type',
75 'Be*' => 'Be Star',
76 'PaG' => 'Pair of Galaxies',
77 'Mas' => 'Maser',
78 'LeQ' => 'Gravitationnaly Lensed Image of a Quasar',
79 'mul' => 'Composite object',
80 'SBG' => 'Starburst Galaxy',
81 '*' => 'Star',
82 'gam' => 'gamma-ray source',
83 'bL*' => 'Eclipsing binary of beta Lyr type',
84 'S*' => 'S Star',
85 'El*' => 'Elliptical variable Star',
86 'GNe' => 'Galactic Nebula',
87 'DQ*' => 'Cataclysmic Var. DQ Her type',
88 '?' => 'Object of unknown nature',
89 'WV*' => 'Variable Star of W Vir type',
90 'SR?' => 'SuperNova Remnant Candidate',
91 'Bla' => 'Blazar',
92 'G' => 'Galaxy',
93 'SCG' => 'Supercluster of Galaxies',
94 'OH*' => 'Star with envelope of OH/IR type',
95 'Lev' => '(Micro)Lensing Event',
96 'BNe' => 'Bright Nebula',
97 'RV*' => 'Variable Star of RV Tau type',
98 'IR0' => 'IR source at lambda < 10 microns',
99 'OVV' => 'Optically Violently Variable object',
100 'a2*' => 'Variable Star of alpha2 CVn type',
101 'IR1' => 'IR source at lambda > 10 microns',
102 'Em*' => 'Emission-line Star',
103 'PM*' => 'High proper-motion Star',
104 'X' => 'X-ray source',
105 'HzG' => 'Galaxy with high redshift',
106 'Sy*' => 'Symbiotic Star',
107 'LXB' => 'Low Mass X-ray Binary',
108 '*i*' => 'Star in double system',
109 'Sy1' => 'Seyfert 1 Galaxy',
110 'Sy2' => 'Seyfert 2 Galaxy',
111 'LIN' => 'LINER-type Active Galaxy Nucleus',
112 'rG' => 'Radio Galaxy',
113 'Cl*' => 'Cluster of Stars',
114 'NL*' => 'Nova-like Star',
115 'HV*' => 'High-velocity Star',
116 'EmG' => 'Emission-line galaxy',
117 '*iA' => 'Star in Association',
118 'grv' => 'Gravitational Source',
119 '*iC' => 'Star in Cluster',
120 'SyG' => 'Seyfert Galaxy',
121 'RNe' => 'Reflection Nebula',
122 'EmO' => 'Emission Object',
123 'Ce*' => 'Classical Cepheid variable Star',
124 'CV*' => 'Cataclysmic Variable Star',
125 '*iN' => 'Star in Nebula',
126 'BY*' => 'Variable of BY Dra type',
127 'Pe*' => 'Peculiar Star',
128 'AM*' => 'Cataclysmic Var. AM Her type',
129 'FU*' => 'Variable Star of FU Ori type',
130 'HVC' => 'High-velocity Cloud',
131 'ClG' => 'Cluster of Galaxies',
132 'Ir*' => 'Variable Star of irregular type',
133 'PN?' => 'Possible Planetary Nebula',
134 'ALS' => 'Absorption Line system',
135 'cm' => 'centimetric Radio-source',
136 'As*' => 'Association of Stars',
137 'V*' => 'Variable Star',
138 'Fl*' => 'Flare Star',
139 'EB*' => 'Eclipsing binary',
140 'CGG' => 'Compact Group of Galaxies',
141 'UV' => 'UV-emission source',
142 'Ro*' => 'Rotationally variable Star',
143 'SN*' => 'SuperNova',
144 'pr*' => 'Pre-main sequence Star',
145 'CH*' => 'Star with envelope of CH type',
146 'Al*' => 'Eclipsing binary of Algol type',
147 'Pu*' => 'Pulsating variable Star',
148 'Cld' => 'Cloud of unknown nature',
149 'QSO' => 'Quasar',
150 'Psr' => 'Pulsars',
151 'GiC' => 'Galaxy in Cluster of Galaxies',
152 'V* RI*' => 'Variable Star with rapid variations',
153 'sh' => 'HI shell',
154 'GiG' => 'Galaxy in Group of Galaxies',
155 'OpC' => 'Open (galactic) Cluster',
156 'WR*' => 'Wolf-Rayet Star',
157 'BCG' => 'Blue compact Galaxy',
158 'blu' => 'Blue object',
159 'GiP' => 'Galaxy in Pair of Galaxies',
160 'LyA' => 'Ly alpha Absorption Line system',
161 'CGb' => 'Cometary Globule',
162 '**' => 'Double or multiple star',
163 'H2G' => 'HII Galaxy',
164 'RR*' => 'Variable Star of RR Lyr type',
165 'HB*' => 'Horizontal Branch Star',
166 'RC*' => 'Variable Star of R CrB type',
167 'SNR' => 'SuperNova Remnant',
168 'MoC' => 'Molecular Cloud',
169 'HXB' => 'High Mass X-ray Binary',
170 'mR' => 'metric Radio-source',
171 'TT*' => 'T Tau-type Star',
172 'DN*' => 'Dwarf Nova',
173 'eg sr*' => 'Semi-regular pulsating Star',
174 'HII' => 'HII (ionized) region',
175 'HH' => 'Herbig-Haro Object',
176 'HI' => 'HI (neutral) region',
177 'WD*' => 'White Dwarf',
178 'Or*' => 'Variable Star in Orion Nebula',
179 'dS*' => 'Variable Star of delta Sct type',
180 'DLy' => 'Dumped Ly alpha Absorption Line system',
181 'AGN' => 'Active Galaxy Nucleus',
182 'GrG' => 'Group of Galaxies',
183 'Mi*' => 'Variable Star of Mira Cet type',
184 'RS*' => 'Variable of RS CVn type',
185 'mm' => 'millimetric Radio-source',
186 'red' => 'Very red source',
187 'BLL' => 'BL Lac - type object',
188 'reg' => 'Region defined in the sky',
189 'PN' => 'Planetary Nebula',
190 'ZZ*' => 'Variable White Dwarf of ZZ Cet type',
191 'gB' => 'gamma-ray Burster',
192 'PoC' => 'Part of Cloud',
193 'XB*' => 'X-ray Binary',
194 'PoG' => 'Part of a Galaxy',
195 'Neb' => 'Nebula of unknown nature'
196 );
197  
198 =head1 METHODS
199  
200 =head2 Constructor
201  
202 =over 4
203  
204 =item B<new>
205  
206 Create a new instance from a hash of options
207  
208 $star = new Astro::Catalog::Item(
209 ID => $id,
210 Coords => new Astro::Coords(),
211 Morphology => new Astro::Catalog::Item::Morphology(),
212 Fluxes => new Astro::Fluxes(),
213 Quality => $quality_flag,
214 Field => $field,
215 GSC => $in_gsc,
216 Distance => $distance_to_centre,
217 PosAngle => $position_angle,
218 X => $x_pixel_coord,
219 Y => $y_pixel_coord,
220 Comment => $comment_string
221 SpecType => $spectral_type,
222 StarType => $star_type,
223 LongStarType => $long_star_type,
224 MoreInfo => $url,
225 InsertDate => new Time::Piece(),
226 Misc => $misc,
227 );
228  
229 returns a reference to an Astro::Catalog::Item object.
230  
231 The coordinates can also be specified as individual RA and Dec values
232 (sexagesimal format) if they are known to be J2000.
233  
234 =cut
235  
236 905 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
237 905 my $proto = shift;
238 905 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
09050
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
239  
240 # bless the query hash into the class
241 905 my $block = bless {
242 ID => undef,
243 FLUXES => undef,
244 MORPHOLOGY => undef,
245 QUALITY => undef,
246 FIELD => undef,
247 GSC => undef,
248 DISTANCE => undef,
249 POSANGLE => undef,
250 COORDS => undef,
251 X => undef,
252 Y => undef,
253 WCS => undef,
254 COMMENT => undef,
255 SPECTYPE => undef,
256 STARTYPE => undef,
257 LONGTYPE => undef,
258 MOREINFO => undef,
259 INSERTDATE => undef,
260 PREFERRED_MAG_TYPE => undef,
261 MISC => undef,
262 }, $class;
263  
264 # If we have arguments configure the object
265 905 ▶ $block->configure( @_ ) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 817 88 905
266  
267 905 return $block;
268 }
269  
270 =back
271  
272 =head2 Accessor Methods
273  
274 =over 4
275  
276 =item B<id>
277  
278 Return (or set) the ID of the star
279  
280 $id = $star->id();
281 $star->id( $id );
282  
283 If an Astro::Coords object is associated with the Star, the name
284 field is set in the underlying Astro::Coords object as well as in
285 the current Star object.
286  
287 =cut
288  
289 5214 ▶sub id {
Subroutine id: called CC=3 SCAR=11.0
Pod documented
290 5214 my $self = shift;
291 5214 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1751 3463 5214
292 1751 $self->{ID} = shift;
293  
294 1751 my $c = $self->coords;
295 1751 ▶ $c->name($self->{ID}) if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 801 950 1751
296 }
297 5214 return $self->{ID};
298 }
299  
300 =item B<coords>
301  
302 Return or set the coordinates of the star as an C<Astro::Coords>
303 object.
304  
305 $c = $star->coords();
306 $star->coords($c);
307  
308 The object returned by this method is the actual object stored
309 inside this Star object and not a clone. If the coordinates
310 are changed through this object the coordinate of the star is
311 also changed.
312  
313 Currently, if you modify the RA or Dec through the ra()
314 or dec() methods of Star, the internal object associated with
315 the Star will change.
316  
317 Returns undef if the coordinates have never been specified.
318  
319 If the name() field is defined in the Astro::Coords object
320 the id() field is set in the current Star object. Similarly for
321 the comment field.
322  
323 =cut
324  
325 9156 ▶sub coords {
Subroutine coords: called CC=5 SCAR=16.1
Pod documented
326 9156 my $self = shift;
327 9156 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 875 8281 9156
328 875 my $c = shift;
329 875 ▶ croak "Coordinates must be an Astro::Coords object"
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($c, "Astro::Coords") 0 875 875
330 unless UNIVERSAL::isa($c, "Astro::Coords");
331  
332 # force the ID and comment to match
333 875 ▶ $self->id($c->name) if defined $c->name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c->name 864 11 875
334 875 ▶ $self->comment($c->comment) if $c->comment;
Branch: 1 branch
BranchTrueFalseTotal
if $c->comment 749 126 875
335  
336 # Store the new coordinate object
337 # Storing it late stops looping from the id and comment methods
338 875 $self->{COORDS} = $c;
339 }
340 9156 return $self->{COORDS};
341 }
342  
343 =item B<ra>
344  
345 Return (or set) the current object R.A. (J2000).
346  
347 $ra = $star->ra();
348  
349 If the Star is associated with a moving object such as a planet,
350 comet or asteroid this method will return the J2000 RA associated
351 with the time and observer position associated with the coordinate
352 object itself (by default current time, longitude of 0 degrees).
353 Returns undef if no coordinate has been associated with this star.
354  
355 $star->ra($ra);
356  
357 The RA can be changed using this method but only if the coordinate
358 object is associated with a fixed position. Attempting to change the
359 J2000 RA of a moving object will fail. If an attempt is made to
360 change the RA when no coordinate is associated with this object then
361 a new Astro::Coords object will be created (with a
362 Dec of 0.0).
363  
364 RA accepted by this method must be in sexagesimal format, space or
365 colon-separated. Returns a space-separated sexagesimal number.
366  
367  
368 =cut
369  
370 402 ▶sub ra {
Subroutine ra: called CC=6 SCAR=26.9
Pod documented
371 402 my $self = shift;
372 402 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 402 402
373 0 my $ra = shift;
374  
375 # Issue a warning specifically for this call
376 0 my @info = caller();
377 0 warnings::warnif("deprecated","Use of ra() method for setting RA now deprecated. Please use the coords() method instead, at $info[1] line $info[2]");
378  
379  
380 # Get the coordinate object
381 0 my $c = $self->coords;
382 0 ▶ if (defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) { } 0 0 0
383 # Need to tweak RA?
384 0 ▶ croak "Can only adjust RA with Astro::Coords::Equatorial coordinates"
Branch: 1 branch
BranchTrueFalseTotal
unless $c->isa("Astro::Coords::Equatorial") 0 0 0
385 unless $c->isa("Astro::Coords::Equatorial");
386  
387 # For now need to kluge since Astro::Coords does not allow
388 # you to change the position (it is an immutable object)
389 0 $c = $c->new(
390 type => 'J2000',
391 dec => $c->dec(format => 's'),
392 ra => $ra,
393 );
394  
395 }
396 else {
397 0 $c = new Astro::Coords(
398 type => 'J2000',
399 ra => $ra,
400 dec => '0',
401 );
402 }
403  
404 # Update the object
405 0 $self->coords($c);
406 }
407  
408 402 my $outc = $self->coords;
409 402 ▶ return unless defined $outc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $outc 0 402 402
410  
411 # Astro::Coords inserts colons by default. Grab the old delimiter
412 # and number of decimal places if we're using a recent enough
413 # version of Astro::Coords.
414 402 my $ra = $outc->ra;
415 402 ▶ if (UNIVERSAL::isa($ra, "Astro::Coords::Angle")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($ra, 'Astro::Coords::Angle')) { } 402 0 402
416 402 $ra->str_delim(' ');
417 402 $ra->str_ndp(2);
418 402 return "$ra";
419 }
420 else {
421 0 my $outra = $outc->ra(format => 's');
422 0 $outra =~ s/:/ /g;
423 0 $outra =~ s/^\s*//;
424  
425 0 return $outra;
426 }
427 }
428  
429 =item B<dec>
430  
431 Return (or set) the current object Dec (J2000).
432  
433 $dec = $star->dec();
434  
435 If the Star is associated with a moving object such as a planet,
436 comet or asteroid this method will return the J2000 Dec associated
437 with the time and observer position associated with the coordinate
438 object itself (by default current time, longitude of 0 degrees).
439 Returns undef if no coordinate has been associated with this star.
440  
441 $star->dec( $dec );
442  
443 The Dec can be changed using this method but only if the coordinate
444 object is associated with a fixed position. Attempting to change the
445 J2000 Dec of a moving object will fail. If an attempt is made to
446 change the Dec when no coordinate is associated with this object then
447 a new Astro::Coords object will be created (with a
448 Dec of 0.0).
449  
450 Dec accepted by this method must be in sexagesimal format, space or
451 colon-separated. Returns a space-separated sexagesimal number
452 with a leading sign.
453  
454 =cut
455  
456 20 ▶sub dec {
Subroutine dec: called CC=8 SCAR=30.5
Pod documented
457 20 my $self = shift;
458 20 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 20 20
459 0 my $dec = shift;
460  
461 # Issue a warning specifically for this call
462 0 my @info = caller();
463 0 warnings::warnif("deprecated","Use of ra() method for setting RA now deprecated. Please use the coords() method instead, at $info[1] line $info[2]");
464  
465 # Get the coordinate object
466 0 my $c = $self->coords;
467 0 ▶ if (defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) { } 0 0 0
468 # Need to tweak RA?
469 0 ▶ croak "Can only adjust Dec with Astro::Coords::Equatorial coordinates"
Branch: 1 branch
BranchTrueFalseTotal
unless $c->isa("Astro::Coords::Equatorial") 0 0 0
470 unless $c->isa("Astro::Coords::Equatorial");
471  
472 # For now need to kluge since Astro::Coords does not allow
473 # you to change the position (it is an immutable object)
474 0 $c = $c->new(
475 type => 'J2000',
476 ra => $c->ra(format => 's'),
477 dec => $dec,
478 );
479  
480 }
481 else {
482 0 $c = new Astro::Coords(
483 type => 'J2000',
484 dec => $dec,
485 ra => 0,
486 );
487 }
488  
489 # Update the object
490 0 $self->coords($c);
491 }
492  
493 20 my $outc = $self->coords;
494 20 ▶ return unless defined $outc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $outc 0 20 20
495  
496 # Astro::Coords inserts colons by default. Grab the old delimiter
497 # and number of decimal places if we're using a recent enough
498 # version of Astro::Coords.
499 20 my $dec = $outc->dec;
500 20 ▶ if (UNIVERSAL::isa($dec, "Astro::Catalog::Angle")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($dec, 'Astro::Catalog::Angle')) { } 0 20 20
501 0 $dec->str_delim(' ');
502 0 $dec->str_ndp(2);
503 0 $dec = "$dec";
504 0 ▶ $dec = (substr($dec, 0, 1) eq '-' ? '' : '+') . $dec;
Branch: 1 branch
BranchTrueFalseTotal
substr($dec, 0, 1) eq '-' ? : 0 0 0
505 0 return $dec;
506 }
507 else {
508 20 my $outdec = $outc->dec(format => 's');
509 20 $outdec =~ s/:/ /g;
510 20 $outdec =~ s/^\s*//;
511  
512 # require leading sign for backwards compatibility
513 # Sign will be there for negative
514 20 ▶ $outdec = (substr($outdec, 0, 1) eq '-' ? '' : '+') . $outdec;
Branch: 1 branch
BranchTrueFalseTotal
substr($outdec, 0, 1) eq '-' ? : 8 12 20
515  
516 20 return $outdec;
517 }
518 }
519  
520 =item B<fluxes>
521  
522 Return or set the flux measurements of the star as an C<Astro::Fluxes>
523 object.
524  
525 $f = $star->fluxes();
526 $star->fluxes($f);
527  
528 $star->fluxes($f, 1); # will replace instead of appending
529  
530  
531 The object returned by this method is the actual object stored
532 inside this Item object and not a clone. If the flux values
533 are changed through this object the flu values of the star is
534 also changed.
535  
536 If an optional flag is passed as set to the routine it will replace
537 instead of appending (default action) to an existing fluxes object
538 in the catalog.
539  
540 Returns undef if the fluxes have never been specified.
541  
542 =cut
543  
544 83 ▶sub fluxes {
Subroutine fluxes: called CC=5 SCAR=18.3
Pod documented
545 83 my $self = shift;
546 83 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 74 9 83
547 74 my $flux = shift;
548 74 my $flag = shift;
549 74 ▶ croak "Flux must be an Astro::Fluxes object"
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($flux, "Astro::Fluxes") 0 74 74
550 unless UNIVERSAL::isa($flux, "Astro::Fluxes");
551  
552 74 ▶ if (defined $self->{FLUXES}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'FLUXES'}) { } 0 74 74
553 0 ▶ if (defined $flag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flag) { } 0 0 0
554 0 $self->{FLUXES} = $flux;
555 }
556 else {
557 0 $self->{FLUXES}->merge( $flux );
558 }
559 }
560 else {
561 74 $self->{FLUXES} = $flux;
562 }
563 }
564 83 return $self->{FLUXES};
565 }
566  
567 =item B<what_filters>
568  
569 Returns a list of the wavebands for which the object has defined values.
570  
571 @filters = $star->what_filters();
572 $num = $star->what_filters();
573  
574 if called in a scalar context it will return the number of filters which
575 have defined magnitudes in the object. It will included 'derived' values,
576 see C<Astro::Flux> for details.
577  
578 =cut
579  
580 10 ▶sub what_filters {
Subroutine what_filters: called CC=3 SCAR=11.0
Pod documented
581 10 my $self = shift;
582  
583 10 my $fluxes = $self->{FLUXES};
584  
585 10 ▶ my @mags = $fluxes->original_wavebands('filters') if defined $fluxes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fluxes 10 0 10
586  
587 # return array of filters or number if called in scalar context
588 10 ▶ return wantarray ? @mags : scalar(@mags);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 2 10
589 }
590  
591 =item B<what_colours>
592  
593 Returns a list of the colours for which the object has defined values.
594  
595 @colours = $star->what_colours();
596 $num = $star->what_colours();
597  
598 if called in a scalar context it will return the number of colours which
599 have defined values in the object.
600  
601 =cut
602  
603 10 ▶sub what_colours {
Subroutine what_colours: called CC=3 SCAR=11.0
Pod documented
604 10 my $self = shift;
605  
606 10 my $fluxes = $self->{FLUXES};
607 10 ▶ my @cols = $fluxes->original_colors() if defined $fluxes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fluxes 10 0 10
608  
609 # return array of colours or number if called in scalar context
610 10 ▶ return wantarray ? @cols : scalar(@cols);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 2 10
611 }
612  
613 =item B<get_magnitude>
614  
615 Returns the magnitude for the supplied filter if available
616  
617 $magnitude = $star->get_magnitude('B');
618  
619 =cut
620  
621 31 ▶sub get_magnitude {
Subroutine get_magnitude: called CC=3 SCAR=11.3
Pod documented
622 31 my $self = shift;
623  
624 31 my $magnitude;
625 31 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 31 0 31
626 # grab passed filter
627 31 my $filter = shift;
628 31 my $fluxes = $self->{FLUXES};
629 31 $magnitude = $fluxes->flux(
630 waveband => $filter,
631 type => $self->preferred_magnitude_type);
632  
633 31 ▶ if (defined($magnitude)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $magnitude) { } 31 0 31
634 31 return $magnitude->quantity($self->preferred_magnitude_type);
635 }
636 else {
637 0 return undef;
638 }
639 }
640 }
641  
642 =item B<get_flux_quantity>
643  
644 Returns the flux quantity for the given waveband and flux type.
645  
646 my $flux = $star->get_flux_quantity(
647 waveband => 'B',
648 type => 'mag');
649  
650 The arguments are passed as a hash. The value for the waveband
651 argument can be either a string describing a filter or an
652 Astro::WaveBand object. The value for the flux type is
653 case-insensitive.
654  
655 Returns a scalar.
656  
657 =cut
658  
659 0 ▶sub get_flux_quantity {
Subroutine get_flux_quantity: not called CC=6 SCAR=37.4
Pod documented
660 0 my $self = shift;
661 0 my %args = @_;
662  
663 0 ▶ unless (defined $args{'waveband'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"waveband"}) 0 0 0
664 0 croak "Must supply waveband to Astro::Catalog::Item->get_flux_quantity()";
665 }
666 0 ▶ unless (defined $args{'type'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"type"}) 0 0 0
667 0 croak "Must supply flux type to Astro::Catalog::Item->get_flux_quantity()";
668 }
669  
670 0 my $waveband;
671 0 ▶ unless (UNIVERSAL::isa($args{'waveband'}, "Astro::WaveBand")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($args{'waveband'}, 'Astro::WaveBand')) { } 0 0 0
672 0 $waveband = new Astro::WaveBand(Filter => $args{'waveband'});
673 }
674 else {
675 0 $waveband = $args{'waveband'};
676 }
677  
678 0 my $fluxes = $self->fluxes;
679 0 ▶ if (defined $fluxes) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fluxes) 0 0 0
680 0 my $flux = $fluxes->flux(waveband => $waveband, type => $args{'type'});
681 0 ▶ if (defined $flux) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flux) 0 0 0
682 0 return $flux->quantity($args{'type'} );
683 }
684 }
685 0 return undef;
686 }
687  
688 =item B<get_errors>
689  
690 Returns the error in the magnitude value for the supplied filter if available
691  
692 $mag_errors = $star->get_errors('B');
693  
694 =cut
695  
696 31 ▶sub get_errors {
Subroutine get_errors: called CC=3 SCAR=11.7
Pod documented
697 31 my $self = shift;
698  
699 31 my $mag_error;
700 31 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 31 0 31
701 # grab passed filter
702 31 my $filter = shift;
703 31 my $fluxes = $self->{FLUXES};
704 31 my $magnitude = $fluxes->flux(
705 waveband => $filter,
706 type => $self->preferred_magnitude_type);
707 31 ▶ if (defined $magnitude) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $magnitude) { } 31 0 31
708 31 return $magnitude->error( $self->preferred_magnitude_type );
709 }
710 else {
711 0 return undef;
712 }
713 }
714 0 return $mag_error;
715 }
716  
717 =item B<get_flux_error>
718  
719 Returns the flux error for the given waveband and flux type.
720  
721 my $flux = $star->get_flux_error(
722 waveband => 'B',
723 type => 'mag');
724  
725 The arguments are passed as a hash. The value for the waveband
726 argument can be either a string describing a filter or an
727 Astro::WaveBand object. The value for the flux type is
728 case-insensitive.
729  
730 Returns a scalar.
731  
732 =cut
733  
734 0 ▶sub get_flux_error {
Subroutine get_flux_error: not called CC=6 SCAR=37.4
Pod documented
735 0 my $self = shift;
736 0 my %args = @_;
737  
738 0 ▶ unless (defined $args{'waveband'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"waveband"}) 0 0 0
739 0 croak "Must supply waveband to Astro::Catalog::Item->get_flux_error()";
740 }
741 0 ▶ unless(defined $args{'type'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"type"}) 0 0 0
742 0 croak "Must supply flux type to Astro::Catalog::Item->get_flux_error()";
743 }
744  
745 0 my $waveband;
746 0 ▶ unless (UNIVERSAL::isa($args{'waveband'}, "Astro::WaveBand")) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($args{'waveband'}, 'Astro::WaveBand')) { } 0 0 0
747 0 $waveband = new Astro::WaveBand(Filter => $args{'waveband'});
748 }
749 else {
750 0 $waveband = $args{'waveband'};
751 }
752 0 my $fluxes = $self->fluxes;
753 0 ▶ if (defined $fluxes) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fluxes) 0 0 0
754 0 my $flux = $fluxes->flux(waveband => $waveband, type => $args{'type'});
755 0 ▶ if (defined $flux) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flux) 0 0 0
756 0 return $flux->error($args{'type'});
757 }
758 }
759 0 return undef;
760 }
761  
762 =item B<get_colour>
763  
764 Returns the value of the supplied colour if available
765  
766 $colour = $star->get_colour('B-V');
767  
768 =cut
769  
770 20 ▶sub get_colour {
Subroutine get_colour: called CC=2 SCAR=6.9
Pod documented
771 20 my $self = shift;
772  
773 20 my $value;
774 20 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 20 0 20
775 # grab passed colour
776 20 my $colour = shift;
777 20 my @filters = split "-", $colour;
778 20 my $fluxes = $self->{FLUXES};
779 20 my $color = $fluxes->color(
780 upper => new Astro::WaveBand(Filter => $filters[0]),
781 lower => new Astro::WaveBand(Filter => $filters[1]));
782 20 $value = $color->quantity('mag');
783 }
784 20 return $value;
785 }
786  
787 =item B<get_colourerror>
788  
789 Returns the error in the colour value for the supplied colour if available
790  
791 $col_errors = $star->get_colourerr('B-V');
792  
793 =cut
794  
795 20 ▶sub get_colourerr {
Subroutine get_colourerr: called CC=2 SCAR=6.9
Pod undocumented
796 20 my $self = shift;
797  
798 20 my $col_error;
799 20 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 20 0 20
800 # grab passed colour
801 20 my $colour = shift;
802 20 my @filters = split "-", $colour;
803 20 my $fluxes = $self->{FLUXES};
804 20 my $color = $fluxes->color(
805 upper => new Astro::WaveBand(Filter => $filters[0]),
806 lower => new Astro::WaveBand(Filter => $filters[1]));
807  
808 20 $col_error = $color->error('mag');
809 }
810 20 return $col_error;
811 }
812  
813 =item B<preferred_magnitude_type>
814  
815 Get or set the preferred magnitude type to be returned from the get_magnitude method.
816  
817 my $type = $item->preferred_magnitude_type;
818 $item->preferred_magnitude_type('MAG_ISO');
819  
820 Defaults to 'MAG'.
821  
822 =cut
823  
824 124 ▶sub preferred_magnitude_type {
Subroutine preferred_magnitude_type: called CC=3 SCAR=11.6
Pod documented
825 124 my $self = shift;
826 124 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 124 124
827 0 my $type = shift;
828 0 $self->{PREFERRED_MAG_TYPE} = $type;
829 }
830  
831 124 ▶ unless (defined $self->{PREFERRED_MAG_TYPE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"PREFERRED_MAG_TYPE"}) 8 116 124
832 8 $self->{PREFERRED_MAG_TYPE} = 'MAG';
833 }
834  
835 124 return $self->{PREFERRED_MAG_TYPE};
836 }
837  
838 =item B<morphology>
839  
840 Get or set the morphology of the star as an C<Astro::Catalog::Item::Morphology>
841 object.
842  
843 $star->morphology($morphology);
844  
845 The object returned by this method is the actual object stored
846 inside this Star object and not a clone. If the morphology
847 is changed through this object the morphology of the star is
848 also changed.
849  
850 =cut
851  
852 8 ▶sub morphology {
Subroutine morphology: called CC=3 SCAR=11.2
Pod documented
853 8 my $self = shift;
854 8 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 8 0 8
855 8 my $m = shift;
856 8 ▶ croak "Morphology must be an Astro::Catalog::Item::Morphology object"
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($m, "Astro::Catalog::Item::Morphology") 0 8 8
857 unless UNIVERSAL::isa($m, "Astro::Catalog::Item::Morphology");
858  
859 # Store the new coordinate object
860 # Storing it late stops looping from the id and comment methods
861 8 $self->{MORPHOLOGY} = $m;
862 }
863 8 return $self->{MORPHOLOGY};
864 }
865  
866 =item B<quality>
867  
868 Return (or set) the quality flag of the star
869  
870 $quality = $star->quailty();
871 $star->quality(0);
872  
873 for example for the USNO-A2 catalog, 0 denotes good quality, and 1
874 denotes a possible problem object. In the generic case any flag value,
875 including a boolean, could be used.
876  
877 These quality flags are standardised sybolically across catalogs and
878 have the following definitions:
879  
880 STARGOOD
881 STARBAD
882  
883 TBD. Need to provide quality constants and mapping to and from these
884 constants on catalog I/O.
885  
886 =cut
887  
888 80 ▶sub quality {
Subroutine quality: called CC=10 SCAR=36.2
Pod documented
889 80 my $self = shift;
890 80 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 56 24 80
891  
892 # 2MASS hack
893 # ----------
894 # quick, dirty and ultimately icky hack. The entire quality flag
895 # code is going to have to be rewritten so it works like mag errors,
896 # and gets assocaited with a magnitude. For now, if the JHK QFlag
897 # for 2MASS is A,B or C then the internal quality flag is 0 (good),
898 # otherwise it gets set to 1 (bad). This pretty much sucks.
899  
900 # Yes Tim, I know I'm doing this in the wrong place. I'm panicing
901 # I'll fix it later. I've moved the Cluster specific hack about the
902 # star ID's out of Astro::Catalog::query::USNOA2 and into the Cluster
903 # IO module and used Scalar::Util to figure out whether I've got a
904 # number (neat solution) before blowing it away.
905  
906 # Anyway...
907 56 my $quality = shift;
908  
909 # Shouldn't happen?
910 56 ▶ unless (defined $quality) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $quality) 9 47 56
911 9 $self->{QUALITY} = undef;
912 9 return undef;
913 }
914  
915 47 ▶ if ($quality =~ /^[A-Z][A-Z][A-Z]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quality =~ /^[A-Z][A-Z][A-Z]$/) { } 0 47 47
916 0 $_ = $quality;
917 0 m/^([A-Z])([A-Z])([A-Z])$/;
918  
919 0 my $j_quality = $1;
920 0 my $h_quality = $2;
921 0 my $k_quality = $3;
922  
923 0 ▶ if (($j_quality eq 'A' || $j_quality eq 'B' || $j_quality eq 'C') &&
Branch: 1 branch
BranchTrueFalseTotal
if ($j_quality eq 'A' || $j_quality eq 'B' || $j_quality eq 'C' and $h_quality eq 'A' || $h_quality eq 'B' || $h_quality eq 'C') { } 0 0 0
Condition0%0/15
$j_quality eq "A" || $j_quality eq "B" || $j_quality eq "C" and $h_quality eq "A" || $h_quality eq "B" || $h_quality eq "C"
!ll&&!rl&&r
000
$j_quality eq "A" or $j_quality eq "B" or $j_quality eq "C"
l!l&&r!l&&!r
000
$j_quality eq "A" or $j_quality eq "B"
l!l&&r!l&&!r
000
$h_quality eq "A" or $h_quality eq "B" or $h_quality eq "C"
l!l&&r!l&&!r
000
$h_quality eq "A" or $h_quality eq "B"
l!l&&r!l&&!r
000
MC/DC0%0/6
$j_quality eq "A" || $j_quality eq "B" || $j_quality eq "C" and $h_quality eq "A" || $h_quality eq "B" || $h_quality eq "C"
$j_quality eq "A" $j_quality eq "B" $j_quality eq "C" $h_quality eq "A" $h_quality eq "B" $h_quality eq "C"
Truth table0%0/13
A or B or C and D or E or F
A= $j_quality eq "A"B= $j_quality eq "B"C= $j_quality eq "C"D= $h_quality eq "A"E= $h_quality eq "B"F= $h_quality eq "C"
ABCDEFresult
000XXX0
1XX0000
01X0000
0010000
1XX1XX1
1XX01X1
1XX0011
01X1XX1
01X01X1
01X0011
0011XX1
00101X1
0010011
924 ($h_quality eq 'A' || $h_quality eq 'B' || $h_quality eq 'C')) {
925 # good quality
926 0 $self->{QUALITY} = 0;
927 }
928 else {
929 # bad quality
930 0 $self->{QUALITY} = 1;
931 }
932 }
933 else {
934 47 $self->{QUALITY} = $quality;
935 }
936  
937 }
938 71 return $self->{QUALITY};
939 }
940  
941 =item B<field>
942  
943 Return (or set) the field parameter for the star
944  
945 $field = $star->field();
946 $star->field('0080');
947  
948 =cut
949  
950 835 ▶sub field {
Subroutine field: called CC=2 SCAR=6.9
Pod documented
951 835 my $self = shift;
952 835 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 820 15 835
953 820 $self->{FIELD} = shift;
954 }
955 835 return $self->{FIELD};
956 }
957  
958 =item B<gsc>
959  
960 Return (or set) the GSC flag for the object
961  
962 $gsc = $star->gsc();
963 $star->gsc( 'TRUE' );
964  
965 the flag is TRUE if the object is known to be in the Guide Star Catalog,
966 and FALSE otherwise.
967  
968 =cut
969  
970 44 ▶sub gsc {
Subroutine gsc: called CC=2 SCAR=6.9
Pod documented
971 44 my $self = shift;
972 44 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 40 4 44
973 40 $self->{GSC} = shift;
974 }
975 44 return $self->{GSC};
976 }
977  
978 =item B<distance>
979  
980 Return (or set) the distance from the field centre
981  
982 $distance = $star->distance();
983 $star->distance('0.009');
984  
985 e.g. for the USNO-A2 catalog.
986  
987 =cut
988  
989 44 ▶sub distance {
Subroutine distance: called CC=2 SCAR=6.9
Pod documented
990 44 my $self = shift;
991 44 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 40 4 44
992 40 $self->{DISTANCE} = shift;
993 }
994 44 return $self->{DISTANCE};
995 }
996  
997 =item B<posangle>
998  
999 Return (or set) the position angle from the field centre
1000  
1001 $position_angle = $star->posangle();
1002 $star->posangle('50.761');
1003  
1004 e.g. for the USNO-A2 catalog.
1005  
1006 =cut
1007  
1008 44 ▶sub posangle {
Subroutine posangle: called CC=2 SCAR=6.9
Pod documented
1009 44 my $self = shift;
1010 44 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 40 4 44
1011 40 $self->{POSANGLE} = shift;
1012 }
1013 44 return $self->{POSANGLE};
1014 }
1015  
1016 =item B<x>
1017  
1018 Return (or set) the X pixel co-ordinate of the star
1019  
1020 $x = $star->x();
1021 $star->id($x);
1022  
1023 =cut
1024  
1025 95 ▶sub x {
Subroutine x: called CC=7 SCAR=30.0
Pod documented
1026 95 my $self = shift;
1027 95 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 44 51 95
1028 44 $self->{X} = shift;
1029 }
1030  
1031 95 ▶ if (! defined($self->{X}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"X"} and defined $self->wcs and defined $self->coords) 0 95 95
Condition50%3/6
not defined $self->{"X"} and defined $self->wcs and defined $self->coords
!ll&&!rl&&r
9500
not defined $self->{"X"} and defined $self->wcs
!ll&&!rl&&r
9140
MC/DC0%0/3
not defined $self->{"X"} and defined $self->wcs and defined $self->coords
not defined $self->{"X"} defined $self->wcs defined $self->coords
Truth table50%2/4
not(A) and B and C
A= not defined $self->{"X"}B= defined $self->wcsC= defined $self->coords
ABCresult
0XX0
10X0
1100
1111
1032 defined($self->wcs) &&
1033 defined($self->coords)) {
1034  
1035 # We need to get a template FK5 SkyFrame to be able to convert
1036 # properly between RA/Dec and X/Y, but we can only do this if
1037 # we load Starlink::AST. So that we don't have a major dependency
1038 # on that module, load it here at runtime.
1039 0 eval {require Starlink::AST;};
1040 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1041 0 croak "Attempted to convert from RA/Dec to X position and cannot load Starlink::AST. Error: $@";
1042 }
1043 0 my $template = new Starlink::AST::SkyFrame("System=FK5");
1044 0 my $wcs = $self->wcs;
1045 0 my $frameset = $wcs->FindFrame($template, "");
1046 0 ▶ unless (defined $frameset) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $frameset) 0 0 0
1047 0 croak "Could not find FK5 SkyFrame to do RA/Dec to X position translation";
1048 }
1049 0 my ($ra, $dec) = $self->coords->radec();
1050 0 my ($x, $y) = $frameset->Tran2(
1051 [$ra->radians],
1052 [$dec->radians],
1053 0);
1054 0 $self->{X} = $x->[0];
1055 }
1056 95 return $self->{X};
1057 }
1058  
1059 =item B<y>
1060  
1061 Return (or set) the Y pixel co-ordinate of the star
1062  
1063 $y = $star->y();
1064 $star->id($y);
1065  
1066 =cut
1067  
1068 95 ▶sub y {
Subroutine y: called CC=7 SCAR=30.0
Pod documented
1069 95 my $self = shift;
1070 95 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 44 51 95
1071 44 $self->{Y} = shift;
1072 }
1073  
1074 95 ▶ if (! defined($self->{Y}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"Y"} and defined $self->wcs and defined $self->coords) 0 95 95
Condition50%3/6
not defined $self->{"Y"} and defined $self->wcs and defined $self->coords
!ll&&!rl&&r
9500
not defined $self->{"Y"} and defined $self->wcs
!ll&&!rl&&r
9140
MC/DC0%0/3
not defined $self->{"Y"} and defined $self->wcs and defined $self->coords
not defined $self->{"Y"} defined $self->wcs defined $self->coords
Truth table50%2/4
not(A) and B and C
A= not defined $self->{"Y"}B= defined $self->wcsC= defined $self->coords
ABCresult
0XX0
10X0
1100
1111
1075 defined($self->wcs) &&
1076 defined($self->coords)) {
1077  
1078 # We need to get a template FK5 SkyFrame to be able to convert
1079 # properly between RA/Dec and X/Y, but we can only do this if
1080 # we load Starlink::AST. So that we don't have a major dependency
1081 # on that module, load it here at runtime.
1082 0 eval {require Starlink::AST;};
1083 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1084 0 croak "Attempted to convert from RA/Dec to Y position and cannot load Starlink::AST. Error: $@";
1085 }
1086 0 my $template = new Starlink::AST::SkyFrame("System=FK5");
1087 0 my $wcs = $self->wcs;
1088 0 my $frameset = $wcs->FindFrame($template, "");
1089 0 ▶ unless (defined $frameset) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $frameset) 0 0 0
1090 0 croak "Could not find FK5 SkyFrame to do RA/Dec to Y position translation";
1091 }
1092 0 my ($ra, $dec) = $self->coords->radec();
1093 0 my ($x, $y) = $frameset->Tran2(
1094 [$ra->radians],
1095 [$dec->radians],
1096 0);
1097 0 $self->{Y} = $y->[0];
1098 }
1099  
1100 95 return $self->{Y};
1101 }
1102  
1103 =item B<wcs>
1104  
1105 Return (or set) the WCS associated with the star.
1106  
1107 $wcs = $star->wcs;
1108 $star->wcs($wcs);
1109  
1110 The WCS is a C<Starlink::AST> object.
1111  
1112 =cut
1113  
1114 13 ▶sub wcs {
Subroutine wcs: called CC=4 SCAR=22.9
Pod documented
1115 13 my $self = shift;
1116 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 13 13
1117 0 my $wcs = shift;
1118 0 ▶ unless (defined $wcs) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $wcs) { } 0 0 0
if (do { UNIVERSAL::isa($wcs, "Starlink::AST") }) 0 0 0
1119 0 $self->{WCS} = undef;
1120 }
1121 0 elsif (UNIVERSAL::isa($wcs, "Starlink::AST")) {
1122 0 $self->{WCS} = $wcs;
1123 }
1124 }
1125 13 return $self->{WCS};
1126 }
1127  
1128 =item B<comment>
1129  
1130 Return (or set) a comment associated with the star
1131  
1132 $comment = $star->comment();
1133 $star->comment($comment_string);
1134  
1135 The comment is propogated to the underlying coordinate
1136 object (if one is present) if the comment is updated.
1137  
1138 =cut
1139  
1140 1956 ▶sub comment {
Subroutine comment: called CC=3 SCAR=11.0
Pod documented
1141 1956 my $self = shift;
1142 1956 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1556 400 1956
1143 1556 $self->{COMMENT} = shift;
1144  
1145 1556 my $c = $self->coords;
1146 1556 ▶ $c->comment($self->{COMMENT}) if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 774 782 1556
1147 }
1148 1956 return $self->{COMMENT};
1149 }
1150  
1151 =item B<spectype>
1152  
1153 The spectral type of the Star.
1154  
1155 $spec = $star->spectype;
1156  
1157 =cut
1158  
1159 2 ▶sub spectype {
Subroutine spectype: called CC=2 SCAR=7.0
Pod documented
1160 2 my $self = shift;
1161 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 0 2
1162 2 $self->{SPECTYPE} = shift;
1163 }
1164 2 return $self->{SPECTYPE};
1165 }
1166  
1167 =item B<startype>
1168  
1169 The type of star. Usually uses the Simbad abbreviation.
1170 eg. '*' for a star, 'rG' for a Radio Galaxy.
1171  
1172 $type = $star->startype;
1173  
1174 See also C<longstartype> for the expanded version of this type.
1175  
1176 =cut
1177  
1178 0 ▶sub startype {
Subroutine startype: not called CC=2 SCAR=17.9
Pod documented
1179 0 my $self = shift;
1180 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1181 0 $self->{STARTYPE} = shift;
1182 }
1183 0 return $self->{STARTYPE};
1184 }
1185  
1186 =item B<longstartype>
1187  
1188 The full description of the type of star. Usually uses the Simbad text.
1189 If no text has been provided, a lookup will be performed using the
1190 abbreviated C<startype>.
1191  
1192 $long = $star->longstartype;
1193 $star->longstartype("A variable star");
1194  
1195 See also C<longstartype> for the expanded version of this type.
1196  
1197 =cut
1198  
1199 0 ▶sub longstartype {
Subroutine longstartype: not called CC=5 SCAR=34.0
Pod documented
1200 0 my $self = shift;
1201 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1202 0 $self->{LONGTYPE} = shift;
1203 }
1204 # if we have nothing, attempt a look up
1205 0 ▶ if (! defined $self->{LONGTYPE} && defined $self->startype
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'LONGTYPE'} and defined $self->startype and exists $STAR_TYPE_LOOKUP{$self->startype}) { } 0 0 0
Condition0%0/6
not defined $self->{"LONGTYPE"} and defined $self->startype and exists $STAR_TYPE_LOOKUP{$self->startype}
!ll&&!rl&&r
000
not defined $self->{"LONGTYPE"} and defined $self->startype
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $self->{"LONGTYPE"} and defined $self->startype and exists $STAR_TYPE_LOOKUP{$self->startype}
not defined $self->{"LONGTYPE"} defined $self->startype exists $STAR_TYPE_LOOKUP{$self->startype}
Truth table0%0/4
not(A) and B and C
A= not defined $self->{"LONGTYPE"}B= defined $self->startypeC= exists $STAR_TYPE_LOOKUP{$self->startype}
ABCresult
0XX0
10X0
1100
1111
1206 && exists $STAR_TYPE_LOOKUP{$self->startype}) {
1207 0 return $STAR_TYPE_LOOKUP{$self->startype};
1208 }
1209 else {
1210 0 return $self->{STARTYPE};
1211 }
1212 }
1213  
1214 =item B<moreinfo>
1215  
1216 A link (URL) to more information on the star in question. For example
1217 this might provide a direct link to the full Simbad description.
1218  
1219 $url = $star->moreinfo;
1220  
1221 =cut
1222  
1223 0 ▶sub moreinfo {
Subroutine moreinfo: not called CC=2 SCAR=17.9
Pod documented
1224 0 my $self = shift;
1225 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1226 0 $self->{MOREINFO} = shift;
1227 }
1228 0 return $self->{MOREINFO};
1229 }
1230  
1231 =item B<insertdate>
1232  
1233 The time the information for the star in question was gathered. This
1234 is different from the time of observation of the star.
1235  
1236 $insertdate = $star->insertdate;
1237  
1238 This is a C<Time::Piece> object.
1239  
1240 =cut
1241  
1242 0 ▶sub insertdate {
Subroutine insertdate: not called CC=2 SCAR=17.9
Pod documented
1243 0 my $self = shift;
1244 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1245 0 $self->{INSERTDATE} = shift;
1246 }
1247 0 return $self->{INSERTDATE};
1248 }
1249  
1250  
1251 =item B<fluxdatestamp>
1252  
1253 Apply a datestamp to all the C<Astro::Flux> objects inside the
1254 C<Astro::Fluxes> object contained within this object
1255  
1256 $star->fluxdatestamp(new DateTime());
1257  
1258 this is different from the time for which the inormation about the
1259 star was gathered, see the insertdate() method call, and is the
1260 time of observation of the object.
1261  
1262 =cut
1263  
1264 1 ▶sub fluxdatestamp {
Subroutine fluxdatestamp: called CC=3 SCAR=11.2
Pod documented
1265 1 my $self = shift;
1266 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 0 1
1267 1 my $datetime = shift;
1268 1 ▶ croak "Astro::Catalog::Item::fluxdatestamp()\n".
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($datetime, "DateTime") 0 1 1
1269 "Error: Not a DateTime object\n"
1270 unless UNIVERSAL::isa($datetime, "DateTime");
1271 1 $self->{FLUXES}->datestamp($datetime);
1272 }
1273 1 return $self->{FLUXES};
1274 }
1275  
1276  
1277 =item B<distancetostar>
1278  
1279 The distance from another Item,
1280  
1281 my $distance1 = $star->distancetostar($star2);
1282  
1283 returns a tangent plane separation value in arcsec. Returns undef if
1284 the star is too far away.
1285  
1286 =cut
1287  
1288 4 ▶sub distancetostar {
Subroutine distancetostar: called CC=3 SCAR=11.3
Pod documented
1289 4 my $self = shift;
1290 4 my $other = shift;
1291  
1292 4 ▶ croak "Astro::Catalog::Item::distancetostar()\n".
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($other, "Astro::Catalog::Item") 0 4 4
1293 "Error: Not an Astro::Catalog::Item object\n"
1294 unless UNIVERSAL::isa($other, "Astro::Catalog::Item");
1295  
1296 4 my $sep = $self->coords->distance($other->coords);
1297 4 ▶ return (defined $sep ? $sep->arcsec : $sep);
Branch: 1 branch
BranchTrueFalseTotal
defined $sep ? : 4 0 4
1298 }
1299  
1300  
1301 =item B<within>
1302  
1303 Check if the passed star is within $distance_in_arcsec of the object.
1304  
1305 my $status = $star->within($star2, $distance_in_arcsec);
1306  
1307 returns true if this is the case.
1308  
1309 =cut
1310  
1311 2 ▶sub within {
Subroutine within: called CC=3 SCAR=11.0
Pod documented
1312 2 my $self = shift;
1313 2 my $other = shift;
1314 2 my $max = shift;
1315  
1316 2 ▶ croak "Astro::Catalog::Item::within()\n".
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($other, "Astro::Catalog::Item") 0 2 2
1317 "Error: Not an Astro::Catalog::Item object\n"
1318 unless UNIVERSAL::isa( $other, "Astro::Catalog::Item" );
1319  
1320 2 my $distance = $self->distancetostar($other);
1321 2 ▶ return 1 if $distance < $max;
Branch: 1 branch
BranchTrueFalseTotal
if $distance < $max 1 1 2
1322 1 return 0;
1323 }
1324  
1325  
1326 =item B<misc>
1327  
1328 A hold-all method to contain information not covered by other methods.
1329  
1330 my $misc = $item->misc;
1331 $item->misc($misc);
1332  
1333 This accessor can hold any type of variable, although it is
1334 recommended that a hash reference is used for easier lookups:
1335  
1336 my $misc = $item->misc;
1337 my $vrad = $misc->{'vrad'};
1338 my $vopt = $misc->{'vopt'}
1339  
1340 =cut
1341  
1342 1872 ▶sub misc {
Subroutine misc: called CC=2 SCAR=6.9
Pod documented
1343 1872 my $self = shift;
1344 1872 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 751 1121 1872
1345 751 $self->{'MISC'} = shift;
1346 }
1347 1872 return $self->{'MISC'};
1348 }
1349  
1350 =back
1351  
1352 =head2 Obsolete Methods
1353  
1354 Several methods were made obsolete with the introduction of V4 of the
1355 Astro::Catalog class. These were magnitudes(), magerr(), colours() and
1356 colerr(). The functionality these supported is now part of the addfluxes()
1357 method.
1358  
1359 =cut
1360  
1361 0 ▶sub magnitudes {
Subroutine magnitudes: not called CC=1 SCAR=6.9
Pod undocumented
1362 0 my $self = shift;
1363 0 croak "Astro::Catalog::Item::magnitudes()\n" .
1364 "This method is no longer supported, use fluxes() instead.\n";
1365 }
1366  
1367 0 ▶sub magerr {
Subroutine magerr: not called CC=1 SCAR=6.9
Pod undocumented
1368 0 my $self = shift;
1369 0 croak "Astro::Catalog::Item::magerr()\n" .
1370 "This method is no longer supported, use fluxes() instead.\n";
1371 }
1372  
1373  
1374 0 ▶sub colours {
Subroutine colours: not called CC=1 SCAR=6.9
Pod undocumented
1375 0 my $self = shift;
1376 0 croak "Astro::Catalog::Item::colours()\n" .
1377 "This method is no longer supported, use fluxes() instead.\n";
1378  
1379 }
1380  
1381 0 ▶sub colerr {
Subroutine colerr: not called CC=1 SCAR=6.9
Pod undocumented
1382 0 my $self = shift;
1383 0 croak "Astro::Catalog::Item::colerr()\n" .
1384 "This method is no longer supported, use fluxes() instead.\n";
1385  
1386 }
1387  
1388 =head2 General Methods
1389  
1390 =over 4
1391  
1392 =item B<configure>
1393  
1394 Configures the object from multiple pieces of information.
1395  
1396 $star->configure(%options);
1397  
1398 Takes a hash as argument with the list of keywords.
1399 The keys are not case-sensitive and map to accessor methods.
1400  
1401 Note that RA and Dec keys are allowed. The values can be supplied in either sexagesimal or decimal degrees.
1402  
1403 =cut
1404  
1405 817 ▶sub configure {
Subroutine configure: called CC=24 SCAR=47.3
Pod documented
1406 817 my $self = shift;
1407  
1408 # return unless we have arguments
1409 817 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 817 817
1410  
1411 # grab the argument list
1412 817 my %args = @_;
1413  
1414 # First check for duplicate keys (case insensitive) with different
1415 # values and store the unique lower-cased keys
1416 817 my %check;
1417 817 for my $key (keys %args) {
1418 4036 my $lckey = lc($key);
1419 4036 ▶ if (exists $check{$lckey} && $check{$lckey} ne $args{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $check{$lckey} and $check{$lckey} ne $args{$key}) 0 4036 4036
Condition33%1/3
exists $check{$lckey} and $check{$lckey} ne $args{$key}
!ll&&!rl&&r
403600
MC/DC0%0/2
exists $check{$lckey} and $check{$lckey} ne $args{$key}
exists $check{$lckey} $check{$lckey} ne $args{$key}
Truth table33%1/3
A and B
A= exists $check{$lckey}B= $check{$lckey} ne $args{$key}
ABresult
0X0
100
111
1420 0 warnings::warnif("Duplicated key in constructor [$lckey] with differing values ".
1421 " '$check{$lckey}' and '$args{$key}'\n");
1422 }
1423 4036 $check{$lckey} = $args{$key};
1424 }
1425  
1426 # Now that we have lower cased keys we can look to see if we have
1427 # ra & dec as well as coords and also verify that they are actually
1428 # the same if we have them
1429 817 ▶ if (exists $check{coords} && (exists $check{ra} || exists $check{dec})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $check{'coords'} and exists $check{'ra'} || exists $check{'dec'}) { } 0 817 817
elsif (exists $check{'ra'} or $check{'dec'}) { } 7 810 817
Condition50%3/6
exists $check{"coords"} and exists $check{"ra"} || exists $check{"dec"}
!ll&&!rl&&r
277900
exists $check{"ra"} or exists $check{"dec"}
l!l&&r!l&&!r
00790
MC/DC0%0/3
exists $check{"coords"} and exists $check{"ra"} || exists $check{"dec"}
exists $check{"coords"} exists $check{"ra"} exists $check{"dec"}
Truth table50%2/4
A and B or C
A= exists $check{"coords"}B= exists $check{"ra"}C= exists $check{"dec"}
ABCresult
0XX0
1000
11X1
1011
1430 # coords + one of ra or dec is a mistake
1431 0 ▶ if (exists $check{ra} && exists $check{dec}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $check{'ra'} and exists $check{'dec'}) { } 0 0 0
elsif (not exists $check{'ra'}) { } 0 0 0
elsif (not exists $check{'dec'}) { } 0 0 0
Condition0%0/3
exists $check{"ra"} and exists $check{"dec"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $check{"ra"} and exists $check{"dec"}
exists $check{"ra"} exists $check{"dec"}
Truth table0%0/3
A and B
A= exists $check{"ra"}B= exists $check{"dec"}
ABresult
0X0
100
111
1432 # Create a new coords object - assume J2000
1433 my $c = new Astro::Coords(
1434 type => 'J2000',
1435 ra => $check{ra},
1436 dec => $check{dec},
1437 # units => 'sex',
1438 0 );
1439  
1440 # Make sure we have the same reference place and time
1441 $c->datetime($check{coords}->datetime)
1442 0 ▶ if $check{coords}->has_datetime;
Branch: 1 branch
BranchTrueFalseTotal
if $check{"coords"}->has_datetime 0 0 0
1443 $c->telescope($check{coords}->telescope)
1444 0 ▶ if defined $check{coords}->telescope;
Branch: 1 branch
BranchTrueFalseTotal
if defined $check{"coords"}->telescope 0 0 0
1445  
1446  
1447 # Check the distance
1448 0 my $d = $c->distance($check{coords});
1449  
1450 # Raise warn if the error is more than 1 arcsecond
1451 0 ▶ warnings::warnif( "Coords and RA/Dec were specified and they differ by more than 1 arcsec [".
Branch: 2 branches
BranchTrueFalseTotal
if not defined $d or $d->arcsec > 1 0 0 0
defined $d ? : 0 0 0
Condition0%0/3
not defined $d or $d->arcsec > 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $d or $d->arcsec > 1
not defined $d $d->arcsec > 1
Truth table0%0/3
not(A) or B
A= not defined $dB= $d->arcsec > 1
ABresult
1X1
011
000
1452 (defined $d ? $d->arcsec : "<undef>")
1453 ." sec]. Ignoring RA/Dec keys.\n")
1454 if (!defined $d || $d->arcsec > 1.0);
1455  
1456 }
1457 elsif (! exists $check{ra}) {
1458 0 warnings::warnif("Dec specified in addition to Coords but without RA. Ignoring it.");
1459 }
1460 elsif (! exists $check{dec}) {
1461 0 warnings::warnif("RA specified in addition to Coords but without Dec. Ignoring it.");
1462 }
1463  
1464 # Whatever happens we do not want ra and dec here
1465 0 delete $check{dec};
1466 0 delete $check{ra};
1467 }
1468 ▶ elsif (exists $check{ra} || $check{dec}) {
Condition66%2/3
exists $check{"ra"} or $check{"dec"}
l!l&&r!l&&!r
70810
MC/DC50%1/2
exists $check{"ra"} or $check{"dec"}
exists $check{"ra"} $check{"dec"}
Truth table66%2/3
A or B
A= exists $check{"ra"}B= $check{"dec"}
ABresult
1X1
011
000
1469 # Generate a Astro::Coords object here in one go rather than
1470 # relying on the old ra() dec() methods individually
1471 7 ▶ my $ra = $check{ra} || 0.0;
Condition50%1/2
$check{'ra'} || 0.0
l!l
70
MC/DC0%0/1
$check{'ra'} || 0.0
$check{'ra'}
Truth table50%1/2
A
A= $check{'ra'}
Aresult
11
00
1472 7 ▶ my $dec = $check{dec} || 0.0;
Condition50%1/2
$check{'dec'} || 0.0
l!l
70
MC/DC0%0/1
$check{'dec'} || 0.0
$check{'dec'}
Truth table50%1/2
A
A= $check{'dec'}
Aresult
11
00
1473 7 $check{coords} = new Astro::Coords(
1474 type => 'J2000',
1475 ra => $ra,
1476 dec => $dec);
1477 7 delete $check{ra};
1478 7 delete $check{dec};
1479 }
1480  
1481 # If we have "coords", process this first, as some of the other
1482 # accessors assign information to the coords object.
1483 817 ▶ if (exists $check{'coords'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $check{"coords"}) 797 20 817
1484 797 $self->coords($check{'coords'});
1485 797 delete $check{'coords'};
1486 }
1487  
1488 # Loop over the allowed keys storing the values
1489 # in the object if they exist. Case insensitive.
1490 817 for my $key (keys %check) {
1491 3232 my $method = lc($key);
1492 3232 ▶ $self->$method($check{$key}) if $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 3232 0 3232
1493 }
1494 817 return;
1495 }
1496  
1497 60 1;
1498  
1499 __END__
« Astro/Catalog/Query/SIMBAD.pm ↑ Summary Astro/Catalog/Query/SkyCat.pm »