| 1 | package Astro::Catalog::IO::UKIRTBS; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Astro::Catalog::IO::UKIRTBS - Old format used by UKIRT Bright Star catalogs | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | $cat = Astro::Catalog::IO::UKIRTBS->_read_catalog(\@lines); | ||||||||||
| 10 | |||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||
| 12 | |||||||||||
| 13 | This class provides a read method for catalogs written in a format | ||||||||||
| 14 | used by the old C<ukstar> web interface to the SAO and Bright Star | ||||||||||
| 15 | catalogs. It is probable that this format has a real name and is a | ||||||||||
| 16 | historical format rather than a UKIRT-specific format but the history | ||||||||||
| 17 | of C<ukstar> and the associated catalog files is not known to the | ||||||||||
| 18 | author of this module. | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | use warnings::register; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | use Astro::Catalog; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 2 | ▶ | use Astro::Catalog::Item; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | use base qw/Astro::Catalog::IO::ASCII/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | 2 | our $VERSION = '4.38'; | |||||||||
| 33 | |||||||||||
| 34 | =over 4 | ||||||||||
| 35 | |||||||||||
| 36 | =item B<_read_catalog> | ||||||||||
| 37 | |||||||||||
| 38 | Parses the catalog lines and returns a new C<Astro::Catalog> | ||||||||||
| 39 | object containing the catalog entries. | ||||||||||
| 40 | |||||||||||
| 41 | $cat = Astro::Catalog::IO::JCMT->_read_catalog(\@lines); | ||||||||||
| 42 | |||||||||||
| 43 | No options are supported. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | 1 | ▶ | sub _read_catalog { | ||||||||
|
Subroutine
_read_catalog: called CC=3 SCAR=11.0
| |||||||||||
| 48 | 1 | my $class = shift; | |||||||||
| 49 | 1 | my $lines = shift; | |||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | croak "Must supply catalog contents as a reference to an array" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | unless ref($lines) eq 'ARRAY'; | ||||||||||
| 53 | |||||||||||
| 54 | # Go through each line and parse it | ||||||||||
| 55 | 1 | my @stars; | |||||||||
| 56 | 1 | for my $l (@$lines) { | |||||||||
| 57 | # benchmarks suggest that substr is faster than an unpack | ||||||||||
| 58 | 2 | my $bs = substr($l, 0, 8); | |||||||||
| 59 | 2 | my $ra = substr($l, 9, 12); | |||||||||
| 60 | 2 | my $dec = substr($l, 21, 12); | |||||||||
| 61 | 2 | my $rap = substr($l, 34, 4); | |||||||||
| 62 | 2 | my $decp = substr($l, 40, 4); | |||||||||
| 63 | 2 | my $mag = substr($l, 46, 4); | |||||||||
| 64 | 2 | my $type = substr($l, 50); | |||||||||
| 65 | |||||||||||
| 66 | # Tidy the result | ||||||||||
| 67 | 2 | chomp($type); | |||||||||
| 68 | 2 | $bs =~ s/^\s+//; | |||||||||
| 69 | |||||||||||
| 70 | # Create coordinate object | ||||||||||
| 71 | 2 | my $c = new Astro::Coords( | |||||||||
| 72 | ra => $ra, | ||||||||||
| 73 | dec => $dec, | ||||||||||
| 74 | type => 'B1950', | ||||||||||
| 75 | name => $bs, | ||||||||||
| 76 | units => 'r', | ||||||||||
| 77 | ); | ||||||||||
| 78 | |||||||||||
| 79 | 2 | my $s = new Astro::Catalog::Item( | |||||||||
| 80 | coords => $c, | ||||||||||
| 81 | id => $bs, | ||||||||||
| 82 | spectype => $type, | ||||||||||
| 83 | fluxes => new Astro::Fluxes( | ||||||||||
| 84 | new Astro::Flux($mag, 'mag', 'V')), | ||||||||||
| 85 | ); | ||||||||||
| 86 | |||||||||||
| 87 | 2 | push(@stars, $s); | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | # Create the catalog object | ||||||||||
| 91 | 1 | return new Astro::Catalog( | |||||||||
| 92 | Stars => \@stars, | ||||||||||
| 93 | Origin => 'UKIRT BS Catalog', | ||||||||||
| 94 | ); | ||||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 2 | 1; | |||||||||
| 98 | |||||||||||
| 99 | __END__ | ||||||||||